136 const std::string& scenario,
137 const std::string& radioNetwork,
138 std::string errorModel,
139 const std::string& operationMode,
140 const std::string& direction,
142 const std::string& pattern,
143 const NodeContainer& gnbSector1Container,
144 const NodeContainer& gnbSector2Container,
145 const NodeContainer& gnbSector3Container,
146 const NodeContainer& ueSector1Container,
147 const NodeContainer& ueSector2Container,
148 const NodeContainer& ueSector3Container,
149 const Ptr<NrPointToPointEpcHelper>& baseEpcHelper,
150 Ptr<NrHelper>& nrHelper,
151 NetDeviceContainer& gnbSector1NetDev,
152 NetDeviceContainer& gnbSector2NetDev,
153 NetDeviceContainer& gnbSector3NetDev,
154 NetDeviceContainer& ueSector1NetDev,
155 NetDeviceContainer& ueSector2NetDev,
156 NetDeviceContainer& ueSector3NetDev,
159 std::string powerAllocation,
165 const std::string& scheduler,
166 uint32_t bandwidthMHz,
167 uint32_t freqScenario,
168 double downtiltAngle)
173 uint8_t numScPerRb = 1;
174 double rbOverhead = 0.1;
175 uint32_t harqProcesses = 20;
176 uint32_t n1Delay = 2;
177 uint32_t n2Delay = 2;
178 if (radioNetwork ==
"LTE")
184 if (errorModel.empty())
186 errorModel =
"ns3::LenaErrorModel";
188 else if (errorModel !=
"ns3::NrLteMiErrorModel" && errorModel !=
"ns3::LenaErrorModel")
190 NS_ABORT_MSG(
"The selected error model is not recommended for LTE");
193 else if (radioNetwork ==
"NR")
197 if (errorModel.empty())
199 errorModel =
"ns3::NrEesmCcT2";
201 else if (errorModel ==
"ns3::NrLteMiErrorModel")
203 NS_ABORT_MSG(
"The selected error model is not recommended for NR");
208 NS_ABORT_MSG(
"Unrecognized radio network technology");
220 nrHelper = CreateObject<NrHelper>();
222 Ptr<IdealBeamformingHelper> idealBeamformingHelper;
227 if (radioNetwork ==
"NR" || calibration)
229 idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
230 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
233 Ptr<NrPointToPointEpcHelper> nrEpcHelper = DynamicCast<NrPointToPointEpcHelper>(baseEpcHelper);
234 nrHelper->SetEpcHelper(nrEpcHelper);
236 double txPowerBs = 0.0;
238 if (scenario ==
"UMi")
242 else if (scenario ==
"UMa" || scenario ==
"RMa")
248 NS_ABORT_MSG(
"Unsupported scenario " << scenario <<
". Supported values: UMi, UMa, RMa");
251 nrHelper->SetUePhyAttribute(
"NoiseFigure", DoubleValue(9.0));
252 nrHelper->SetUePhyAttribute(
"EnableUplinkPowerControl", BooleanValue(enableUlPc));
254 NrSpectrumValueHelper::PowerAllocationType powerAllocationEnum;
255 if (powerAllocation ==
"UniformPowerAllocBw")
257 powerAllocationEnum = NrSpectrumValueHelper::UNIFORM_POWER_ALLOCATION_BW;
259 else if (powerAllocation ==
"UniformPowerAllocUsed")
261 powerAllocationEnum = NrSpectrumValueHelper::UNIFORM_POWER_ALLOCATION_USED;
265 NS_ABORT_MSG(
"Unsupported power allocation type "
267 <<
". Supported values: "
268 "UniformPowerAllocBw and UniformPowerAllocUsed.");
271 nrHelper->SetUePhyAttribute(
"PowerAllocationType", EnumValue(powerAllocationEnum));
273 nrHelper->SetGnbPhyAttribute(
"PowerAllocationType",
274 EnumValue(NrSpectrumValueHelper::UNIFORM_POWER_ALLOCATION_BW));
277 nrHelper->SetUlErrorModel(errorModel);
278 nrHelper->SetDlErrorModel(errorModel);
288 nrHelper->SetGnbDlAmcAttribute(
"NumRefScPerRb", UintegerValue(numScPerRb));
289 nrHelper->SetGnbUlAmcAttribute(
"NumRefScPerRb", UintegerValue(1));
291 nrHelper->SetGnbPhyAttribute(
"RbOverhead", DoubleValue(rbOverhead));
292 nrHelper->SetGnbPhyAttribute(
"N2Delay", UintegerValue(n2Delay));
293 nrHelper->SetGnbPhyAttribute(
"N1Delay", UintegerValue(n1Delay));
295 nrHelper->SetUeMacAttribute(
"NumHarqProcess", UintegerValue(harqProcesses));
296 nrHelper->SetGnbMacAttribute(
"NumHarqProcess", UintegerValue(harqProcesses));
349 const double band0Start = 2110e6;
350 double bandwidthBwp = bandwidthMHz * 1e6;
359 if (operationMode ==
"FDD")
361 Config::SetDefault(
"ns3::NrUeNetDevice::PrimaryUlIndex", UintegerValue(1));
363 if (freqScenario == 0)
367 if (operationMode ==
"FDD")
379 double bandwidthCc = numBwp * bandwidthBwp;
380 uint8_t numCcPerBand = 1;
381 double bandwidthBand = numCcPerBand * bandwidthCc;
382 double bandCenter = band0Start + bandwidthBand / 2.0;
384 NS_LOG_LOGIC(
"NON_OVERLAPPING, " << operationMode <<
": " << bandwidthBand <<
":"
385 << bandwidthCc <<
":" << bandwidthBwp <<
", "
386 << (
int)numCcPerBand <<
", " << (
int)numBwp);
388 NS_LOG_LOGIC(
"bandConf0: " << bandCenter <<
" " << bandwidthBand);
391 bandCenter += bandwidthBand;
393 NS_LOG_LOGIC(
"bandConf1: " << bandCenter <<
" " << bandwidthBand);
396 bandCenter += bandwidthBand;
398 NS_LOG_LOGIC(
"bandConf2: " << bandCenter <<
" " << bandwidthBand);
410 bandCenter = band0Start + bandwidthBwp / 2.0;
412 NS_LOG_LOGIC(
"band0[0][0]: " << bandCenter <<
" " << bandwidthBwp);
413 ConfigureBwpTo(band0.
m_cc[0]->m_bwp[0], bandCenter, bandwidthBwp);
414 bandCenter += bandwidthBwp;
416 if (operationMode ==
"FDD")
418 NS_LOG_LOGIC(
"band0[0][1]: " << bandCenter <<
" " << bandwidthBwp);
419 ConfigureBwpTo(band0.
m_cc[0]->m_bwp[1], bandCenter, bandwidthBwp);
420 bandCenter += bandwidthBwp;
423 NS_LOG_LOGIC(
"band1[0][0]: " << bandCenter <<
" " << bandwidthBwp);
424 ConfigureBwpTo(band1.
m_cc[0]->m_bwp[0], bandCenter, bandwidthBwp);
425 bandCenter += bandwidthBwp;
427 if (operationMode ==
"FDD")
429 NS_LOG_LOGIC(
"band1[0][1]: " << bandCenter <<
" " << bandwidthBwp);
430 ConfigureBwpTo(band1.
m_cc[0]->m_bwp[1], bandCenter, bandwidthBwp);
431 bandCenter += bandwidthBwp;
434 NS_LOG_LOGIC(
"band2[0][0]: " << bandCenter <<
" " << bandwidthBwp);
435 ConfigureBwpTo(band2.
m_cc[0]->m_bwp[0], bandCenter, bandwidthBwp);
436 bandCenter += bandwidthBwp;
438 if (operationMode ==
"FDD")
440 NS_LOG_LOGIC(
"band2[0][1]: " << bandCenter <<
" " << bandwidthBwp);
441 ConfigureBwpTo(band2.
m_cc[0]->m_bwp[1], bandCenter, bandwidthBwp);
444 std::cout <<
"BWP Configuration for NON_OVERLAPPING case, mode " << operationMode <<
"\n"
445 << band0 << band1 << band2;
448 else if (freqScenario == 1)
452 if (operationMode ==
"FDD")
464 double bandwidthCc = numBwp * bandwidthBwp;
465 uint8_t numCcPerBand = 1;
466 double bandwidthBand = numCcPerBand * bandwidthCc;
467 double bandCenter = band0Start + bandwidthBand / 2.0;
469 NS_LOG_LOGIC(
"OVERLAPPING, " << operationMode <<
": " << bandwidthBand <<
":" << bandwidthCc
470 <<
":" << bandwidthBwp <<
", " << (
int)numCcPerBand <<
", "
473 NS_LOG_LOGIC(
"bandConf0: " << bandCenter <<
" " << bandwidthBand);
476 bandCenter += bandwidthBand;
483 bandCenter = band0Start + bandwidthBwp / 2.0;
485 NS_LOG_LOGIC(
"band0[0][0]: " << bandCenter <<
" " << bandwidthBwp);
486 ConfigureBwpTo(band0.
m_cc[0]->m_bwp[0], bandCenter, bandwidthBwp);
487 bandCenter += bandwidthBwp;
489 if (operationMode ==
"FDD")
491 NS_LOG_LOGIC(
"band0[0][1]: " << bandCenter <<
" " << bandwidthBwp);
492 ConfigureBwpTo(band0.
m_cc[0]->m_bwp[1], bandCenter, bandwidthBwp);
495 std::cout <<
"BWP Configuration for OVERLAPPING case, mode " << operationMode <<
"\n"
501 std::cerr <<
"unknown combination of freqScenario = " << freqScenario
502 <<
" and operationMode = " << operationMode << std::endl;
505 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
506 channelHelper->ConfigureFactories(scenario,
"LOS",
"ThreeGpp");
508 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(!calibration));
509 Config::SetDefault(
"ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(100)));
514 channelHelper->AssignChannelsToBands({band0, band1, band2},
519 channelHelper->AssignChannelsToBands({band0, band1, band2});
525 if (freqScenario == 0)
559 if (radioNetwork ==
"LTE" && calibration)
561 idealBeamformingHelper->SetAttribute(
565 else if (radioNetwork ==
"NR")
567 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
573 if (scheduler ==
"PF")
575 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerOfdmaPF"));
577 else if (scheduler ==
"RR")
579 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(
"ns3::NrMacSchedulerOfdmaRR"));
583 nrHelper->SetSchedulerAttribute(
"SrsSymbols", UintegerValue(1));
584 nrHelper->SetSchedulerAttribute(
"EnableSrsInUlSlots", BooleanValue(
false));
585 nrHelper->SetSchedulerAttribute(
"EnableSrsInFSlots", BooleanValue(
false));
588 nrHelper->SetSchedulerAttribute(
"DlCtrlSymbols", UintegerValue(1));
591 nrEpcHelper->SetAttribute(
"S1uLinkDelay", TimeValue(MilliSeconds(0)));
594 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(1));
595 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(1));
596 Ptr<IsotropicAntennaModel> ueIsotropicAntenna = CreateObject<IsotropicAntennaModel>();
597 ueIsotropicAntenna->SetAttribute(
"Gain", DoubleValue(0.0));
598 nrHelper->SetUeAntennaAttribute(
"AntennaElement", PointerValue(ueIsotropicAntenna));
603 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(1));
604 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(1));
608 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(5));
609 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(2));
612 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
613 PointerValue(CreateObject<ThreeGppAntennaModel>()));
614 nrHelper->SetGnbAntennaAttribute(
"DowntiltAngle", DoubleValue(downtiltAngle * M_PI / 180.0));
617 nrHelper->SetUePhyAttribute(
"TxPower", DoubleValue(23.0));
623 if (radioNetwork ==
"LTE")
625 switch (bandwidthMHz)
629 nrHelper->SetGnbMacAttribute(
"NumRbPerRbg", UintegerValue(4));
632 nrHelper->SetGnbMacAttribute(
"NumRbPerRbg", UintegerValue(3));
635 nrHelper->SetGnbMacAttribute(
"NumRbPerRbg", UintegerValue(2));
638 NS_ABORT_MSG(
"Currently, only supported bandwidths are 5, 10, 15, and 20MHz, you chose "
644 uint32_t bwpIdForLowLat = 0;
645 if (operationMode ==
"FDD" && direction ==
"UL")
651 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_DEFAULT",
652 UintegerValue(bwpIdForLowLat));
655 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_VIDEO_TCP_DEFAULT",
656 UintegerValue(bwpIdForLowLat));
677 gnbSector1NetDev = nrHelper->InstallGnbDevice(gnbSector1Container, sector1Bwps);
678 NetDeviceContainer gnbNetDevs(gnbSector1NetDev);
679 gnbSector2NetDev = nrHelper->InstallGnbDevice(gnbSector2Container, sector2Bwps);
680 gnbNetDevs.Add(gnbSector2NetDev);
681 gnbSector3NetDev = nrHelper->InstallGnbDevice(gnbSector3Container, sector3Bwps);
682 gnbNetDevs.Add(gnbSector3NetDev);
683 ueSector1NetDev = nrHelper->InstallUeDevice(ueSector1Container, sector1Bwps);
684 NetDeviceContainer ueNetDevs(ueSector1NetDev);
685 ueSector2NetDev = nrHelper->InstallUeDevice(ueSector2Container, sector2Bwps);
686 ueNetDevs.Add(ueSector2NetDev);
687 ueSector3NetDev = nrHelper->InstallUeDevice(ueSector3Container, sector3Bwps);
688 ueNetDevs.Add(ueSector3NetDev);
690 int64_t randomStream = 1;
691 randomStream += nrHelper->AssignStreams(gnbSector1NetDev, randomStream);
692 randomStream += nrHelper->AssignStreams(gnbSector2NetDev, randomStream);
693 randomStream += nrHelper->AssignStreams(gnbSector3NetDev, randomStream);
694 randomStream += nrHelper->AssignStreams(ueSector1NetDev, randomStream);
695 randomStream += nrHelper->AssignStreams(ueSector2NetDev, randomStream);
696 randomStream += nrHelper->AssignStreams(ueSector3NetDev, randomStream);
704 std::vector<double> sectorOrientationRad{
706 sector0AngleRad + 2.0 * M_PI / 3.0,
707 sector0AngleRad - 2.0 * M_PI / 3.0
710 for (uint32_t cellId = 0; cellId < gnbNetDevs.GetN(); ++cellId)
712 Ptr<NetDevice> gnb = gnbNetDevs.Get(cellId);
713 uint32_t numBwps = nrHelper->GetNumberBwp(gnb);
716 NS_ABORT_MSG(
"Incorrect number of BWPs per CC");
719 uint32_t sector = cellId % (gnbSector3NetDev.GetN() == 0 ? 1 : 3);
720 double orientation = sectorOrientationRad[sector];
723 ConfigurePhy(nrHelper, gnb, orientation, numerology, txPowerBs, pattern, 0);
727 ConfigurePhy(nrHelper, gnb, orientation, numerology, txPowerBs, pattern, 1);
729 nrHelper->GetBwpManagerGnb(gnb)->SetOutputLink(1, 0);
734 for (
auto nd = ueNetDevs.Begin(); nd != ueNetDevs.End(); ++nd)
736 auto uePhyFirst = nrHelper->GetUePhy(*nd, 0);
737 auto uePhySecond{uePhyFirst};
738 if (operationMode ==
"FDD")
740 nrHelper->GetBwpManagerUe(*nd)->SetOutputLink(0, 1);
741 uePhySecond = nrHelper->GetUePhy(*nd, 1);
742 uePhySecond->SetUplinkPowerControl(uePhyFirst->GetUplinkPowerControl());
744 uePhyFirst->TraceConnectWithoutContext(
"DlDataSinr",
745 MakeBoundCallback(&ReportSinrNr, sinrStats));
746 uePhySecond->TraceConnectWithoutContext(
"ReportPowerSpectralDensity",
747 MakeBoundCallback(&ReportPowerNr, ueTxPowerStats));
750 for (
auto nd = gnbNetDevs.Begin(); nd != gnbNetDevs.End(); ++nd)
753 if (operationMode ==
"FDD" && direction ==
"UL")
757 auto gnbPhy = nrHelper->GetGnbPhy(*nd, bwpId);
758 gnbPhy->TraceConnectWithoutContext(
"SlotDataStats",
759 MakeBoundCallback(&ReportSlotStatsNr, slotStats));
760 gnbPhy->TraceConnectWithoutContext(
"RBDataStats",
761 MakeBoundCallback(&ReportRbStatsNr, rbStats));
762 gnbPhy->GetSpectrumPhy()->TraceConnectWithoutContext(
764 MakeBoundCallback(&ReportGnbRxDataNr, gnbRxPowerStats));
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)