6#include "cttc-nr-3gpp-calibration.h"
8#include "cttc-nr-3gpp-calibration-utils-v1.h"
9#include "cttc-nr-3gpp-calibration-utils-v2.h"
10#include "flow-monitor-output-stats.h"
11#include "power-output-stats.h"
12#include "rb-output-stats.h"
13#include "sinr-output-stats.h"
14#include "slot-output-stats.h"
16#include "ns3/antenna-module.h"
17#include "ns3/applications-module.h"
18#include "ns3/config-store-module.h"
19#include "ns3/config-store.h"
20#include "ns3/core-module.h"
21#include "ns3/flow-monitor-module.h"
22#include "ns3/internet-apps-module.h"
23#include "ns3/internet-module.h"
24#include "ns3/lte-module.h"
25#include "ns3/mobility-module.h"
26#include "ns3/network-module.h"
27#include "ns3/point-to-point-module.h"
28#include "ns3/radio-environment-map-helper.h"
29#include "ns3/sqlite-output.h"
44NS_LOG_COMPONENT_DEFINE(
"Nr3gppCalibration");
49const Time appStartWindow = MilliSeconds(50);
53CreateLowLatTft(uint16_t start, uint16_t end, std::string dir)
56 lowLatTft = Create<T>();
57 typename T::PacketFilter dlpfLowLat;
60 dlpfLowLat.localPortStart = start;
61 dlpfLowLat.localPortEnd = end;
62 dlpfLowLat.direction = T::DOWNLINK;
66 dlpfLowLat.remotePortStart = start;
67 dlpfLowLat.remotePortEnd = end;
68 dlpfLowLat.direction = T::UPLINK;
70 lowLatTft->Add(dlpfLowLat);
74template Ptr<ns3::EpcTft> CreateLowLatTft<ns3::EpcTft>(uint16_t, uint16_t, std::string);
75template Ptr<ns3::NrEpcTft> CreateLowLatTft<ns3::NrEpcTft>(uint16_t, uint16_t, std::string);
77static std::pair<ApplicationContainer, Time>
78InstallApps(
const Ptr<Node>& ue,
79 const Ptr<NetDevice>& ueDevice,
80 const Address& ueAddress,
81 const std::string& direction,
82 UdpClientHelper* dlClientLowLat,
83 const Ptr<Node>& remoteHost,
84 const Ipv4Address& remoteHostAddr,
86 uint16_t dlPortLowLat,
87 const Ptr<UniformRandomVariable>& x,
88 Time appGenerationTime,
89 const Ptr<LteHelper>& lteHelper,
90 const Ptr<NrHelper>& nrHelper)
92 ApplicationContainer app;
95 EpsBearer lowLatBearer(EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
99 Ptr<EpcTft> lowLatTft = CreateLowLatTft<EpcTft>(dlPortLowLat, dlPortLowLat, direction);
100 Ptr<NrEpcTft> nrLowLatTft = CreateLowLatTft<NrEpcTft>(dlPortLowLat, dlPortLowLat, direction);
104 if (direction ==
"DL")
106 dlClientLowLat->SetAttribute(
108 AddressValue(addressUtils::ConvertToSocketAddress(ueAddress, dlPortLowLat)));
109 app = dlClientLowLat->Install(remoteHost);
113 dlClientLowLat->SetAttribute(
115 AddressValue(addressUtils::ConvertToSocketAddress(remoteHostAddr, dlPortLowLat)));
116 app = dlClientLowLat->Install(ue);
124 Time startTime = udpAppStartTime;
125 app.Start(startTime);
126 app.Stop(startTime + appGenerationTime);
128 std::cout <<
"\tStarts at time " << startTime.As(Time::MS) <<
" and ends at "
129 << (startTime + appGenerationTime).As(Time::MS) << std::endl;
132 if (lteHelper !=
nullptr)
134 lteHelper->ActivateDedicatedEpsBearer(ueDevice, lowLatBearer, lowLatTft);
136 else if (nrHelper !=
nullptr)
138 nrHelper->ActivateDedicatedEpsBearer(ueDevice, nrLowLatBearer, nrLowLatTft);
141 return std::make_pair(app, startTime);
145PrintUePosition(NetDeviceContainer ueNetDevs, NodeContainer ueNodes)
147 for (uint32_t ueId = 0; ueId < ueNodes.GetN(); ++ueId)
149 Ptr<NetDevice> ueNetDev = ueNetDevs.Get(ueId);
150 Vector uepos = ueNetDev->GetNode()->GetObject<MobilityModel>()->GetPosition();
152 std::cout <<
"ueId: " << ueId <<
", at " << uepos << std::endl;
155 Simulator::Schedule(MilliSeconds(100), &PrintUePosition, ueNetDevs, ueNodes);
159Parameters::Validate()
const
161 NS_ABORT_MSG_IF(bandwidthMHz != 40 && bandwidthMHz != 20 && bandwidthMHz != 10 &&
163 "Valid bandwidth values are 40, 20, 10, 5, you set " << bandwidthMHz);
165 NS_ABORT_MSG_IF(trafficScenario > 4 && trafficScenario != UINT32_MAX,
166 "Traffic scenario " << trafficScenario
167 <<
" not valid. Valid values are 0 1 2 3 4");
169 NS_ABORT_MSG_IF(numerologyBwp > 4,
"At most 4 bandwidth parts supported.");
171 NS_ABORT_MSG_IF(direction !=
"DL" && direction !=
"UL",
172 "Flow direction can only be DL or UL: " << direction);
173 NS_ABORT_MSG_IF(operationMode !=
"TDD" && operationMode !=
"FDD",
174 "Operation mode can only be TDD or FDD: " << operationMode);
177 NS_ABORT_MSG_IF(simulator !=
"LENA" && simulator !=
"5GLENA",
178 "Unrecognized simulator: " << simulator);
179 NS_ABORT_MSG_IF(scheduler !=
"PF" && scheduler !=
"RR",
180 "Unrecognized scheduler: " << scheduler);
181 NS_ABORT_MSG_IF(radioNetwork ==
"NR" && enableFading ==
false && enableRealBF ==
true,
182 "Realistic BF should not be enabled in when fading is disabled");
185 NS_ABORT_MSG_IF(bfMethod !=
"Omni" && bfMethod !=
"CellScan" && bfMethod !=
"FixedBeam",
186 "For bfMethod you can choose among Omni, CellScan, and FixedBeam");
187 NS_ABORT_MSG_IF(confType !=
"customConf" && confType !=
"calibrationConf",
188 "Unrecognized Configuration type: " << confType);
190 if (confType ==
"calibrationConf")
192 if (radioNetwork ==
"LTE")
194 NS_FATAL_ERROR(
"LTE not supported currently");
196 else if (radioNetwork ==
"NR")
199 (nrConfigurationScenario !=
"DenseA" && nrConfigurationScenario !=
"DenseB" &&
200 nrConfigurationScenario !=
"RuralA" && nrConfigurationScenario !=
"RuralB"),
201 "NR needs one of the NR pre-defined scenarios to be specified");
205 NS_FATAL_ERROR(
"Unrecognized radio network technology: " << radioNetwork);
210 attachToClosest ==
true && freqScenario == 0,
211 "attachToClosest option should be activated only in overlapping frequency scenario");
215 NS_ABORT_MSG_IF(simulator !=
"5GLENA",
216 "Cannot do the REM with the simulator " << simulator);
217 NS_ABORT_MSG_IF(dlRem && ulRem,
"You selected both DL and UL REM, that is not supported");
218 NS_ABORT_MSG_IF(remSector > 3,
"Only three sectors supported for REM");
220 NS_ABORT_MSG_IF(remSector == 0 && freqScenario != 1,
221 "RemSector == 0 makes sense only in a OVERLAPPING scenario");
228ChooseCalibrationScenario(Parameters& params)
230 if (params.confType ==
"calibrationConf")
232 params.utHeight = 1.5;
234 if (params.radioNetwork ==
"NR")
236 params.freqScenario = 1;
237 if (params.trafficScenario == UINT32_MAX)
239 params.trafficScenario = 0;
241 params.ueTxPower = 23;
242 params.speed = 0.8333;
244 params.ueNumRows = 1;
245 params.ueNumColumns = 1;
246 params.gnbEnable3gppElement =
true;
248 params.linkO2iConditionToAntennaHeight =
false;
250 params.scheduler =
"RR";
252 if (params.nrConfigurationScenario ==
"DenseA")
254 params.scenario =
"UMa";
255 params.startingFreq = 4e9;
256 params.bandwidthMHz = 10;
257 params.gnbTxPower = 41;
258 params.bsHeight = 25;
259 params.uesWithRandomUtHeight = 0.8;
261 params.o2iThreshold = 0.8;
262 params.o2iLowLossThreshold = 0.8;
263 params.linkO2iConditionToAntennaHeight =
true;
265 params.gnbNumRows = 4;
266 params.gnbNumColumns = 8;
268 params.gnbHSpacing = 0.5;
269 params.gnbVSpacing = 0.8;
271 params.ueEnable3gppElement =
false;
272 params.downtiltAngle = 0;
273 params.gnbNoiseFigure = 5;
274 params.ueNoiseFigure = 7;
276 else if (params.nrConfigurationScenario ==
"DenseB")
278 params.scenario =
"UMa";
279 params.startingFreq = 30e9;
280 params.bandwidthMHz = 40;
281 params.gnbTxPower = 37;
282 params.uesWithRandomUtHeight = 0.8;
283 params.bsHeight = 25;
285 params.o2iThreshold = 0.8;
286 params.o2iLowLossThreshold = 0.8;
287 params.linkO2iConditionToAntennaHeight =
true;
289 params.gnbNumRows = 4;
290 params.gnbNumColumns = 8;
291 params.ueNumRows = 2;
292 params.ueNumColumns = 4;
294 params.gnbHSpacing = 0.5;
295 params.gnbVSpacing = 0.5;
297 params.ueEnable3gppElement =
true;
298 params.downtiltAngle = 0;
299 params.gnbNoiseFigure = 7;
300 params.ueNoiseFigure = 10;
302 else if (params.nrConfigurationScenario ==
"RuralA")
304 params.scenario =
"RMa";
305 params.startingFreq = 700e6;
306 params.bandwidthMHz = 10;
307 params.gnbTxPower = 46;
308 params.bsHeight = 35;
310 params.o2iThreshold = 0.5;
312 params.gnbNumRows = 8;
313 params.gnbNumColumns = 1;
315 params.gnbHSpacing = 0.5;
316 params.gnbVSpacing = 0.8;
318 params.ueEnable3gppElement =
false;
319 params.downtiltAngle = 0;
320 params.gnbNoiseFigure = 5;
321 params.ueNoiseFigure = 7;
323 else if (params.nrConfigurationScenario ==
"RuralB")
325 params.scenario =
"RMa";
326 params.startingFreq = 4e9;
327 params.bandwidthMHz = 10;
328 params.gnbTxPower = 46;
329 params.bsHeight = 35;
331 params.o2iThreshold = 0.5;
333 params.gnbNumRows = 8;
334 params.gnbNumColumns = 1;
336 params.gnbHSpacing = 0.5;
337 params.gnbVSpacing = 0.8;
339 params.ueEnable3gppElement =
false;
340 params.downtiltAngle = 0;
341 params.gnbNoiseFigure = 5;
342 params.ueNoiseFigure = 7;
349Nr3gppCalibration(Parameters& params)
354 uint32_t udpPacketSize = 1000;
356 uint32_t packetCount;
358 std::cout <<
"\n----------------------------------------\n"
359 <<
"Configuring scenario" << std::endl;
361 std::cout <<
" traffic parameters\n";
362 switch (params.trafficScenario)
365 packetCount = 0xFFFFFFFF;
366 switch (params.bandwidthMHz)
369 udpPacketSize = 2000;
372 udpPacketSize = 1000;
381 udpPacketSize = 1000;
383 lambda = 10000 / params.ueNumPergNb;
391 packetCount = 0xFFFFFFFF;
392 switch (params.bandwidthMHz)
409 lambda = 1000 / params.ueNumPergNb;
412 packetCount = 0xFFFFFFFF;
413 switch (params.bandwidthMHz)
430 lambda = 10000 / params.ueNumPergNb;
433 packetCount = 0xFFFFFFFF;
434 switch (params.bandwidthMHz)
437 udpPacketSize = 3000;
440 udpPacketSize = 1500;
449 udpPacketSize = 1500;
451 lambda = 10000 / params.ueNumPergNb;
454 NS_FATAL_ERROR(
"Traffic scenario " << params.trafficScenario
455 <<
" not valid. Valid values are 0 1 2 3 4");
458 std::cout <<
" statistics\n";
459 SQLiteOutput db(params.outputDir +
"/" + params.simTag +
".db");
460 SinrOutputStats sinrStats;
461 PowerOutputStats ueTxPowerStats;
462 PowerOutputStats gnbRxPowerStats;
463 SlotOutputStats slotStats;
464 RbOutputStats rbStats;
466 sinrStats.SetDb(&db);
467 ueTxPowerStats.SetDb(&db,
"ueTxPower");
468 slotStats.SetDb(&db);
470 gnbRxPowerStats.SetDb(&db,
"gnbRxPower");
476 std::cout <<
" checking frequency and numerology\n";
488 std::cout <<
" logging\n";
491 LogComponentEnable(
"UdpClient", LOG_LEVEL_INFO);
492 LogComponentEnable(
"UdpServer", LOG_LEVEL_INFO);
493 LogComponentEnable(
"LtePdcp", LOG_LEVEL_INFO);
500 std::cout <<
" max tx buffer size\n";
501 Config::SetDefault(
"ns3::LteRlcUm::MaxTxBufferSize", UintegerValue(999999999));
502 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
510 ScenarioParameters scenarioParams;
513 uint32_t gnbSites = 0;
514 NodeContainer gnbNodes;
515 NodeContainer ueNodes;
516 double sector0AngleRad = 30;
517 const uint32_t sectors = 3;
519 scenarioParams.m_isd = params.isd;
520 scenarioParams.m_bsHeight = params.bsHeight;
521 scenarioParams.m_utHeight = params.utHeight;
522 scenarioParams.m_minBsUtDistance = params.minBsUtDistance;
523 scenarioParams.m_antennaOffset = params.antennaOffset;
525 scenarioParams.SetSectorization(sectors);
526 scenarioParams.SetScenarioParameters(scenarioParams);
529 NodeDistributionScenarioInterface* scenario{
nullptr};
530 HexagonalGridScenarioHelper gridScenario;
532 std::cout <<
" hexagonal grid: ";
533 gridScenario.SetScenarioParameters(scenarioParams);
534 gridScenario.SetSimTag(params.simTag);
535 gridScenario.SetResultsDir(params.outputDir);
536 gridScenario.SetNumRings(params.numOuterRings);
537 gnbSites = gridScenario.GetNumSites();
538 uint32_t ueNum = params.ueNumPergNb * gnbSites * sectors;
539 gridScenario.SetUtNumber(ueNum);
540 sector0AngleRad = gridScenario.GetAntennaOrientationRadians(0);
541 std::cout << sector0AngleRad << std::endl;
544 gridScenario.SetMaxUeDistanceToClosestSite(params.maxUeClosestSiteDistance);
545 gridScenario.CreateScenarioWithMobility(
546 Vector(params.speed, 0, 0),
547 params.uesWithRandomUtHeight);
549 gnbNodes = gridScenario.GetBaseStations();
550 ueNodes = gridScenario.GetUserTerminals();
551 scenario = &gridScenario;
554 std::cout <<
"\n Topology configuration: " << gnbSites <<
" sites, " << sectors
555 <<
" sectors/site, " << gnbNodes.GetN() <<
" cells, " << ueNodes.GetN() <<
" UEs\n";
571 NodeContainer gnbSector1Container;
572 NodeContainer gnbSector2Container;
573 NodeContainer gnbSector3Container;
574 std::vector<NodeContainer*> gnbNodesBySector{&gnbSector1Container,
575 &gnbSector2Container,
576 &gnbSector3Container};
577 for (uint32_t cellId = 0; cellId < gnbNodes.GetN(); ++cellId)
579 Ptr<Node> gnb = gnbNodes.Get(cellId);
580 auto sector = scenario->GetSectorIndex(cellId);
581 gnbNodesBySector[sector]->Add(gnb);
583 std::cout <<
" gNb containers: " << gnbSector1Container.GetN() <<
", "
584 << gnbSector2Container.GetN() <<
", " << gnbSector3Container.GetN() << std::endl;
594 NodeContainer ueSector1Container;
595 NodeContainer ueSector2Container;
596 NodeContainer ueSector3Container;
597 std::vector<NodeContainer*> ueNodesBySector{&ueSector1Container,
599 &ueSector3Container};
600 for (uint32_t ueId = 0; ueId < ueNodes.GetN(); ++ueId)
602 Ptr<Node> ue = ueNodes.Get(ueId);
603 auto cellId = scenario->GetCellIndex(ueId);
604 auto sector = scenario->GetSectorIndex(cellId);
605 ueNodesBySector[sector]->Add(ue);
607 std::cout <<
" UE containers: " << ueSector1Container.GetN() <<
", "
608 << ueSector2Container.GetN() <<
", " << ueSector3Container.GetN() << std::endl;
614 std::cout <<
" helpers\n";
615 Ptr<PointToPointEpcHelper> epcHelper;
616 Ptr<NrPointToPointEpcHelper> nrEpcHelper;
618 NetDeviceContainer gnbSector1NetDev;
619 NetDeviceContainer gnbSector2NetDev;
620 NetDeviceContainer gnbSector3NetDev;
621 std::vector<NetDeviceContainer*> gnbNdBySector{&gnbSector1NetDev,
624 NetDeviceContainer ueSector1NetDev;
625 NetDeviceContainer ueSector2NetDev;
626 NetDeviceContainer ueSector3NetDev;
627 std::vector<NetDeviceContainer*> ueNdBySector{&ueSector1NetDev,
631 Ptr<LteHelper> lteHelper =
nullptr;
632 Ptr<NrHelper> nrHelper =
nullptr;
634 if (params.simulator ==
"LENA")
636 epcHelper = CreateObject<PointToPointEpcHelper>();
637 LenaV1Utils::SetLenaV1SimulatorParameters(sector0AngleRad,
654 params.lenaCalibration,
664 params.gnbNoiseFigure,
665 params.ueNoiseFigure,
666 params.enableShadowing);
668 else if (params.simulator ==
"5GLENA")
670 nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
676 params.operationMode,
678 params.numerologyBwp,
696 params.powerAllocation,
708 params.downtiltAngle,
710 params.gnbNumColumns,
713 params.gnbEnable3gppElement,
714 params.ueEnable3gppElement,
719 params.gnbNoiseFigure,
720 params.ueNoiseFigure,
722 params.enableShadowing,
724 params.o2iLowLossThreshold,
725 params.linkO2iConditionToAntennaHeight,
726 params.crossPolarizedGnb,
727 params.crossPolarizedUe,
728 params.polSlantAngleGnb1,
729 params.polSlantAngleGnb2,
730 params.polSlantAngleUe1,
731 params.polSlantAngleUe2,
734 params.bfConfElevation,
736 params.ueBearingAngle);
740 if ((lteHelper ==
nullptr) && (nrHelper ==
nullptr))
742 NS_ABORT_MSG(
"Programming error: no valid helper");
747 std::cout <<
" pgw and internet\n";
751 pgw = epcHelper->GetPgwNode();
755 pgw = nrEpcHelper->GetPgwNode();
757 NodeContainer remoteHostContainer;
758 remoteHostContainer.Create(1);
759 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
760 InternetStackHelper internet;
761 internet.Install(remoteHostContainer);
764 PointToPointHelper p2ph;
765 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
766 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
767 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
768 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
769 Ipv4AddressHelper ipv4h;
770 Ipv4StaticRoutingHelper ipv4RoutingHelper;
771 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
772 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
773 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
774 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
775 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"), Ipv4Mask(
"255.0.0.0"), 1);
776 internet.Install(ueNodes);
778 NetDeviceContainer gnbNetDevs(gnbSector1NetDev, gnbSector2NetDev);
779 gnbNetDevs.Add(gnbSector3NetDev);
780 NetDeviceContainer ueNetDevs(ueSector1NetDev, ueSector2NetDev);
781 ueNetDevs.Add(ueSector3NetDev);
783 Ipv4InterfaceContainer ueIpIfaces;
784 Ipv4Address gatewayAddress;
787 ueIpIfaces = epcHelper->AssignUeIpv4Address(ueNetDevs);
788 gatewayAddress = epcHelper->GetUeDefaultGatewayAddress();
792 ueIpIfaces = nrEpcHelper->AssignUeIpv4Address(ueNetDevs);
793 gatewayAddress = nrEpcHelper->GetUeDefaultGatewayAddress();
796 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
799 std::cout <<
" default gateway\n";
800 for (
auto ue = ueNodes.Begin(); ue != ueNodes.End(); ++ue)
802 Ptr<Ipv4StaticRouting> ueStaticRouting =
803 ipv4RoutingHelper.GetStaticRouting((*ue)->GetObject<Ipv4>());
804 ueStaticRouting->SetDefaultRoute(gatewayAddress, 1);
807 if (nrHelper !=
nullptr && params.attachToClosest)
809 nrHelper->AttachToClosestGnb(ueNetDevs, gnbNetDevs);
814 std::cout <<
" attach UEs to gNBs\n" << std::endl;
815 for (uint32_t ueId = 0; ueId < ueNodes.GetN(); ++ueId)
817 auto cellId = scenario->GetCellIndex(ueId);
818 Ptr<NetDevice> gnbNetDev = gnbNodes.Get(cellId)->GetDevice(0);
819 Ptr<NetDevice> ueNetDev = ueNodes.Get(ueId)->GetDevice(0);
820 if (lteHelper !=
nullptr)
822 lteHelper->Attach(ueNetDev, gnbNetDev);
824 else if (nrHelper !=
nullptr)
826 nrHelper->AttachToGnb(ueNetDev, gnbNetDev);
827 auto uePhyBwp0{nrHelper->GetUePhy(ueNetDev, 0)};
828 auto gnbPhyBwp0{nrHelper->GetGnbPhy(gnbNetDev, 0)};
829 Vector gnbpos = gnbNetDev->GetNode()->GetObject<MobilityModel>()->GetPosition();
830 Vector uepos = ueNetDev->GetNode()->GetObject<MobilityModel>()->GetPosition();
831 double distance = CalculateDistance(gnbpos, uepos);
832 std::cout <<
"ueId " << ueId <<
", cellIndex " << cellId <<
" ue Pos: " << uepos
833 <<
" gnb Pos: " << gnbpos <<
", ue freq "
834 << uePhyBwp0->GetCentralFrequency() / 1e9 <<
", gnb freq "
835 << gnbPhyBwp0->GetCentralFrequency() / 1e9 <<
", sector "
836 << scenario->GetSectorIndex(cellId) <<
", distance " << distance
837 <<
", azimuth gnb->ue:"
838 << RadiansToDegrees(Angles(gnbpos, uepos).GetAzimuth()) << std::endl;
843 if (params.checkUeMobility)
845 Simulator::Schedule(MilliSeconds(100), &PrintUePosition, ueNetDevs, ueNodes);
852 std::cout <<
" server factory\n";
853 uint16_t dlPortLowLat = 1234;
855 ApplicationContainer serverApps;
858 UdpServerHelper dlPacketSinkLowLat(dlPortLowLat);
861 if (params.direction ==
"DL")
863 serverApps.Add(dlPacketSinkLowLat.Install(ueNodes));
867 serverApps.Add(dlPacketSinkLowLat.Install(remoteHost));
871 serverApps.Start(params.udpAppStartTime);
879 Time interval = Seconds(1.0 / lambda);
880 std::cout <<
" client factory:"
881 <<
"\n packet size: " << udpPacketSize <<
"\n interval: " << interval
882 <<
"\n max packets: " << packetCount << std::endl;
884 UdpClientHelper dlClientLowLat;
885 dlClientLowLat.SetAttribute(
"MaxPackets", UintegerValue(packetCount));
886 dlClientLowLat.SetAttribute(
"PacketSize", UintegerValue(udpPacketSize));
887 dlClientLowLat.SetAttribute(
"Interval", TimeValue(interval));
892 std::cout <<
" applications\n";
893 ApplicationContainer clientApps;
894 Ptr<UniformRandomVariable> startRng = CreateObject<UniformRandomVariable>();
895 startRng->SetStream(RngSeedManager::GetRun());
898 for (uint32_t ueId = 0; ueId < ueNodes.GetN(); ++ueId)
900 auto cellId = scenario->GetCellIndex(ueId);
901 auto sector = scenario->GetSectorIndex(cellId);
902 auto siteId = scenario->GetSiteIndex(cellId);
903 Ptr<Node> node = ueNodes.Get(ueId);
904 Ptr<NetDevice> dev = ueNetDevs.Get(ueId);
905 Address addr = ueIpIfaces.GetAddress(ueId);
907 std::cout <<
"app for ue " << ueId <<
", cellId " << cellId <<
", sector " << sector
908 <<
", siteId " << siteId;
911 auto app = InstallApps(node,
918 params.udpAppStartTime,
921 params.appGenerationTime,
924 maxStartTime = std::max(app.second, maxStartTime);
925 clientApps.Add(app.first);
927 std::cout << clientApps.GetN() <<
" apps\n";
930 std::cout <<
" tracing\n";
932 if (lteHelper !=
nullptr && (params.basicTraces || params.extendedTraces))
934 lteHelper->EnableTraces();
936 else if (nrHelper !=
nullptr && params.extendedTraces)
938 nrHelper->EnableTraces();
939 nrHelper->GetPhyRxTrace()->SetSimTag(params.simTag);
940 nrHelper->GetPhyRxTrace()->SetResultsFolder(params.outputDir);
942 else if (nrHelper !=
nullptr && params.basicTraces)
944 nrHelper->EnableDlDataPhyTraces();
945 nrHelper->EnableDlCtrlPhyTraces();
946 nrHelper->EnableDlCtrlPhyTraces();
947 nrHelper->EnableDlCtrlPathlossTraces(ueNetDevs);
948 nrHelper->EnableDlDataPathlossTraces(ueNetDevs);
949 nrHelper->EnableUlPhyTraces();
950 nrHelper->EnablePathlossTraces();
951 nrHelper->GetPhyRxTrace()->SetSimTag(params.simTag);
952 nrHelper->GetPhyRxTrace()->SetResultsFolder(params.outputDir);
955 std::cout <<
" flowmon\n";
956 FlowMonitorHelper flowmonHelper;
957 NodeContainer endpointNodes;
958 endpointNodes.Add(remoteHost);
959 endpointNodes.Add(ueNodes);
961 Ptr<FlowMonitor> monitor = flowmonHelper.Install(endpointNodes);
962 monitor->SetAttribute(
"DelayBinWidth", DoubleValue(0.001));
963 monitor->SetAttribute(
"JitterBinWidth", DoubleValue(0.001));
964 monitor->SetAttribute(
"PacketSizeBinWidth", DoubleValue(20));
966 std::string tableName =
"e2e";
968 Ptr<NrRadioEnvironmentMapHelper>
973 if (params.operationMode ==
"FDD")
975 Config::SetDefault(
"ns3::NrUeNetDevice::PrimaryUlIndex", UintegerValue(1));
977 if (params.dlRem || params.ulRem)
979 std::cout <<
" rem helper\n";
981 uint16_t remPhyIndex = 0;
982 if (params.operationMode ==
"FDD" && params.direction ==
"UL")
987 NetDeviceContainer remNd;
988 Ptr<NetDevice> remDevice;
991 std::vector<NetDeviceContainer*> remNdBySector{ueNdBySector};
992 std::vector<NetDeviceContainer*> remDevBySector{gnbNdBySector};
996 remNdBySector = gnbNdBySector;
997 remDevBySector = ueNdBySector;
1000 uint32_t sectorIndex;
1002 for (uint32_t sector = sectors; sector > 0; --sector)
1004 if (params.remSector == sector || params.remSector == 0)
1006 sectorIndex = sector - 1;
1007 remNd.Add(*remNdBySector[sectorIndex]);
1010 if (params.useLastUeForRem)
1012 remUe = (remDevBySector[sectorIndex]->GetN() - 1);
1013 remDevice = remDevBySector[sectorIndex]->Get(remUe);
1017 remDevice = remDevBySector[sectorIndex]->Get(0);
1024 auto antArray = DynamicCast<NrGnbNetDevice>(remDevice)
1028 ->GetObject<UniformPlanarArray>();
1029 auto antenna = ConstCast<UniformPlanarArray>(antArray);
1030 antenna->SetAttribute(
"AntennaElement",
1031 PointerValue(CreateObject<IsotropicAntennaModel>()));
1035 remHelper = CreateObject<NrRadioEnvironmentMapHelper>();
1036 remHelper->SetMinX(params.xMinRem);
1037 remHelper->SetMaxX(params.xMaxRem);
1038 remHelper->SetResX(params.xResRem);
1039 remHelper->SetMinY(params.yMinRem);
1040 remHelper->SetMaxY(params.yMaxRem);
1041 remHelper->SetResY(params.yResRem);
1042 remHelper->SetZ(params.zRem);
1045 for (uint32_t sector = sectors; sector > 0; --sector)
1047 if ((params.remSector == sector) || (params.remSector == 0))
1049 sectorIndex = sector - 1;
1050 for (uint32_t siteId = 0; siteId < gnbSites; ++siteId)
1052 gnbNdBySector[sectorIndex]
1054 ->GetObject<NrGnbNetDevice>()
1055 ->GetPhy(remPhyIndex)
1056 ->ChangeBeamformingVector(
1057 DynamicCast<NrUeNetDevice>(ueNdBySector[sectorIndex]->Get(siteId)));
1062 remHelper->CreateRem(remNd, remDevice, remPhyIndex);
1065 std::cout <<
"\n----------------------------------------\n"
1066 <<
"Start simulation" << std::endl;
1068 const Time appStopWindow = MilliSeconds(50);
1069 Time stopTime = maxStartTime + params.appGenerationTime + appStopWindow;
1070 Simulator::Stop(stopTime);
1073 sinrStats.EmptyCache();
1074 ueTxPowerStats.EmptyCache();
1075 gnbRxPowerStats.EmptyCache();
1076 slotStats.EmptyCache();
1077 rbStats.EmptyCache();
1086 FlowMonitorOutputStats flowMonStats;
1087 flowMonStats.SetDb(&db, tableName);
1088 flowMonStats.Save(monitor, flowmonHelper, params.outputDir +
"/" + params.simTag);
1090 std::cout <<
"\n----------------------------------------\n"
1091 <<
"End simulation" << std::endl;
1093 Simulator::Destroy();
1097operator<<(std::ostream& os,
const Parameters& parameters)
1103 os << "\n" << m << std::left << std::setw(40 - strlen(m)) << (strlen(m) > 0 ? ":" : "")
1105 MSG(
"Calibration Scenario Parameters");
1107 MSG(
"Model version") << p.simulator << (p.simulator ==
"LENA" ?
" (v1)" :
" (v2)");
1109 MSG(
"Starting Frequency") << (p.startingFreq);
1110 MSG(
"Channel bandwidth") << p.bandwidthMHz <<
" MHz";
1111 MSG(
"Spectrum configuration") << (p.freqScenario == 0 ?
"non-" :
"") <<
"overlapping";
1112 MSG(
"Scheduler") << p.scheduler;
1113 MSG(
"Number of UEs per sector") << p.ueNumPergNb;
1115 if (p.simulator ==
"5GLENA")
1117 MSG(
"LTE Standard") << p.radioNetwork << (p.radioNetwork ==
"LTE" ?
" (4G)" :
" (5G NR)");
1118 MSG(
"Configuration") << (p.confType ==
"calibrationConf" ?
"pre-defined Scenarios"
1119 :
"custom Configuration");
1120 if (p.confType ==
"calibrationConf")
1122 MSG(
"Pre-defined Scenario") << p.nrConfigurationScenario;
1124 MSG(
"Operation mode") << p.operationMode;
1125 MSG(
"Numerology") << p.numerologyBwp;
1127 if (p.operationMode ==
"TDD")
1129 MSG(
"TDD pattern") << p.pattern;
1132 MSG(
"gNB/UE Tx Power (dBm)") << p.gnbTxPower << (
", ") << p.ueTxPower;
1133 MSG(
"gNB/UE Antenna Height (m)") << p.bsHeight << (
", ") << p.utHeight;
1135 MSG(
"UE-BS min distance (m)") << p.minBsUtDistance;
1137 MSG(
"UE-BS max distance (m)") << p.maxUeClosestSiteDistance;
1139 MSG(
"Error model") << p.errorModel;
1141 MSG(
"Downtilt(deg)") << p.downtiltAngle;
1143 MSG(
"gNB Antenna") << p.gnbNumRows << (
", ") << p.gnbNumColumns << (
", ") << p.gnbHSpacing
1144 << (
", ") << p.gnbVSpacing;
1146 MSG(
"gNB Antenna Element") << (p.gnbEnable3gppElement ?
"3GPP" :
"ISO");
1148 MSG(
"UE Antenna") << p.ueNumRows << (
", ") << p.ueNumColumns << (
", ") << p.ueHSpacing
1149 << (
", ") << p.ueVSpacing;
1150 MSG(
"UE Antenna Element") << (p.ueEnable3gppElement ?
"3GPP" :
"ISO");
1152 MSG(
"gNB/UE Noise Figure") << p.gnbNoiseFigure << (
", ") << p.ueNoiseFigure;
1154 if (p.radioNetwork ==
"NR")
1156 MSG(
"5G-NR Realistic BF") << (p.enableRealBF ?
"Enabled" :
"Disabled");
1159 MSG(
"Shadowing") << (p.enableShadowing ?
"Enabled" :
"Disabled");
1160 MSG(
"Fading") << (p.enableFading ?
"Enabled" :
"Disabled");
1162 MSG(
"BF method") << p.bfMethod;
1164 if (p.crossPolarizedGnb)
1166 MSG(
"Cross Polarization at gNB with angles")
1167 << p.polSlantAngleGnb1 << (
", ") << p.polSlantAngleGnb2;
1169 if (p.crossPolarizedUe)
1171 MSG(
"Cross Polarization at UE with angles")
1172 << p.polSlantAngleUe1 << (
", ") << p.polSlantAngleUe2;
1176 MSG(
"Cross Polarization at UE is NOT ENABLED");
1181 MSG(
"Cross Polarization is NOT ENABLED");
1183 MSG(
"4G-NR ULPC mode") << (p.enableUlPc ?
"Enabled" :
"Disabled");
1188 MSG(
"Operation mode") << p.operationMode;
1189 MSG(
"LTE Standard") <<
"4G";
1190 MSG(
"Lena calibration mode") << (p.lenaCalibration ?
"ON" :
"off");
1191 MSG(
"LTE ULPC mode") << (p.enableUlPc ?
"Enabled" :
"Disabled");
1195 MSG(
"Base station positions") <<
"regular hexagonal lay down";
1196 MSG(
"Number of rings") << p.numOuterRings;
1198 if (p.baseStationFile.empty() and p.useSiteFile)
1200 MSG(
"Number of outer rings") << p.numOuterRings;
1204 MSG(
"Network loading") << p.trafficScenario;
1205 switch (p.trafficScenario)
1208 MSG(
" Max loading (80 Mbps/20 MHz)");
1209 MSG(
" Number of packets") <<
"infinite";
1210 MSG(
" Packet size");
1211 switch (p.bandwidthMHz)
1229 MSG(
" Inter-packet interval (per UE)") << p.ueNumPergNb / 10.0 <<
" ms";
1234 MSG(
" Number of packets") << 1;
1235 MSG(
" Packet size") <<
"12 bytes";
1236 MSG(
" Inter-packet interval (per UE)") <<
"1 s";
1240 MSG(
" Moderate loading");
1241 MSG(
" Number of packets") <<
"infinite";
1242 MSG(
" Packet size");
1243 switch (p.bandwidthMHz)
1261 MSG(
" Inter-packet interval (per UE)") << 1 / (1000 / p.ueNumPergNb) <<
" s";
1266 MSG(
" Moderate-high loading");
1267 MSG(
" Number of packets") <<
"infinite";
1268 MSG(
" Packet size");
1269 switch (p.bandwidthMHz)
1287 MSG(
" Inter-packet interval (per UE)") << 1 / (10000.0 / p.ueNumPergNb) <<
" s";
1291 MSG(
" Max loading (120 Mbps/20 MHz)");
1292 MSG(
" Number of packets") <<
"infinite";
1293 MSG(
" Packet size");
1294 switch (p.bandwidthMHz)
1312 MSG(
" Inter-packet interval (per UE)") << p.ueNumPergNb / 10.0 <<
" ms";
1315 os <<
"\n (Unknown configuration)";
1318 MSG(
"Application start window")
1319 << p.udpAppStartTime.As(Time::MS) <<
" + " << appStartWindow.As(Time::MS);
1320 MSG(
"Application on duration") << p.appGenerationTime.As(Time::MS);
1321 MSG(
"Traffic direction") << p.direction;
1324 MSG(
"Output file name") << p.simTag;
1325 MSG(
"Output directory") << p.outputDir;
1326 MSG(
"Logging") << (p.logging ?
"ON" :
"off");
1327 MSG(
"Basic Trace file generation") << (p.basicTraces ?
"ON" :
"OFF");
1328 MSG(
"Extended Trace file generation") << (p.extendedTraces ?
"ON" :
"OFF");
1330 MSG(
"Radio environment map") << (p.dlRem ?
"DL" : (p.ulRem ?
"UL" :
"off"));
1331 if (p.dlRem || p.ulRem)
1333 MSG(
" Sector to sample");
1334 if (p.remSector == 0)
1342 MSG(
" X range") << p.xMinRem <<
" - " << p.xMaxRem <<
", in " << p.xResRem <<
" m steps";
1343 MSG(
" Y range") << p.yMinRem <<
" - " << p.yMaxRem <<
", in " << p.yResRem <<
" m steps";
1344 MSG(
" Altitude (Z)") << p.zRem <<
" m";
static void SetLenaV2SimulatorParameters(const double sector0AngleRad, const std::string &scenario, const std::string &confType, const std::string &radioNetwork, std::string errorModel, const std::string &operationMode, const std::string &direction, uint16_t numerology, const std::string &pattern, const NodeContainer &gnbSector1Container, const NodeContainer &gnbSector2Container, const NodeContainer &gnbSector3Container, const NodeContainer &ueSector1Container, const NodeContainer &ueSector2Container, const NodeContainer &ueSector3Container, const Ptr< NrPointToPointEpcHelper > &baseEpcHelper, Ptr< NrHelper > &nrHelper, NetDeviceContainer &gnbSector1NetDev, NetDeviceContainer &gnbSector2NetDev, NetDeviceContainer &gnbSector3NetDev, NetDeviceContainer &ueSector1NetDev, NetDeviceContainer &ueSector2NetDev, NetDeviceContainer &ueSector3NetDev, bool enableFading, bool enableUlPc, std::string powerAllocation, SinrOutputStats *sinrStats, PowerOutputStats *ueTxPowerStats, PowerOutputStats *gnbRxPowerStats, SlotOutputStats *slotStats, RbOutputStats *rbStats, const std::string &scheduler, uint32_t bandwidthMHz, double startingFreq, uint32_t freqScenario, double gnbTxPower, double ueTxPower, double downtiltAngle, const uint32_t gnbNumRows, const uint32_t gnbNumColumns, const uint32_t ueNumRows, const uint32_t ueNumColumns, bool gnbEnable3gppElement, bool ueEnable3gppElement, const double gnbHSpacing, const double gnbVSpacing, const double ueHSpacing, const double ueVSpacing, const double gnbNoiseFigure, const double ueNoiseFigure, bool enableRealBF, bool enableShadowing, double o2iThreshold, double o2iLowLossThreshold, bool linkO2iConditionToAntennaHeight, bool crossPolarizedGnb, bool crossPolarizedUe, double polSlantAngleGnb1, double polSlantAngleGnb2, double polSlantAngleUe1, double polSlantAngleUe2, std::string bfMethod, uint16_t beamConfSector, double beamConfElevation, double isd, bool ueBearingAngle)
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)