21 #include <ns3/core-module.h>
22 #include <ns3/network-module.h>
23 #include <ns3/mobility-module.h>
24 #include <ns3/internet-module.h>
25 #include <ns3/lte-module.h>
26 #include <ns3/config-store-module.h>
27 #include <ns3/buildings-module.h>
28 #include <ns3/point-to-point-helper.h>
29 #include <ns3/applications-module.h>
60 bool OverlapsWithAnyPrevious (
Box);
74 m_nApartmentsX (nApartmentsX),
76 m_xSize (nApartmentsX*10 + 20),
79 m_xMinVar = CreateObject<UniformRandomVariable> ();
82 m_yMinVar = CreateObject<UniformRandomVariable> ();
90 for (uint32_t i = 0; i < n; ++i)
100 uint32_t attempt = 0;
103 NS_ASSERT_MSG (attempt < 100,
"Too many failed attemtps to position apartment block. Too many blocks? Too small area?");
112 NS_LOG_LOGIC (
"allocated non overlapping block " << box);
115 gridBuildingAllocator = CreateObject<GridBuildingAllocator> ();
127 gridBuildingAllocator->
Create (2);
146 std::ofstream outFile;
147 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
148 if (!outFile.is_open ())
157 Box box = (*it)->GetBoundaries ();
158 outFile <<
"set object " << index
159 <<
" rect from " << box.
xMin <<
"," << box.
yMin
160 <<
" to " << box.
xMax <<
"," << box.
yMax
161 <<
" front fs empty "
169 std::ofstream outFile;
170 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
171 if (!outFile.is_open ())
180 for (
int j = 0; j < nDevs; j++)
186 outFile <<
"set label \"" << uedev->
GetImsi ()
187 <<
"\" at "<< pos.
x <<
"," << pos.
y <<
" left font \"Helvetica,4\" textcolor rgb \"grey\" front point pt 1 ps 0.3 lc rgb \"grey\" offset 0,0"
197 std::ofstream outFile;
198 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
199 if (!outFile.is_open ())
208 for (
int j = 0; j < nDevs; j++)
214 outFile <<
"set label \"" << enbdev->
GetCellId ()
215 <<
"\" at "<< pos.
x <<
"," << pos.
y <<
" left font \"Helvetica,4\" textcolor rgb \"white\" front point pt 2 ps 0.3 lc rgb \"white\" offset 0,0"
224 "Number of femtocell blocks",
226 ns3::MakeUintegerChecker<uint32_t> ());
228 "Number of apartments along the X axis in a femtocell block",
230 ns3::MakeUintegerChecker<uint32_t> ());
234 ns3::MakeUintegerChecker<uint32_t> ());
236 "How many macro sites there are",
238 ns3::MakeUintegerChecker<uint32_t> ());
240 "(minimum) number of sites along the X-axis of the hex grid",
242 ns3::MakeUintegerChecker<uint32_t> ());
244 "min distance between two nearby macro cell sites",
246 ns3::MakeDoubleChecker<double> ());
248 "how much the UE area extends outside the macrocell grid, "
249 "expressed as fraction of the interSiteDistance",
251 ns3::MakeDoubleChecker<double> ());
253 "How many macrocell UEs there are per square meter",
255 ns3::MakeDoubleChecker<double> ());
257 "The HeNB deployment ratio as per 3GPP R4-092042",
259 ns3::MakeDoubleChecker<double> ());
261 "The HeNB activation ratio as per 3GPP R4-092042",
263 ns3::MakeDoubleChecker<double> ());
265 "How many (on average) home UEs per HeNB there are in the simulation",
267 ns3::MakeDoubleChecker<double> ());
269 "TX power [dBm] used by macro eNBs",
271 ns3::MakeDoubleChecker<double> ());
273 "TX power [dBm] used by HeNBs",
275 ns3::MakeDoubleChecker<double> ());
277 "DL EARFCN used by macro eNBs",
279 ns3::MakeUintegerChecker<uint16_t> ());
281 "DL EARFCN used by HeNBs",
283 ns3::MakeUintegerChecker<uint16_t> ());
285 "bandwidth [num RBs] used by macro eNBs",
287 ns3::MakeUintegerChecker<uint16_t> ());
289 "bandwidth [num RBs] used by HeNBs",
291 ns3::MakeUintegerChecker<uint16_t> ());
293 "Total duration of the simulation [s]",
295 ns3::MakeDoubleChecker<double> ());
297 "if true, will generate a REM and then abort the simulation;"
298 "if false, will run the simulation normally (without generating any REM)",
300 ns3::MakeBooleanChecker ());
302 "If true, will setup the EPC to simulate an end-to-end topology, "
303 "with real IP applications over PDCP and RLC UM (or RLC AM by changing "
304 "the default value of EpsBearerToRlcMapping e.g. to RLC_AM_ALWAYS). "
305 "If false, only the LTE radio access will be simulated with RLC SM. ",
307 ns3::MakeBooleanChecker ());
309 "if true, will activate data flows in the downlink when EPC is being used. "
310 "If false, downlink flows won't be activated. "
311 "If EPC is not used, this parameter will be ignored.",
313 ns3::MakeBooleanChecker ());
315 "if true, will activate data flows in the uplink when EPC is being used. "
316 "If false, uplink flows won't be activated. "
317 "If EPC is not used, this parameter will be ignored.",
319 ns3::MakeBooleanChecker ());
321 "if true, the UdpClient application will be used. "
322 "Otherwise, the BulkSend application will be used over a TCP connection. "
323 "If EPC is not used, this parameter will be ignored.",
325 ns3::MakeBooleanChecker ());
327 "The path of the fading trace (by default no fading trace "
328 "is loaded, i.e., fading is not considered)",
330 ns3::MakeStringChecker ());
332 "How many bearers per UE there are in the simulation",
334 ns3::MakeUintegerChecker<uint16_t> ());
337 "SRS Periodicity (has to be at least greater than the number of UEs per eNB)",
339 ns3::MakeUintegerChecker<uint16_t> ());
342 "Minimum speed value of macor UE with random waypoint model [m/s].",
344 ns3::MakeDoubleChecker<double> ());
347 "Maximum speed value of macor UE with random waypoint model [m/s].",
349 ns3::MakeDoubleChecker<double> ());
362 cmd.
Parse (argc, argv);
366 cmd.
Parse (argc, argv);
373 GlobalValue::GetValueByName (
"nBlocks", uintegerValue);
374 uint32_t nBlocks = uintegerValue.
Get ();
375 GlobalValue::GetValueByName (
"nApartmentsX", uintegerValue);
376 uint32_t nApartmentsX = uintegerValue.
Get ();
377 GlobalValue::GetValueByName (
"nFloors", uintegerValue);
378 uint32_t nFloors = uintegerValue.
Get ();
379 GlobalValue::GetValueByName (
"nMacroEnbSites", uintegerValue);
380 uint32_t nMacroEnbSites = uintegerValue.
Get ();
381 GlobalValue::GetValueByName (
"nMacroEnbSitesX", uintegerValue);
382 uint32_t nMacroEnbSitesX = uintegerValue.
Get ();
383 GlobalValue::GetValueByName (
"interSiteDistance", doubleValue);
384 double interSiteDistance = doubleValue.
Get ();
385 GlobalValue::GetValueByName (
"areaMarginFactor", doubleValue);
386 double areaMarginFactor = doubleValue.
Get ();
387 GlobalValue::GetValueByName (
"macroUeDensity", doubleValue);
388 double macroUeDensity = doubleValue.
Get ();
389 GlobalValue::GetValueByName (
"homeEnbDeploymentRatio", doubleValue);
390 double homeEnbDeploymentRatio = doubleValue.
Get ();
391 GlobalValue::GetValueByName (
"homeEnbActivationRatio", doubleValue);
392 double homeEnbActivationRatio = doubleValue.
Get ();
393 GlobalValue::GetValueByName (
"homeUesHomeEnbRatio", doubleValue);
394 double homeUesHomeEnbRatio = doubleValue.
Get ();
395 GlobalValue::GetValueByName (
"macroEnbTxPowerDbm", doubleValue);
396 double macroEnbTxPowerDbm = doubleValue.
Get ();
397 GlobalValue::GetValueByName (
"homeEnbTxPowerDbm", doubleValue);
398 double homeEnbTxPowerDbm = doubleValue.
Get ();
399 GlobalValue::GetValueByName (
"macroEnbDlEarfcn", uintegerValue);
400 uint16_t macroEnbDlEarfcn = uintegerValue.
Get ();
401 GlobalValue::GetValueByName (
"homeEnbDlEarfcn", uintegerValue);
402 uint16_t homeEnbDlEarfcn = uintegerValue.
Get ();
403 GlobalValue::GetValueByName (
"macroEnbBandwidth", uintegerValue);
404 uint16_t macroEnbBandwidth = uintegerValue.
Get ();
405 GlobalValue::GetValueByName (
"homeEnbBandwidth", uintegerValue);
406 uint16_t homeEnbBandwidth = uintegerValue.
Get ();
407 GlobalValue::GetValueByName (
"simTime", doubleValue);
408 double simTime = doubleValue.
Get ();
409 GlobalValue::GetValueByName (
"epc", booleanValue);
410 bool epc = booleanValue.
Get ();
411 GlobalValue::GetValueByName (
"epcDl", booleanValue);
412 bool epcDl = booleanValue.
Get ();
413 GlobalValue::GetValueByName (
"epcUl", booleanValue);
414 bool epcUl = booleanValue.
Get ();
415 GlobalValue::GetValueByName (
"useUdp", booleanValue);
416 bool useUdp = booleanValue.
Get ();
417 GlobalValue::GetValueByName (
"generateRem", booleanValue);
418 bool generateRem = booleanValue.
Get ();
419 GlobalValue::GetValueByName (
"fadingTrace", stringValue);
420 std::string fadingTrace = stringValue.
Get ();
421 GlobalValue::GetValueByName (
"numBearersPerUe", uintegerValue);
422 uint16_t numBearersPerUe = uintegerValue.
Get ();
423 GlobalValue::GetValueByName (
"srsPeriodicity", uintegerValue);
424 uint16_t srsPeriodicity = uintegerValue.
Get ();
425 GlobalValue::GetValueByName (
"outdoorUeMinSpeed", doubleValue);
426 uint16_t outdoorUeMinSpeed = doubleValue.
Get ();
427 GlobalValue::GetValueByName (
"outdoorUeMaxSpeed", doubleValue);
428 uint16_t outdoorUeMaxSpeed = doubleValue.
Get ();
434 if (nMacroEnbSites > 0)
436 uint32_t currentSite = nMacroEnbSites -1;
437 uint32_t biRowIndex = (currentSite / (nMacroEnbSitesX + nMacroEnbSitesX + 1));
438 uint32_t biRowRemainder = currentSite % (nMacroEnbSitesX + nMacroEnbSitesX + 1);
439 uint32_t rowIndex = biRowIndex*2 + 1;
440 if (biRowRemainder >= nMacroEnbSitesX)
444 uint32_t nMacroEnbSitesY = rowIndex;
447 macroUeBox =
Box (-areaMarginFactor*interSiteDistance,
448 (nMacroEnbSitesX + areaMarginFactor)*interSiteDistance,
449 -areaMarginFactor*interSiteDistance,
450 (nMacroEnbSitesY -1)*interSiteDistance*sqrt(0.75) + areaMarginFactor*interSiteDistance,
456 macroUeBox =
Box (0, 150, 0, 150, ueZ, ueZ);
460 blockAllocator.
Create (nBlocks);
463 uint32_t nHomeEnbs = round (4 * nApartmentsX * nBlocks * nFloors * homeEnbDeploymentRatio * homeEnbActivationRatio);
465 uint32_t nHomeUes = round (nHomeEnbs * homeUesHomeEnbRatio);
467 double macroUeAreaSize = (macroUeBox.
xMax - macroUeBox.
xMin) * (macroUeBox.
yMax - macroUeBox.
yMin);
468 uint32_t nMacroUes = round (macroUeAreaSize * macroUeDensity) ;
469 NS_LOG_LOGIC (
"nMacroUes = " << nMacroUes <<
" (density=" << macroUeDensity <<
")");
472 homeEnbs.
Create (nHomeEnbs);
474 macroEnbs.
Create (3 * nMacroEnbSites);
476 homeUes.
Create (nHomeUes);
478 macroUes.
Create (nMacroUes);
496 if (!fadingTrace.empty ())
506 epcHelper = CreateObject<EpcHelper> ();
513 BuildingsHelper::Install (macroEnbs);
540 BuildingsHelper::Install (homeEnbs);
551 positionAlloc = CreateObject<SameRoomPositionAllocator> (homeEnbs);
554 BuildingsHelper::Install (homeUes);
558 NS_LOG_LOGIC (
"randomly allocating macro UEs in " << macroUeBox <<
" speedMin " << outdoorUeMinSpeed <<
" speedMax " << outdoorUeMaxSpeed);
559 if (outdoorUeMaxSpeed!=0.0)
575 positionAlloc = CreateObject<RandomBoxPositionAllocator> ();
583 it != macroUes.
End ();
586 (*it)->Initialize ();
591 positionAlloc = CreateObject<RandomBoxPositionAllocator> ();
607 BuildingsHelper::Install (macroUes);
623 remoteHostContainer.
Create (1);
624 remoteHost = remoteHostContainer.
Get (0);
626 internet.
Install (remoteHostContainer);
636 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
639 remoteHostAddr = internetIpIfaces.
GetAddress (1);
648 ueDevs.
Add (homeUeDevs);
649 ueDevs.
Add (macroUeDevs);
663 for (ueDevIt = homeUeDevs.
Begin ();
664 ueDevIt != homeUeDevs.
End ();
665 ++ueDevIt, ++enbDevIt)
669 if (enbDevIt == homeEnbDevs.
End ())
671 enbDevIt = homeEnbDevs.
Begin ();
673 lteHelper->
Attach (*ueDevIt, *enbDevIt);
682 uint16_t dlPort = 10000;
683 uint16_t ulPort = 20000;
702 for (uint32_t u = 0; u < ues.
GetN (); ++u)
709 for (uint32_t b = 0; b < numBearersPerUe; ++b)
723 clientApps.
Add (dlClientHelper.Install (remoteHost));
726 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
735 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
746 clientApps.
Add (dlClientHelper.
Install (remoteHost));
749 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
760 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
782 EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
786 serverApps.
Start (startTime);
787 clientApps.
Start (startTime);
797 ueDevs.
Add (homeUeDevs);
798 ueDevs.
Add (macroUeDevs);
799 for (uint32_t u = 0; u < ueDevs.
GetN (); ++u)
802 for (uint32_t b = 0; b < numBearersPerUe; ++b)
811 BuildingsHelper::MakeMobilityModelConsistent ();
820 remHelper = CreateObject<RadioEnvironmentMapHelper> ();
833 Simulator::Stop (
Seconds (simTime));
849 Simulator::Destroy ();