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>
59 bool OverlapsWithAnyPrevious (
Box);
73 m_nApartmentsX (nApartmentsX),
75 m_xSize (nApartmentsX*10 + 20),
78 m_xMinVar = CreateObject<UniformRandomVariable> ();
81 m_yMinVar = CreateObject<UniformRandomVariable> ();
89 for (uint32_t i = 0; i < n; ++i)
102 NS_ASSERT_MSG (attempt < 100,
"Too many failed attemtps to position apartment block. Too many blocks? Too small area?");
111 NS_LOG_LOGIC (
"allocated non overlapping block " << box);
114 gridBuildingAllocator = CreateObject<GridBuildingAllocator> ();
126 gridBuildingAllocator->
Create (2);
145 std::ofstream outFile;
146 outFile.open (filename.c_str ());
147 if (!outFile.is_open ())
156 Box box = (*it)->GetBoundaries ();
157 outFile <<
"set object " << index
158 <<
" rect from " << box.
xMin <<
"," << box.
yMin
159 <<
" to " << box.
xMax <<
"," << box.
yMax
160 <<
" front fs empty "
168 std::ofstream outFile;
169 outFile.open (filename.c_str ());
170 if (!outFile.is_open ())
179 for (
int j = 0; j < nDevs; j++)
185 outFile <<
"set label \"" << uedev->
GetImsi ()
186 <<
"\" 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"
196 std::ofstream outFile;
197 outFile.open (filename.c_str ());
198 if (!outFile.is_open ())
207 for (
int j = 0; j < nDevs; j++)
213 outFile <<
"set label \"" << enbdev->
GetCellId ()
214 <<
"\" 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"
223 "Number of femtocell blocks",
225 ns3::MakeUintegerChecker<uint32_t> ());
227 "Number of apartments along the X axis in a femtocell block",
229 ns3::MakeUintegerChecker<uint32_t> ());
233 ns3::MakeUintegerChecker<uint32_t> ());
235 "How many macro sites there are",
237 ns3::MakeUintegerChecker<uint32_t> ());
239 "(minimum) number of sites along the X-axis of the hex grid",
241 ns3::MakeUintegerChecker<uint32_t> ());
243 "min distance between two nearby macro cell sites",
245 ns3::MakeDoubleChecker<double> ());
247 "how much the UE area extends outside the macrocell grid, "
248 "expressed as fraction of the interSiteDistance",
250 ns3::MakeDoubleChecker<double> ());
252 "How many macrocell UEs there are per square meter",
254 ns3::MakeDoubleChecker<double> ());
256 "The HeNB deployment ratio as per 3GPP R4-092042",
258 ns3::MakeDoubleChecker<double> ());
260 "The HeNB activation ratio as per 3GPP R4-092042",
262 ns3::MakeDoubleChecker<double> ());
264 "How many (on average) home UEs per HeNB there are in the simulation",
266 ns3::MakeDoubleChecker<double> ());
268 "TX power [dBm] used by macro eNBs",
270 ns3::MakeDoubleChecker<double> ());
272 "TX power [dBm] used by HeNBs",
274 ns3::MakeDoubleChecker<double> ());
276 "DL EARFCN used by macro eNBs",
278 ns3::MakeUintegerChecker<uint16_t> ());
280 "DL EARFCN used by HeNBs",
282 ns3::MakeUintegerChecker<uint16_t> ());
284 "bandwidth [num RBs] used by macro eNBs",
286 ns3::MakeUintegerChecker<uint16_t> ());
288 "bandwidth [num RBs] used by HeNBs",
290 ns3::MakeUintegerChecker<uint16_t> ());
292 "Total duration of the simulation [s]",
294 ns3::MakeDoubleChecker<double> ());
296 "if true, will generate a REM and then abort the simulation;"
297 "if false, will run the simulation normally (without generating any REM)",
299 ns3::MakeBooleanChecker ());
301 "if true, will setup the EPC to simulate an end-to-end topology;"
302 "if false, only the LTE radio access will be simulated.",
304 ns3::MakeBooleanChecker ());
306 "if true, will activate data flows in the downlink when EPC is being used. "
307 "If false, downlink flows won't be activated. "
308 "If EPC is not used, this parameter will be ignored.",
310 ns3::MakeBooleanChecker ());
312 "if true, will activate data flows in the uplink when EPC is being used. "
313 "If false, uplink flows won't be activated. "
314 "If EPC is not used, this parameter will be ignored.",
316 ns3::MakeBooleanChecker ());
318 "if true, the UdpClient application will be used. "
319 "Otherwise, the BulkSend application will be used over a TCP connection. "
320 "If EPC is not used, this parameter will be ignored.",
322 ns3::MakeBooleanChecker ());
324 "The path of the fading trace (by default no fading trace "
325 "is loaded, i.e., fading is not considered)",
327 ns3::MakeStringChecker ());
340 cmd.
Parse (argc, argv);
344 cmd.
Parse (argc, argv);
351 GlobalValue::GetValueByName (
"nBlocks", uintegerValue);
352 uint32_t nBlocks = uintegerValue.
Get ();
353 GlobalValue::GetValueByName (
"nApartmentsX", uintegerValue);
354 uint32_t nApartmentsX = uintegerValue.
Get ();
355 GlobalValue::GetValueByName (
"nFloors", uintegerValue);
356 uint32_t nFloors = uintegerValue.
Get ();
357 GlobalValue::GetValueByName (
"nMacroEnbSites", uintegerValue);
358 uint32_t nMacroEnbSites = uintegerValue.
Get ();
359 GlobalValue::GetValueByName (
"nMacroEnbSitesX", uintegerValue);
360 uint32_t nMacroEnbSitesX = uintegerValue.
Get ();
361 GlobalValue::GetValueByName (
"interSiteDistance", doubleValue);
362 double interSiteDistance = doubleValue.
Get ();
363 GlobalValue::GetValueByName (
"areaMarginFactor", doubleValue);
364 double areaMarginFactor = doubleValue.
Get ();
365 GlobalValue::GetValueByName (
"macroUeDensity", doubleValue);
366 double macroUeDensity = doubleValue.
Get ();
367 GlobalValue::GetValueByName (
"homeEnbDeploymentRatio", doubleValue);
368 double homeEnbDeploymentRatio = doubleValue.
Get ();
369 GlobalValue::GetValueByName (
"homeEnbActivationRatio", doubleValue);
370 double homeEnbActivationRatio = doubleValue.
Get ();
371 GlobalValue::GetValueByName (
"homeUesHomeEnbRatio", doubleValue);
372 double homeUesHomeEnbRatio = doubleValue.
Get ();
373 GlobalValue::GetValueByName (
"macroEnbTxPowerDbm", doubleValue);
374 double macroEnbTxPowerDbm = doubleValue.
Get ();
375 GlobalValue::GetValueByName (
"homeEnbTxPowerDbm", doubleValue);
376 double homeEnbTxPowerDbm = doubleValue.
Get ();
377 GlobalValue::GetValueByName (
"macroEnbDlEarfcn", uintegerValue);
378 uint16_t macroEnbDlEarfcn = uintegerValue.
Get ();
379 GlobalValue::GetValueByName (
"homeEnbDlEarfcn", uintegerValue);
380 uint16_t homeEnbDlEarfcn = uintegerValue.
Get ();
381 GlobalValue::GetValueByName (
"macroEnbBandwidth", uintegerValue);
382 uint16_t macroEnbBandwidth = uintegerValue.
Get ();
383 GlobalValue::GetValueByName (
"homeEnbBandwidth", uintegerValue);
384 uint16_t homeEnbBandwidth = uintegerValue.
Get ();
385 GlobalValue::GetValueByName (
"simTime", doubleValue);
386 double simTime = doubleValue.
Get ();
387 GlobalValue::GetValueByName (
"epc", booleanValue);
388 bool epc = booleanValue.
Get ();
389 GlobalValue::GetValueByName (
"epcDl", booleanValue);
390 bool epcDl = booleanValue.
Get ();
391 GlobalValue::GetValueByName (
"epcUl", booleanValue);
392 bool epcUl = booleanValue.
Get ();
393 GlobalValue::GetValueByName (
"useUdp", booleanValue);
394 bool useUdp = booleanValue.
Get ();
395 GlobalValue::GetValueByName (
"generateRem", booleanValue);
396 bool generateRem = booleanValue.
Get ();
397 GlobalValue::GetValueByName (
"fadingTrace", stringValue);
398 std::string fadingTrace = stringValue.
Get ();
402 if (nMacroEnbSites > 0)
404 uint32_t currentSite = nMacroEnbSites -1;
405 uint32_t biRowIndex = (currentSite / (nMacroEnbSitesX + nMacroEnbSitesX + 1));
406 uint32_t biRowRemainder = currentSite % (nMacroEnbSitesX + nMacroEnbSitesX + 1);
407 uint32_t rowIndex = biRowIndex*2 + 1;
408 if (biRowRemainder >= nMacroEnbSitesX)
412 uint32_t nMacroEnbSitesY = rowIndex;
415 macroUeBox =
Box (-areaMarginFactor*interSiteDistance,
416 (nMacroEnbSitesX + areaMarginFactor)*interSiteDistance,
417 -areaMarginFactor*interSiteDistance,
418 (nMacroEnbSitesY -1)*interSiteDistance*sqrt(0.75) + areaMarginFactor*interSiteDistance,
424 macroUeBox =
Box (0, 150, 0, 150, 1.0, 2.0);
428 blockAllocator.
Create (nBlocks);
431 uint32_t nHomeEnbs = round (4 * nApartmentsX * nBlocks * nFloors * homeEnbDeploymentRatio * homeEnbActivationRatio);
433 uint32_t nHomeUes = round (nHomeEnbs * homeUesHomeEnbRatio);
435 double macroUeAreaSize = (macroUeBox.
xMax - macroUeBox.
xMin) * (macroUeBox.
yMax - macroUeBox.
yMin);
436 uint32_t nMacroUes = round (macroUeAreaSize * macroUeDensity) ;
437 NS_LOG_LOGIC (
"nMacroUes = " << nMacroUes <<
" (density=" << macroUeDensity <<
")");
440 homeEnbs.
Create (nHomeEnbs);
442 macroEnbs.
Create (3 * nMacroEnbSites);
444 homeUes.
Create (nHomeUes);
446 macroUes.
Create (nMacroUes);
461 if (!fadingTrace.empty ())
471 epcHelper = CreateObject<EpcHelper> ();
509 NS_LOG_LOGIC (
"randomly allocating macro UEs in " << macroUeBox);
510 positionAlloc = CreateObject<RandomBoxPositionAllocator> ();
530 positionAlloc = CreateObject<SameRoomPositionAllocator> (homeEnbs);
538 for (ueDevIt = homeUeDevs.
Begin ();
539 ueDevIt != homeUeDevs.
End ();
540 ++ueDevIt, ++enbDevIt)
544 if (enbDevIt == homeEnbDevs.
End ())
546 enbDevIt = homeEnbDevs.
Begin ();
548 lteHelper->
Attach (*ueDevIt, *enbDevIt);
554 NS_LOG_LOGIC (
"setting up internet, remote host and applications");
558 remoteHostContainer.
Create (1);
561 internet.
Install (remoteHostContainer);
571 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
585 ueDevs.
Add (homeUeDevs);
586 ueDevs.
Add (macroUeDevs);
594 uint16_t dlPort = 10000;
595 uint16_t ulPort = 20000;
599 for (uint32_t u = 0; u < ues.
GetN (); ++u)
613 clientApps.
Add (dlClientHelper.Install (remoteHost));
616 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
625 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
636 clientApps.
Add (dlClientHelper.
Install (remoteHost));
639 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
650 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
669 BuildingsHelper::MakeMobilityModelConsistent ();
678 remHelper = CreateObject<RadioEnvironmentMapHelper> ();
693 Simulator::Stop (
Seconds (simTime));
709 Simulator::Destroy ();