void BuildingsPathlossTestCase::DoRun (void) { NS_LOG_FUNCTION (this); // the building basically occupies the negative x plane, so any node // in this area will fall in the building Ptr<Building> building1 = CreateObject<Building> (); building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12)); building1->SetBuildingType (Building::Residential); building1->SetExtWallsType (Building::ConcreteWithWindows); building1->SetNFloors (3); Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1); Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2); Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> (); propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); // cancel shadowing effect propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); double loss = propagationLossModel->GetLoss (mma, mmb); NS_LOG_INFO ("Calculated loss: " << loss); NS_LOG_INFO ("Theoretical loss: " << m_lossRef); NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !"); Simulator::Destroy (); }
/* subKey を指定した場合は subkey を含むキー以下を削除 subkey が NULL の場合、カレント の配下を削除 */ BOOL TRegistry::DeleteChildTree(LPSTR subKey) { char buf[100]; BOOL ret = TRUE; if (subKey != NULL && OpenKey(subKey) != TRUE) return FALSE; while (EnumKey(0, buf, sizeof(buf))) { if ((ret = DeleteChildTree(buf)) != TRUE) break; } if (subKey != NULL) { CloseKey(); ret = DeleteKey(subKey) ? ret : FALSE; } else { while (EnumValue(0, buf, sizeof(buf))) { if (DeleteValue(buf) != TRUE) { ret = FALSE; break; } } } return ret; }
void TitleScreenModel::Update() { UpdatePlayerPosition(player1_top, Lerp(GetPlayer1TopLeft(EnumValue(court_position)), GetPlayer1TopRight(EnumValue(court_position)), Player1Position())); UpdatePlayerPosition(player1_bottom, Lerp(GetPlayer1BottomLeft(EnumValue(court_position)), GetPlayer1BottomRight(EnumValue(court_position)), Player1Position())); UpdatePlayerPosition(player2_top, Lerp(GetPlayer2TopLeft(EnumValue(court_position)), GetPlayer2TopRight(EnumValue(court_position)), Player2Position())); UpdatePlayerPosition(player2_bottom, Lerp(GetPlayer2BottomLeft(EnumValue(court_position)), GetPlayer2BottomRight(EnumValue(court_position)), Player2Position())); if(player1_position == 1.0f && player2_position == 1.0f) { dynamic_cast<WitchBall *>(ofGetAppPtr())->RunPlayScreen(); return; } world.Step(kTimeStep, kBox2dVelocityIterations, kBox2dPositionIterations); }
TypeId FdNetDevice::GetTypeId (void) { static TypeId tid = TypeId ("ns3::FdNetDevice") .SetParent<NetDevice> () .AddConstructor<FdNetDevice> () .AddAttribute ("Address", "The MAC address of this device.", Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), MakeMac48AddressAccessor (&FdNetDevice::m_address), MakeMac48AddressChecker ()) .AddAttribute ("Start", "The simulation time at which to spin up the device thread.", TimeValue (Seconds (0.)), MakeTimeAccessor (&FdNetDevice::m_tStart), MakeTimeChecker ()) .AddAttribute ("Stop", "The simulation time at which to tear down the device thread.", TimeValue (Seconds (0.)), MakeTimeAccessor (&FdNetDevice::m_tStop), MakeTimeChecker ()) .AddAttribute ("EncapsulationMode", "The link-layer encapsulation type to use.", EnumValue (DIX), MakeEnumAccessor (&FdNetDevice::m_encapMode), MakeEnumChecker (DIX, "Dix", LLC, "Llc", DIXPI, "DixPi")) .AddAttribute ("RxQueueSize", "Maximum size of the read queue. " "This value limits number of packets that have been read " "from the network into a memory buffer but have not yet " "been processed by the simulator.", UintegerValue (1000), MakeUintegerAccessor (&FdNetDevice::m_maxPendingReads), MakeUintegerChecker<uint32_t> ()) // // Trace sources at the "top" of the net device, where packets transition // to/from higher layers. These points do not really correspond to the // MAC layer of the underlying operating system, but exist to provide // a consitent tracing environment. These trace hooks should really be // interpreted as the points at which a packet leaves the ns-3 environment // destined for the underlying operating system or vice-versa. // .AddTraceSource ("MacTx", "Trace source indicating a packet has arrived for transmission by this device", MakeTraceSourceAccessor (&FdNetDevice::m_macTxTrace)) .AddTraceSource ("MacTxDrop", "Trace source indicating a packet has been dropped by the device before transmission", MakeTraceSourceAccessor (&FdNetDevice::m_macTxDropTrace)) .AddTraceSource ("MacPromiscRx", "A packet has been received by this device, has been passed up from the physical layer " "and is being forwarded up the local protocol stack. This is a promiscuous trace,", MakeTraceSourceAccessor (&FdNetDevice::m_macPromiscRxTrace)) .AddTraceSource ("MacRx", "A packet has been received by this device, has been passed up from the physical layer " "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,", MakeTraceSourceAccessor (&FdNetDevice::m_macRxTrace)) // // Trace sources designed to simulate a packet sniffer facility (tcpdump). // .AddTraceSource ("Sniffer", "Trace source simulating a non-promiscuous packet sniffer attached to the device", MakeTraceSourceAccessor (&FdNetDevice::m_snifferTrace)) .AddTraceSource ("PromiscSniffer", "Trace source simulating a promiscuous packet sniffer attached to the device", MakeTraceSourceAccessor (&FdNetDevice::m_promiscSnifferTrace)) ; return tid; }
void TitleScreenModel::CreatePlayers() { player1_top = CreatePlayer(GetPlayer1TopLeft(EnumValue(CourtPosition::POSITION_1))); player1_bottom = CreatePlayer(GetPlayer1BottomLeft(EnumValue(CourtPosition::POSITION_1))); player2_top = CreatePlayer(GetPlayer2TopLeft(EnumValue(CourtPosition::POSITION_1))); player2_bottom = CreatePlayer(GetPlayer2BottomLeft(EnumValue(CourtPosition::POSITION_1))); }
void LenaMimoTestCase::DoRun (void) { NS_LOG_FUNCTION (this << GetName ()); Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (m_useIdealRrc)); /** * Initialize Simulation Scenario: 1 eNB and m_nUser UEs */ Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false)); Config::SetDefault ("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue (false)); // lteHelper->SetSchedulerAttribute ("HarqEnabled", BooleanValue (false)); lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::HybridBuildingsPropagationLossModel")); lteHelper->SetPathlossModelAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); lteHelper->SetPathlossModelAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); lteHelper->SetPathlossModelAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); // lteHelper->EnableLogComponents (); // Create Nodes: eNodeB and UE NodeContainer enbNodes; NodeContainer ueNodes; enbNodes.Create (1); ueNodes.Create (1); // Install Mobility Model MobilityHelper mobility; mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (enbNodes); BuildingsHelper::Install (enbNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (ueNodes); BuildingsHelper::Install (ueNodes); // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; lteHelper->SetSchedulerType (m_schedulerType); enbDevs = lteHelper->InstallEnbDevice (enbNodes); ueDevs = lteHelper->InstallUeDevice (ueNodes); // Attach a UE to a eNB lteHelper->Attach (ueDevs, enbDevs.Get (0)); // Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); lteHelper->ActivateDataRadioBearer (ueDevs, bearer); Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> (); Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy (); enbPhy->SetAttribute ("TxPower", DoubleValue (46.0)); enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); Ptr<MobilityModel> mmenb = enbNodes.Get (0)->GetObject<MobilityModel> (); mmenb->SetPosition (Vector (0.0, 0.0, 30.0)); // Set UE's position and power Ptr<MobilityModel> mmue = ueNodes.Get (0)->GetObject<MobilityModel> (); mmue->SetPosition (Vector (m_dist, 0.0, 1.0)); Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (0)->GetObject<LteUeNetDevice> (); Ptr<LteUePhy> uePhy = lteUeDev->GetPhy (); uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); // need to allow for RRC connection establishment + SRS before enabling traces lteHelper->EnableRlcTraces (); lteHelper->EnableMacTraces (); double simulationTime = 0.6; double tolerance = 0.1; uint8_t rnti = 1; Ptr<LteEnbNetDevice> enbNetDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> (); PointerValue ptrval; enbNetDev->GetAttribute ("FfMacScheduler", ptrval); Ptr<PfFfMacScheduler> pfsched; Ptr<RrFfMacScheduler> rrsched; if (m_schedulerType.compare ("ns3::RrFfMacScheduler") == 0) { rrsched = ptrval.Get<RrFfMacScheduler> (); if (rrsched == 0) { NS_FATAL_ERROR ("No RR Scheduler available"); } Simulator::Schedule (Seconds (0.2), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 1); Simulator::Schedule (Seconds (0.4), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 2); } else if (m_schedulerType.compare ("ns3::PfFfMacScheduler") == 0) { pfsched = ptrval.Get<PfFfMacScheduler> (); if (pfsched == 0) { NS_FATAL_ERROR ("No Pf Scheduler available"); } Simulator::Schedule (Seconds (0.2), &PfFfMacScheduler::TransmissionModeConfigurationUpdate, pfsched, rnti, 1); Simulator::Schedule (Seconds (0.4), &PfFfMacScheduler::TransmissionModeConfigurationUpdate, pfsched, rnti, 2); } else { NS_FATAL_ERROR ("Scheduler not supported by this test"); } Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats (); rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (0.1))); NS_LOG_INFO (m_schedulerType << " MIMO test:"); double sampleTime = 0.199999; // at 0.2 RlcStats are reset for (uint8_t j = 0; j < m_estThrDl.size (); j ++) { NS_LOG_INFO ("\t test with user at distance " << m_dist << " time " << sampleTime); // get the imsi uint64_t imsi = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetImsi (); uint8_t lcId = 3; Time t = Seconds (sampleTime); Simulator::Schedule(t, &LenaMimoTestCase::GetRlcBufferSample, this, rlcStats, imsi, lcId); sampleTime += 0.2; } Simulator::Stop (Seconds (simulationTime)); Simulator::Run (); Simulator::Destroy (); NS_LOG_INFO ("Check consistency"); for (uint8_t i = 0; i < m_estThrDl.size (); i++) { NS_LOG_INFO ("interval " << i + 1 << ": bytes rxed " << (double)m_dlDataRxed.at (i) << " ref " << m_estThrDl.at (i)); NS_TEST_ASSERT_MSG_EQ_TOL ((double)m_dlDataRxed.at (i) , m_estThrDl.at (i), m_estThrDl.at (i) * tolerance, " Unfair Throughput!"); } }
virtual bool get(size_t Index, value& Value) override { return m_Key && EnumValue(m_Key.Key(), Index, Value); }
TypeId RedQueue::GetTypeId (void) { static TypeId tid = TypeId ("ns3::RedQueue") .SetParent<Queue> () .AddConstructor<RedQueue> () .AddAttribute ("Mode", "Determines unit for QueueLimit", EnumValue (QUEUE_MODE_PACKETS), MakeEnumAccessor (&RedQueue::SetMode), MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES", QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS")) .AddAttribute ("MeanPktSize", "Average of packet size", UintegerValue (500), MakeUintegerAccessor (&RedQueue::m_meanPktSize), MakeUintegerChecker<uint32_t> ()) .AddAttribute ("IdlePktSize", "Average packet size used during idle times. Used when m_cautions = 3", UintegerValue (0), MakeUintegerAccessor (&RedQueue::m_idlePktSize), MakeUintegerChecker<uint32_t> ()) .AddAttribute ("Wait", "True for waiting between dropped packets", BooleanValue (true), MakeBooleanAccessor (&RedQueue::m_isWait), MakeBooleanChecker ()) .AddAttribute ("Gentle", "True to increases dropping probability slowly when average queue exceeds maxthresh", BooleanValue (true), MakeBooleanAccessor (&RedQueue::m_isGentle), MakeBooleanChecker ()) .AddAttribute ("MinTh", "Minimum average length threshold in packets/bytes", DoubleValue (5), MakeDoubleAccessor (&RedQueue::m_minTh), MakeDoubleChecker<double> ()) .AddAttribute ("MaxTh", "Maximum average length threshold in packets/bytes", DoubleValue (15), MakeDoubleAccessor (&RedQueue::m_maxTh), MakeDoubleChecker<double> ()) .AddAttribute ("QueueLimit", "Queue limit in bytes/packets", UintegerValue (25), MakeUintegerAccessor (&RedQueue::m_queueLimit), MakeUintegerChecker<uint32_t> ()) .AddAttribute ("QW", "Queue weight related to the exponential weighted moving average (EWMA)", DoubleValue (0.002), MakeDoubleAccessor (&RedQueue::m_qW), MakeDoubleChecker <double> ()) .AddAttribute ("LInterm", "The maximum probability of dropping a packet", DoubleValue (50), MakeDoubleAccessor (&RedQueue::m_lInterm), MakeDoubleChecker <double> ()) .AddAttribute ("Ns1Compat", "NS-1 compatibility", BooleanValue (false), MakeBooleanAccessor (&RedQueue::m_isNs1Compat), MakeBooleanChecker ()) .AddAttribute ("LinkBandwidth", "The RED link bandwidth", DataRateValue (DataRate ("1.5Mbps")), MakeDataRateAccessor (&RedQueue::m_linkBandwidth), MakeDataRateChecker ()) .AddAttribute ("LinkDelay", "The RED link delay", TimeValue (MilliSeconds (20)), MakeTimeAccessor (&RedQueue::m_linkDelay), MakeTimeChecker ()) ; return tid; }
void LenaDlCtrlPhyErrorModelTestCase::DoRun (void) { double ber = 0.03; Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (ber)); Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (true)); Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false)); Config::SetGlobal ("RngRun", IntegerValue (m_rngRun)); /* * Initialize Simulation Scenario: 1 eNB and m_nUser UEs */ int64_t stream = 1; Ptr<LteHelper> lena = CreateObject<LteHelper> (); // Create Nodes: eNodeB and UE NodeContainer enbNodes; NodeContainer ueNodes; enbNodes.Create (m_nEnb); ueNodes.Create (1); // Install Mobility Model MobilityHelper mobility; mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (enbNodes); BuildingsHelper::Install (enbNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (ueNodes); BuildingsHelper::Install (ueNodes); // remove random shadowing component lena->SetAttribute ("PathlossModel", StringValue ("ns3::HybridBuildingsPropagationLossModel")); lena->SetPathlossModelAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); lena->SetPathlossModelAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); lena->SetPathlossModelAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; lena->SetSchedulerType ("ns3::RrFfMacScheduler"); lena->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI)); enbDevs = lena->InstallEnbDevice (enbNodes); stream += lena->AssignStreams (enbDevs, stream); ueDevs = lena->InstallUeDevice (ueNodes); stream += lena->AssignStreams (ueDevs, stream); // Attach a UE to one eNB (the others are interfering ones) lena->Attach (ueDevs, enbDevs.Get (0)); // Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); lena->ActivateDataRadioBearer (ueDevs, bearer); // Set UEs' position and power for (int i = 0; i < m_nEnb; i++) { // place the HeNB over the default rooftop level (20 mt.) Ptr<MobilityModel> mm = enbNodes.Get (i)->GetObject<MobilityModel> (); mm->SetPosition (Vector (0.0, 0.0, 30.0)); Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (i)->GetObject<LteEnbNetDevice> (); Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy (); enbPhy->SetAttribute ("TxPower", DoubleValue (43.0)); enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); } // Set UEs' position and power Ptr<MobilityModel> mm = ueNodes.Get (0)->GetObject<MobilityModel> (); mm->SetPosition (Vector (m_dist, 0.0, 1.0)); Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (0)->GetObject<LteUeNetDevice> (); Ptr<LteUePhy> uePhy = lteUeDev->GetPhy (); uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); Time statsDuration = Seconds (1.0); Simulator::Stop (m_statsStartTime + statsDuration - Seconds (0.0001)); lena->EnableRlcTraces (); Ptr<RadioBearerStatsCalculator> rlcStats = lena->GetRlcStats (); rlcStats->SetAttribute ("StartTime", TimeValue (m_statsStartTime)); rlcStats->SetAttribute ("EpochDuration", TimeValue (statsDuration)); Simulator::Run (); NS_LOG_INFO ("\tTest downlink control channels (PCFICH+PDCCH)"); NS_LOG_INFO ("Test with " << m_nEnb << " eNB(s) at distance " << m_dist << " expected BLER " << m_blerRef); int nUser = 1; for (int i = 0; i < nUser; i++) { // get the imsi uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi (); uint8_t lcId = 3; double dlRxPackets = rlcStats->GetDlRxPackets (imsi, lcId); double dlTxPackets = rlcStats->GetDlTxPackets (imsi, lcId); double dlBler = 1.0 - (dlRxPackets/dlTxPackets); double expectedDlRxPackets = dlTxPackets -dlTxPackets*m_blerRef; NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " DOWNLINK" << " pkts rx " << dlRxPackets << " tx " << dlTxPackets << " BLER " << dlBler << " Err " << std::fabs (m_blerRef - dlBler) << " expected rx " << expectedDlRxPackets << " difference " << std::abs (expectedDlRxPackets - dlRxPackets) << " tolerance " << m_toleranceRxPackets); NS_UNUSED (dlBler); // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI double expectedDlTxPackets = statsDuration.GetMilliSeconds (); NS_TEST_ASSERT_MSG_EQ_TOL (dlTxPackets, expectedDlTxPackets, expectedDlTxPackets * 0.005, " too different DL TX packets reported"); // this is the main test condition: check that the RX packets are within the expected range NS_TEST_ASSERT_MSG_EQ_TOL (dlRxPackets, expectedDlRxPackets, m_toleranceRxPackets, "too different DL RX packets reported"); } Simulator::Destroy (); }