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"
231 uint32_t nBlocks = 10;
232 uint32_t nApartmentsX = 10;
233 uint32_t nFloors = 1;
234 uint32_t nMacroEnbSites = 3;
235 uint32_t nMacroEnbSitesX = 1;
236 double interSiteDistance = 500;
237 double areaMarginFactor = 0.5;
238 double macroUeDensity = 0.0001;
239 double homeEnbDeploymentRatio = 0.2;
240 double homeEnbActivationRatio = 0.5;
241 double homeUesHomeEnbRatio = 1;
242 double macroEnbTxPowerDbm = 46.0;
243 double homeEnbTxPowerDbm = 20.0;
244 uint16_t macroEnbDlEarfcn = 100;
245 uint16_t homeEnbDlEarfcn = 100;
246 uint16_t macroEnbBandwidth = 25;
247 uint16_t homeEnbBandwidth = 25;
248 double simTime = 0.25;
253 bool generateRem =
false;
254 std::string fadingFileTrace =
"";
257 cmd.
AddValue (
"nBlocks",
"Number of femtocell blocks", nBlocks);
258 cmd.
AddValue (
"nApartmentsX",
"Number of apartments along the X axis in a femtocell block", nApartmentsX);
259 cmd.
AddValue (
"nFloors",
"Number of floors", nFloors);
260 cmd.
AddValue (
"nMacroEnbSites",
"How many macro sites there are", nMacroEnbSites);
262 "(minimum) number of sites along the X-axis of the hex grid", nMacroEnbSitesX);
263 cmd.
AddValue (
"interSiteDistance",
"min distance between two nearby macro cell sites", interSiteDistance);
264 cmd.
AddValue (
"areaMarginFactor",
"how much the UE area extends outside the macrocell grid, "
265 "expressed as fraction of the interSiteDistance", areaMarginFactor);
266 cmd.
AddValue (
"macroUeDensity",
"How many macrocell UEs there are per square meter", macroUeDensity);
267 cmd.
AddValue (
"homeEnbDeploymentRatio",
268 "The HeNB deployment ratio as per 3GPP R4-092042", homeEnbDeploymentRatio);
269 cmd.
AddValue (
"homeEnbActivationRatio",
270 "The HeNB activation ratio as per 3GPP R4-092042", homeEnbActivationRatio);
271 cmd.
AddValue (
"homeUesHomeEnbRatio",
272 "How many (on average) home UEs per HeNB there are in the simulation",
273 homeUesHomeEnbRatio);
274 cmd.
AddValue (
"macroEnbTxPowerDbm",
"TX power [dBm] used by macro eNBs", macroEnbTxPowerDbm);
275 cmd.
AddValue (
"homeEnbTxPowerDbm",
"TX power [dBm] used by HeNBs", homeEnbTxPowerDbm);
276 cmd.
AddValue (
"macroEnbDlEarfcn",
"DL EARFCN used by macro eNBs", macroEnbDlEarfcn);
277 cmd.
AddValue (
"homeEnbDlEarfcn",
"DL EARFCN used by HeNBs", homeEnbDlEarfcn);
278 cmd.
AddValue (
"macroEnbBandwidth",
"bandwdith [num RBs] used by macro eNBs", macroEnbBandwidth);
279 cmd.
AddValue (
"homeEnbBandwidth",
"bandwdith [num RBs] used by HeNBs", homeEnbBandwidth);
280 cmd.
AddValue (
"simTime",
"Total duration of the simulation [s]", simTime);
281 cmd.
AddValue (
"generateRem",
"if true, will generate a REM and then abort the simulation;"
282 "if false, will run the simulation normally (without generating any REM)", generateRem);
283 cmd.
AddValue (
"epc",
"if true, will setup the EPC to simulate an end-to-end topology;"
284 "if false, only the LTE radio access will be simulated.", epc);
285 cmd.
AddValue (
"epcDl",
"if true, will activate data flows in the downlink when EPC is being used. "
286 "If false, downlink flows won't be activated. "
287 "If EPC is not used, this parameter will be ignored.", epcDl);
288 cmd.
AddValue (
"epcUl",
"if true, will activate data flows in the uplink when EPC is being used. "
289 "If false, uplink flows won't be activated. "
290 "If EPC is not used, this parameter will be ignored.", epcUl);
291 cmd.
AddValue (
"useUdp",
"if true, the UdpClient application will be used. "
292 "Otherwise, the BulkSend application will be used over a TCP connection. "
293 "If EPC is not used, this parameter will be ignored.", useUdp);
294 cmd.
AddValue (
"fadingTrace",
"The path of the fading trace (by default any fading trace is loadedm which implies that fading is not considered)", fadingFileTrace);
297 cmd.
Parse (argc, argv);
302 cmd.
Parse (argc, argv);
306 if (nMacroEnbSites > 0)
308 uint32_t currentSite = nMacroEnbSites -1;
309 uint32_t biRowIndex = (currentSite / (nMacroEnbSitesX + nMacroEnbSitesX + 1));
310 uint32_t biRowRemainder = currentSite % (nMacroEnbSitesX + nMacroEnbSitesX + 1);
311 uint32_t rowIndex = biRowIndex*2 + 1;
312 if (biRowRemainder >= nMacroEnbSitesX)
316 uint32_t nMacroEnbSitesY = rowIndex;
319 macroUeBox =
Box (-areaMarginFactor*interSiteDistance,
320 (nMacroEnbSitesX + areaMarginFactor)*interSiteDistance,
321 -areaMarginFactor*interSiteDistance,
322 (nMacroEnbSitesY -1)*interSiteDistance*sqrt(0.75) + areaMarginFactor*interSiteDistance,
328 macroUeBox =
Box (0, 150, 0, 150, 1.0, 2.0);
332 blockAllocator.
Create (nBlocks);
335 uint32_t nHomeEnbs = round (4 * nApartmentsX * nBlocks * nFloors * homeEnbDeploymentRatio * homeEnbActivationRatio);
337 uint32_t nHomeUes = round (nHomeEnbs * homeUesHomeEnbRatio);
339 double macroUeAreaSize = (macroUeBox.
xMax - macroUeBox.
xMin) * (macroUeBox.
yMax - macroUeBox.
yMin);
340 uint32_t nMacroUes = round (macroUeAreaSize * macroUeDensity) ;
341 NS_LOG_LOGIC (
"nMacroUes = " << nMacroUes <<
" (density=" << macroUeDensity <<
")");
344 homeEnbs.
Create (nHomeEnbs);
346 macroEnbs.
Create (3 * nMacroEnbSites);
348 homeUes.
Create (nHomeUes);
350 macroUes.
Create (nMacroUes);
365 if (!fadingFileTrace.empty ())
375 epcHelper = CreateObject<EpcHelper> ();
413 NS_LOG_LOGIC (
"randomly allocating macro UEs in " << macroUeBox);
414 positionAlloc = CreateObject<RandomBoxPositionAllocator> ();
434 positionAlloc = CreateObject<SameRoomPositionAllocator> (homeEnbs);
442 for (ueDevIt = homeUeDevs.
Begin ();
443 ueDevIt != homeUeDevs.
End ();
444 ++ueDevIt, ++enbDevIt)
448 if (enbDevIt == homeEnbDevs.
End ())
450 enbDevIt = homeEnbDevs.
Begin ();
452 lteHelper->
Attach (*ueDevIt, *enbDevIt);
458 NS_LOG_LOGIC (
"setting up internet, remote host and applications");
462 remoteHostContainer.
Create (1);
465 internet.
Install (remoteHostContainer);
475 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
489 ueDevs.
Add (homeUeDevs);
490 ueDevs.
Add (macroUeDevs);
498 uint16_t dlPort = 10000;
499 uint16_t ulPort = 20000;
503 for (uint32_t u = 0; u < ues.
GetN (); ++u)
517 clientApps.
Add (dlClientHelper.Install (remoteHost));
520 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
529 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
540 clientApps.
Add (dlClientHelper.
Install (remoteHost));
543 serverApps.
Add (dlPacketSinkHelper.
Install (ue));
554 serverApps.
Add (ulPacketSinkHelper.
Install (remoteHost));
573 BuildingsHelper::MakeMobilityModelConsistent ();
582 remHelper = CreateObject<RadioEnvironmentMapHelper> ();
597 Simulator::Stop (
Seconds (simTime));
613 Simulator::Destroy ();