7#include "nr-bearer-stats-calculator.h"
8#include "nr-epc-helper.h"
9#include "nr-mac-rx-trace.h"
10#include "nr-phy-rx-trace.h"
12#include <ns3/bandwidth-part-gnb.h>
13#include <ns3/bandwidth-part-ue.h>
14#include <ns3/beam-manager.h>
15#include <ns3/buildings-channel-condition-model.h>
16#include <ns3/bwp-manager-algorithm.h>
17#include <ns3/bwp-manager-gnb.h>
18#include <ns3/bwp-manager-ue.h>
19#include <ns3/config.h>
20#include <ns3/multi-model-spectrum-channel.h>
22#include <ns3/nr-ch-access-manager.h>
23#include <ns3/nr-chunk-processor.h>
24#include <ns3/nr-epc-gnb-application.h>
25#include <ns3/nr-epc-ue-nas.h>
26#include <ns3/nr-epc-x2.h>
27#include <ns3/nr-gnb-mac.h>
28#include <ns3/nr-gnb-net-device.h>
29#include <ns3/nr-gnb-phy.h>
30#include <ns3/nr-mac-scheduler-tdma-rr.h>
31#include <ns3/nr-pm-search-full.h>
32#include <ns3/nr-rrc-protocol-ideal.h>
33#include <ns3/nr-rrc-protocol-real.h>
34#include <ns3/nr-ue-mac.h>
35#include <ns3/nr-ue-net-device.h>
36#include <ns3/nr-ue-phy.h>
37#include <ns3/nr-ue-rrc.h>
38#include <ns3/pointer.h>
39#include <ns3/three-gpp-channel-model.h>
40#include <ns3/three-gpp-propagation-loss-model.h>
41#include <ns3/three-gpp-spectrum-propagation-loss-model.h>
42#include <ns3/three-gpp-v2v-channel-condition-model.h>
43#include <ns3/three-gpp-v2v-propagation-loss-model.h>
44#include <ns3/uniform-planar-array.h>
52NS_LOG_COMPONENT_DEFINE(
"NrHelper");
54NS_OBJECT_ENSURE_REGISTERED(NrHelper);
58 NS_LOG_FUNCTION(
this);
59 m_channelFactory.SetTypeId(MultiModelSpectrumChannel::GetTypeId());
60 m_gnbNetDeviceFactory.SetTypeId(NrGnbNetDevice::GetTypeId());
71 m_ueAntennaFactory.SetTypeId(UniformPlanarArray::GetTypeId());
72 m_gnbAntennaFactory.SetTypeId(UniformPlanarArray::GetTypeId());
79 m_spectrumPropagationFactory.SetTypeId(ThreeGppSpectrumPropagationLossModel::GetTypeId());
84 m_pathlossModelFactory.SetTypeId(ThreeGppPropagationLossModel::GetTypeId());
85 m_channelConditionModelFactory.SetTypeId(ThreeGppChannelConditionModel::GetTypeId());
87 Config::SetDefault(
"ns3::NrEpsBearer::Release", UintegerValue(18));
92 NS_LOG_FUNCTION(
this);
93 if (m_beamformingHelper)
95 m_beamformingHelper->Dispose();
97 m_beamformingHelper =
nullptr;
104 TypeId(
"ns3::NrHelper")
106 .AddConstructor<NrHelper>()
107 .AddAttribute(
"EnableMimoFeedback",
108 "Generate CQI feedback with RI and PMI for MIMO support",
110 MakeBooleanAccessor(&NrHelper::m_enableMimoFeedback),
111 MakeBooleanChecker())
112 .AddAttribute(
"PmSearchMethod",
113 "Type of the precoding matrix search method.",
117 .AddAttribute(
"UseIdealRrc",
118 "If true, NrRrcProtocolIdeal will be used for RRC signaling. "
119 "If false, NrRrcProtocolReal will be used.",
121 MakeBooleanAccessor(&NrHelper::m_useIdealRrc),
122 MakeBooleanChecker())
123 .AddAttribute(
"HandoverAlgorithm",
124 "The type of handover algorithm to be used for gNBs. "
125 "The allowed values for this attributes are the type names "
126 "of any class inheriting from ns3::LteHandoverAlgorithm.",
127 StringValue(
"ns3::NrNoOpHandoverAlgorithm"),
128 MakeStringAccessor(&NrHelper::SetHandoverAlgorithmType,
129 &NrHelper::GetHandoverAlgorithmType),
130 MakeStringChecker());
134typedef std::function<void(ObjectFactory*, ObjectFactory*)> InitPathLossFn;
137InitRma(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
139 pathlossModelFactory->SetTypeId(ThreeGppRmaPropagationLossModel::GetTypeId());
140 channelConditionModelFactory->SetTypeId(ThreeGppRmaChannelConditionModel::GetTypeId());
144InitRma_LoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
146 pathlossModelFactory->SetTypeId(ThreeGppRmaPropagationLossModel::GetTypeId());
147 channelConditionModelFactory->SetTypeId(AlwaysLosChannelConditionModel::GetTypeId());
151InitRma_nLoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
153 pathlossModelFactory->SetTypeId(ThreeGppRmaPropagationLossModel::GetTypeId());
154 channelConditionModelFactory->SetTypeId(NeverLosChannelConditionModel::GetTypeId());
158InitUma(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
160 pathlossModelFactory->SetTypeId(ThreeGppUmaPropagationLossModel::GetTypeId());
161 channelConditionModelFactory->SetTypeId(ThreeGppUmaChannelConditionModel::GetTypeId());
165InitUma_LoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
167 pathlossModelFactory->SetTypeId(ThreeGppUmaPropagationLossModel::GetTypeId());
168 channelConditionModelFactory->SetTypeId(AlwaysLosChannelConditionModel::GetTypeId());
172InitUma_nLoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
174 pathlossModelFactory->SetTypeId(ThreeGppUmaPropagationLossModel::GetTypeId());
175 channelConditionModelFactory->SetTypeId(NeverLosChannelConditionModel::GetTypeId());
179InitUmi(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
181 pathlossModelFactory->SetTypeId(ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId());
182 channelConditionModelFactory->SetTypeId(
183 ThreeGppUmiStreetCanyonChannelConditionModel::GetTypeId());
187InitUmi_LoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
189 pathlossModelFactory->SetTypeId(ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId());
190 channelConditionModelFactory->SetTypeId(AlwaysLosChannelConditionModel::GetTypeId());
194InitUmi_nLoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
196 pathlossModelFactory->SetTypeId(ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId());
197 channelConditionModelFactory->SetTypeId(NeverLosChannelConditionModel::GetTypeId());
201InitIndoorOpen(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
203 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
204 channelConditionModelFactory->SetTypeId(
205 ThreeGppIndoorOpenOfficeChannelConditionModel::GetTypeId());
209InitIndoorOpen_LoS(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
211 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
212 channelConditionModelFactory->SetTypeId(AlwaysLosChannelConditionModel::GetTypeId());
216InitIndoorOpen_nLoS(ObjectFactory* pathlossModelFactory,
217 ObjectFactory* channelConditionModelFactory)
219 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
220 channelConditionModelFactory->SetTypeId(NeverLosChannelConditionModel::GetTypeId());
224InitIndoorMixed(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
226 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
227 channelConditionModelFactory->SetTypeId(
228 ThreeGppIndoorMixedOfficeChannelConditionModel::GetTypeId());
232InitIndoorMixed_LoS(ObjectFactory* pathlossModelFactory,
233 ObjectFactory* channelConditionModelFactory)
235 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
236 channelConditionModelFactory->SetTypeId(AlwaysLosChannelConditionModel::GetTypeId());
240InitIndoorMixed_nLoS(ObjectFactory* pathlossModelFactory,
241 ObjectFactory* channelConditionModelFactory)
243 pathlossModelFactory->SetTypeId(ThreeGppIndoorOfficePropagationLossModel::GetTypeId());
244 channelConditionModelFactory->SetTypeId(NeverLosChannelConditionModel::GetTypeId());
248InitUmaBuildings(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
250 pathlossModelFactory->SetTypeId(ThreeGppUmaPropagationLossModel::GetTypeId());
251 channelConditionModelFactory->SetTypeId(BuildingsChannelConditionModel::GetTypeId());
255InitUmiBuildings(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
257 pathlossModelFactory->SetTypeId(ThreeGppUmiStreetCanyonPropagationLossModel::GetTypeId());
258 channelConditionModelFactory->SetTypeId(BuildingsChannelConditionModel::GetTypeId());
262InitV2VHighway(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
264 pathlossModelFactory->SetTypeId(ThreeGppV2vHighwayPropagationLossModel::GetTypeId());
265 channelConditionModelFactory->SetTypeId(ThreeGppV2vHighwayChannelConditionModel::GetTypeId());
269InitV2VUrban(ObjectFactory* pathlossModelFactory, ObjectFactory* channelConditionModelFactory)
271 pathlossModelFactory->SetTypeId(ThreeGppV2vUrbanPropagationLossModel::GetTypeId());
272 channelConditionModelFactory->SetTypeId(ThreeGppV2vUrbanChannelConditionModel::GetTypeId());
278 NS_LOG_FUNCTION(
this);
280 static std::unordered_map<BandwidthPartInfo::Scenario, InitPathLossFn, std::hash<int>>
282 {BandwidthPartInfo::RMa,
283 std::bind(&InitRma, std::placeholders::_1, std::placeholders::_2)},
285 std::bind(&InitRma_LoS, std::placeholders::_1, std::placeholders::_2)},
287 std::bind(&InitRma_nLoS, std::placeholders::_1, std::placeholders::_2)},
289 std::bind(&InitUma, std::placeholders::_1, std::placeholders::_2)},
291 std::bind(&InitUma_LoS, std::placeholders::_1, std::placeholders::_2)},
293 std::bind(&InitUma_nLoS, std::placeholders::_1, std::placeholders::_2)},
295 std::bind(&InitUmi, std::placeholders::_1, std::placeholders::_2)},
297 std::bind(&InitUmi_LoS, std::placeholders::_1, std::placeholders::_2)},
299 std::bind(&InitUmi_nLoS, std::placeholders::_1, std::placeholders::_2)},
301 std::bind(&InitIndoorOpen, std::placeholders::_1, std::placeholders::_2)},
303 std::bind(&InitIndoorOpen_LoS, std::placeholders::_1, std::placeholders::_2)},
305 std::bind(&InitIndoorOpen_nLoS, std::placeholders::_1, std::placeholders::_2)},
307 std::bind(&InitIndoorMixed, std::placeholders::_1, std::placeholders::_2)},
309 std::bind(&InitIndoorMixed_LoS, std::placeholders::_1, std::placeholders::_2)},
311 std::bind(&InitIndoorMixed_nLoS, std::placeholders::_1, std::placeholders::_2)},
313 std::bind(&InitUmaBuildings, std::placeholders::_1, std::placeholders::_2)},
315 std::bind(&InitUmiBuildings, std::placeholders::_1, std::placeholders::_2)},
317 std::bind(&InitV2VHighway, std::placeholders::_1, std::placeholders::_2)},
319 std::bind(&InitV2VUrban, std::placeholders::_1, std::placeholders::_2)},
323 for (
const auto& cc : band->
m_cc)
325 for (
const auto& bwp : cc->m_bwp)
329 initLookupTable.at(bwp->m_scenario)(&m_pathlossModelFactory,
330 &m_channelConditionModelFactory);
332 auto channelConditionModel =
333 m_channelConditionModelFactory.Create<ChannelConditionModel>();
337 bwp->m_propagation = m_pathlossModelFactory.Create<ThreeGppPropagationLossModel>();
338 bwp->m_propagation->SetAttributeFailSafe(
"Frequency",
339 DoubleValue(bwp->m_centralFrequency));
340 DynamicCast<ThreeGppPropagationLossModel>(bwp->m_propagation)
341 ->SetChannelConditionModel(channelConditionModel);
344 if (bwp->m_3gppChannel ==
nullptr && flags &
INIT_FADING)
347 m_spectrumPropagationFactory.Create<ThreeGppSpectrumPropagationLossModel>();
348 DynamicCast<ThreeGppSpectrumPropagationLossModel>(bwp->m_3gppChannel)
349 ->SetChannelModelAttribute(
"Frequency", DoubleValue(bwp->m_centralFrequency));
350 DynamicCast<ThreeGppSpectrumPropagationLossModel>(bwp->m_3gppChannel)
351 ->SetChannelModelAttribute(
"Scenario", StringValue(bwp->GetScenario()));
352 DynamicCast<ThreeGppSpectrumPropagationLossModel>(bwp->m_3gppChannel)
353 ->SetChannelModelAttribute(
"ChannelConditionModel",
354 PointerValue(channelConditionModel));
359 bwp->m_channel = m_channelFactory.Create<SpectrumChannel>();
360 bwp->m_channel->AddPropagationLossModel(bwp->m_propagation);
361 bwp->m_channel->AddPhasedArraySpectrumPropagationLossModel(bwp->m_3gppChannel);
367std::pair<double, BandwidthPartInfoPtrVector>
371 double totalBandwidth = 0.0;
372 for (
auto& bandConf : bandConfs)
376 totalBandwidth += bandConf.m_channelBandwidth;
378 std::vector<std::reference_wrapper<OperationBandInfo>> bandsRefs(m_bands.rbegin(),
388 NS_LOG_FUNCTION(gnbDevice);
389 Ptr<const NrGnbNetDevice> netDevice = DynamicCast<const NrGnbNetDevice>(gnbDevice);
390 if (netDevice ==
nullptr)
394 return netDevice->GetCcMapSize();
400 NS_LOG_FUNCTION(gnbDevice << bwpIndex);
401 NS_ASSERT(bwpIndex < UINT8_MAX);
402 Ptr<NrGnbNetDevice> netDevice = DynamicCast<NrGnbNetDevice>(gnbDevice);
403 if (netDevice ==
nullptr)
407 return netDevice->GetPhy(
static_cast<uint8_t
>(bwpIndex));
413 NS_LOG_FUNCTION(gnbDevice << bwpIndex);
414 NS_ASSERT(bwpIndex < UINT8_MAX);
415 Ptr<NrGnbNetDevice> netDevice = DynamicCast<NrGnbNetDevice>(gnbDevice);
416 if (netDevice ==
nullptr)
420 return netDevice->GetMac(
static_cast<uint8_t
>(bwpIndex));
426 NS_LOG_FUNCTION(ueDevice << bwpIndex);
427 NS_ASSERT(bwpIndex < UINT8_MAX);
428 Ptr<NrUeNetDevice> netDevice = DynamicCast<NrUeNetDevice>(ueDevice);
429 if (netDevice ==
nullptr)
433 return netDevice->GetMac(
static_cast<uint8_t
>(bwpIndex));
439 NS_LOG_FUNCTION(ueDevice << bwpIndex);
440 NS_ASSERT(bwpIndex < UINT8_MAX);
441 Ptr<NrUeNetDevice> netDevice = DynamicCast<NrUeNetDevice>(ueDevice);
442 if (netDevice ==
nullptr)
446 return netDevice->GetPhy(
static_cast<uint8_t
>(bwpIndex));
452 NS_LOG_FUNCTION(gnbDevice);
454 Ptr<NrGnbNetDevice> netDevice = DynamicCast<NrGnbNetDevice>(gnbDevice);
455 if (netDevice ==
nullptr)
460 return netDevice->GetBwpManager();
466 NS_LOG_FUNCTION(ueDevice);
468 Ptr<NrUeNetDevice> netDevice = DynamicCast<NrUeNetDevice>(ueDevice);
469 if (netDevice ==
nullptr)
474 return netDevice->GetBwpManager();
480 NS_LOG_FUNCTION(gnbDevice << bwpIndex);
482 Ptr<NrGnbNetDevice> netDevice = DynamicCast<NrGnbNetDevice>(gnbDevice);
483 if (netDevice ==
nullptr)
488 return netDevice->GetScheduler(bwpIndex);
505 const std::vector<std::reference_wrapper<BandwidthPartInfoPtr>>& allBwps)
507 NS_LOG_FUNCTION(
this);
509 NetDeviceContainer devices;
510 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
513 Ptr<NetDevice> device = InstallSingleUeDevice(node, allBwps);
514 device->SetAddress(Mac48Address::Allocate());
522 const std::vector<std::reference_wrapper<BandwidthPartInfoPtr>> allBwps)
524 NS_LOG_FUNCTION(
this);
526 NetDeviceContainer devices;
527 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
530 Ptr<NetDevice> device = InstallSingleGnbDevice(node, allBwps);
531 device->SetAddress(Mac48Address::Allocate());
540 for (uint32_t i = 0; i < netDevs.GetN(); i++)
542 auto ueNetDev = DynamicCast<NrUeNetDevice>(netDevs.Get(i));
543 auto gnbNetDev = DynamicCast<NrGnbNetDevice>(netDevs.Get(i));
546 ueNetDev->UpdateConfig();
550 gnbNetDev->UpdateConfig();
556NrHelper::CreateUeMac()
const
558 NS_LOG_FUNCTION(
this);
559 Ptr<NrUeMac> mac = m_ueMacFactory.Create<
NrUeMac>();
564NrHelper::CreateUePhy(
const Ptr<Node>& n,
565 const std::unique_ptr<BandwidthPartInfo>& bwp,
566 const Ptr<NrUeNetDevice>& dev,
570 NS_LOG_FUNCTION(
this);
572 Ptr<NrUePhy> phy = m_uePhyFactory.Create<NrUePhy>();
574 NS_ASSERT(bwp->m_channel !=
nullptr);
576 phy->InstallCentralFrequency(bwp->m_centralFrequency);
578 phy->ScheduleStartEventLoop(n->GetId(), 0, 0, 0);
581 Ptr<NrChAccessManager> cam =
582 DynamicCast<NrChAccessManager>(m_ueChannelAccessManagerFactory.Create());
587 Ptr<MobilityModel> mm = n->GetObject<MobilityModel>();
590 "MobilityModel needs to be set on node before calling NrHelper::InstallUeDevice ()");
592 Ptr<NrSpectrumPhy> channelPhy =
593 m_ueSpectrumFactory.Create<NrSpectrumPhy>();
595 Ptr<NrHarqPhy> harq = Create<NrHarqPhy>();
596 channelPhy->InstallHarqPhyModule(harq);
597 channelPhy->SetPhyDlHarqFeedbackCallback(dlHarqCallback);
599 channelPhy->SetIsGnb(
false);
600 channelPhy->SetDevice(dev);
602 Ptr<UniformPlanarArray> antenna =
603 m_ueAntennaFactory.Create<UniformPlanarArray>();
604 channelPhy->SetAntenna(antenna);
606 cam->SetNrSpectrumPhy(channelPhy);
608 Ptr<NrChunkProcessor> pData = Create<NrChunkProcessor>();
610 channelPhy->AddDataSinrChunkProcessor(pData);
612 Ptr<NrMimoChunkProcessor> pDataMimo{
nullptr};
613 if (bwp->m_3gppChannel)
615 pDataMimo = Create<NrMimoChunkProcessor>();
617 channelPhy->AddDataMimoChunkProcessor(pDataMimo);
619 if (bwp->m_3gppChannel && m_enableMimoFeedback)
630 Ptr<NrChunkProcessor> pRs = Create<NrChunkProcessor>();
632 channelPhy->AddRsPowerChunkProcessor(pRs);
634 Ptr<NrChunkProcessor> pSinr = Create<NrChunkProcessor>();
636 channelPhy->AddDlCtrlSinrChunkProcessor(pSinr);
638 channelPhy->SetChannel(bwp->m_channel);
639 channelPhy->InstallPhy(phy);
640 channelPhy->SetMobility(mm);
642 channelPhy->SetPhyRxCtrlEndOkCallback(phyRxCtrlCallback);
645 Ptr<BeamManager> beamManager = m_ueBeamManagerFactory.Create<BeamManager>();
646 beamManager->Configure(antenna);
647 channelPhy->SetBeamManager(beamManager);
648 phy->InstallSpectrumPhy(channelPhy);
653NrHelper::InstallSingleUeDevice(
655 const std::vector<std::reference_wrapper<BandwidthPartInfoPtr>> allBwps)
657 NS_LOG_FUNCTION(
this);
659 Ptr<NrUeNetDevice> dev = m_ueNetDeviceFactory.Create<NrUeNetDevice>();
662 std::map<uint8_t, Ptr<BandwidthPartUe>> ueCcMap;
665 for (uint32_t bwpId = 0; bwpId < allBwps.size(); ++bwpId)
667 Ptr<BandwidthPartUe> cc = CreateObject<BandwidthPartUe>();
668 double bwInKhz = allBwps[bwpId].get()->m_channelBandwidth / 1000.0;
669 NS_ABORT_MSG_IF(bwInKhz / 100.0 > 65535.0,
670 "A bandwidth of " << bwInKhz / 100.0 <<
" kHz cannot be represented");
671 cc->SetUlBandwidth(
static_cast<uint16_t
>(bwInKhz / 100));
672 cc->SetDlBandwidth(
static_cast<uint16_t
>(bwInKhz / 100));
676 auto mac = CreateUeMac();
679 auto phy = CreateUePhy(
681 allBwps[bwpId].get(),
686 phy->SetBwpId(bwpId);
691 cc->SetAsPrimary(
true);
695 cc->SetAsPrimary(
false);
698 ueCcMap.insert(std::make_pair(bwpId, cc));
701 Ptr<NrUeComponentCarrierManager> ccmUe =
702 DynamicCast<NrUeComponentCarrierManager>(CreateObject<BwpManagerUe>());
703 DynamicCast<BwpManagerUe>(ccmUe)->SetBwpManagerAlgorithm(
704 m_ueBwpManagerAlgoFactory.Create<BwpManagerAlgorithm>());
706 Ptr<NrUeRrc> rrc = CreateObject<NrUeRrc>();
707 rrc->m_numberOfComponentCarriers = ueCcMap.size();
709 rrc->InitializeSap();
710 rrc->SetNrMacSapProvider(ccmUe->GetNrMacSapProvider());
712 rrc->SetNrCcmRrcSapProvider(ccmUe->GetNrCcmRrcSapProvider());
713 ccmUe->SetNrCcmRrcSapUser(rrc->GetNrCcmRrcSapUser());
714 ccmUe->SetNumberOfComponentCarriers(ueCcMap.size());
718 Ptr<NrUeRrcProtocolIdeal> rrcProtocol = CreateObject<NrUeRrcProtocolIdeal>();
719 rrcProtocol->SetUeRrc(rrc);
720 rrc->AggregateObject(rrcProtocol);
721 rrcProtocol->SetNrUeRrcSapProvider(rrc->GetNrUeRrcSapProvider());
722 rrc->SetNrUeRrcSapUser(rrcProtocol->GetNrUeRrcSapUser());
726 Ptr<nr::UeRrcProtocolReal> rrcProtocol = CreateObject<nr::UeRrcProtocolReal>();
727 rrcProtocol->SetUeRrc(rrc);
728 rrc->AggregateObject(rrcProtocol);
729 rrcProtocol->SetNrUeRrcSapProvider(rrc->GetNrUeRrcSapProvider());
730 rrc->SetNrUeRrcSapUser(rrcProtocol->GetNrUeRrcSapUser());
733 if (m_nrEpcHelper !=
nullptr)
735 rrc->SetUseRlcSm(
false);
739 rrc->SetUseRlcSm(
true);
741 Ptr<NrEpcUeNas> nas = CreateObject<NrEpcUeNas>();
743 nas->SetAsSapProvider(rrc->GetAsSapProvider());
745 nas->SetForwardUpCallback(MakeCallback(&NrUeNetDevice::Receive, dev));
747 rrc->SetAsSapUser(nas->GetAsSapUser());
749 for (
auto& it : ueCcMap)
751 rrc->SetNrUeCmacSapProvider(it.second->GetMac()->GetUeCmacSapProvider(), it.first);
752 it.second->GetMac()->SetUeCmacSapUser(rrc->GetNrUeCmacSapUser(it.first));
754 it.second->GetPhy()->SetUeCphySapUser(rrc->GetNrUeCphySapUser());
755 rrc->SetNrUeCphySapProvider(it.second->GetPhy()->GetUeCphySapProvider(), it.first);
757 it.second->GetPhy()->SetPhySapUser(it.second->GetMac()->GetPhySapUser());
758 it.second->GetMac()->SetPhySapProvider(it.second->GetPhy()->GetPhySapProvider());
761 ccmUe->SetComponentCarrierMacSapProviders(it.first,
762 it.second->GetMac()->GetUeMacSapProvider());
766 NS_FATAL_ERROR(
"Error in SetComponentCarrierMacSapProviders");
770 dev->SetAttribute(
"Imsi", UintegerValue(n->GetId()));
771 dev->SetCcMap(ueCcMap);
772 dev->SetAttribute(
"nrUeRrc", PointerValue(rrc));
773 dev->SetAttribute(
"NrEpcUeNas", PointerValue(nas));
774 dev->SetAttribute(
"NrUeComponentCarrierManager", PointerValue(ccmUe));
778 if (m_nrEpcHelper !=
nullptr)
780 m_nrEpcHelper->AddUe(dev, dev->GetImsi());
788NrHelper::CreateGnbPhy(
const Ptr<Node>& n,
789 const std::unique_ptr<BandwidthPartInfo>& bwp,
790 const Ptr<NrGnbNetDevice>& dev,
793 NS_LOG_FUNCTION(
this);
795 Ptr<NrGnbPhy> phy = m_gnbPhyFactory.Create<NrGnbPhy>();
797 DoubleValue frequency;
798 phy->InstallCentralFrequency(bwp->m_centralFrequency);
800 phy->ScheduleStartEventLoop(n->GetId(), 0, 0, 0);
803 Ptr<NrChAccessManager> cam =
804 DynamicCast<NrChAccessManager>(m_gnbChannelAccessManagerFactory.Create());
808 Ptr<MobilityModel> mm = n->GetObject<MobilityModel>();
811 "MobilityModel needs to be set on node before calling NrHelper::InstallGnbDevice ()");
813 Ptr<NrSpectrumPhy> channelPhy = m_gnbSpectrumFactory.Create<NrSpectrumPhy>();
814 Ptr<UniformPlanarArray> antenna = m_gnbAntennaFactory.Create<UniformPlanarArray>();
815 channelPhy->SetAntenna(antenna);
816 cam->SetNrSpectrumPhy(channelPhy);
818 channelPhy->InstallHarqPhyModule(
819 Create<NrHarqPhy>());
820 channelPhy->SetIsGnb(
true);
821 channelPhy->SetDevice(dev);
822 channelPhy->SetChannel(
825 channelPhy->InstallPhy(phy);
827 Ptr<NrChunkProcessor> pData =
828 Create<NrChunkProcessor>();
829 Ptr<NrChunkProcessor> pSrs =
830 Create<NrChunkProcessor>();
843 if (bwp->m_3gppChannel)
845 auto pDataMimo = Create<NrMimoChunkProcessor>();
846 pDataMimo->AddCallback(
848 channelPhy->AddDataMimoChunkProcessor(pDataMimo);
851 channelPhy->AddDataSinrChunkProcessor(pData);
852 channelPhy->AddSrsSinrChunkProcessor(pSrs);
853 channelPhy->SetMobility(mm);
854 channelPhy->SetPhyRxDataEndOkCallback(
856 channelPhy->SetPhyRxCtrlEndOkCallback(phyEndCtrlCallback);
858 channelPhy->SetPhyUlHarqFeedbackCallback(
861 Ptr<BeamManager> beamManager = m_gnbBeamManagerFactory.Create<BeamManager>();
862 beamManager->Configure(antenna);
863 channelPhy->SetBeamManager(beamManager);
864 phy->InstallSpectrumPhy(channelPhy);
870NrHelper::CreateGnbMac()
872 NS_LOG_FUNCTION(
this);
874 Ptr<NrGnbMac> mac = m_gnbMacFactory.Create<NrGnbMac>();
879NrHelper::CreateGnbSched()
881 NS_LOG_FUNCTION(
this);
883 auto sched = m_schedFactory.Create<NrMacSchedulerNs3>();
884 auto dlAmc = m_gnbDlAmcFactory.Create<NrAmc>();
885 auto ulAmc = m_gnbUlAmcFactory.Create<NrAmc>();
887 sched->InstallDlAmc(dlAmc);
888 sched->InstallUlAmc(ulAmc);
894NrHelper::InstallSingleGnbDevice(
896 const std::vector<std::reference_wrapper<BandwidthPartInfoPtr>> allBwps)
898 NS_ABORT_MSG_IF(m_cellIdCounter == 65535,
"max num gNBs exceeded");
900 Ptr<NrGnbNetDevice> dev = m_gnbNetDeviceFactory.Create<NrGnbNetDevice>();
902 NS_LOG_DEBUG(
"Creating gNB, cellId = " << m_cellIdCounter);
903 uint16_t cellId = m_cellIdCounter;
904 m_cellIdCounter += allBwps.empty();
905 dev->SetCellId(cellId);
909 std::map<uint8_t, Ptr<BandwidthPartGnb>> ccMap;
911 for (uint32_t bwpId = 0; bwpId < allBwps.size(); ++bwpId)
913 NS_LOG_DEBUG(
"Creating BandwidthPart, id = " << bwpId);
914 Ptr<BandwidthPartGnb> cc = CreateObject<BandwidthPartGnb>();
915 double bwInKhz = allBwps[bwpId].get()->m_channelBandwidth / 1000.0;
916 NS_ABORT_MSG_IF(bwInKhz / 100.0 > 65535.0,
917 "A bandwidth of " << bwInKhz / 100.0 <<
" kHz cannot be represented");
919 cc->SetUlBandwidth(
static_cast<uint16_t
>(bwInKhz / 100));
920 cc->SetDlBandwidth(
static_cast<uint16_t
>(bwInKhz / 100));
923 cc->SetCellId(m_cellIdCounter);
926 auto phy = CreateGnbPhy(
928 allBwps[bwpId].get(),
931 phy->SetBwpId(bwpId);
934 auto mac = CreateGnbMac();
936 phy->GetCam()->SetNrGnbMac(mac);
938 auto sched = CreateGnbSched();
939 cc->SetNrMacScheduler(sched);
943 cc->SetAsPrimary(
true);
947 cc->SetAsPrimary(
false);
950 ccMap.insert(std::make_pair(bwpId, cc));
953 Ptr<NrGnbRrc> rrc = CreateObject<NrGnbRrc>();
954 Ptr<NrGnbComponentCarrierManager> ccmGnbManager =
955 DynamicCast<NrGnbComponentCarrierManager>(CreateObject<BwpManagerGnb>());
956 DynamicCast<BwpManagerGnb>(ccmGnbManager)
957 ->SetBwpManagerAlgorithm(m_gnbBwpManagerAlgoFactory.Create<BwpManagerAlgorithm>());
962 std::map<uint8_t, Ptr<BandwidthPartGnb>> ccPhyConfMap;
963 for (
const auto& i : ccMap)
965 Ptr<BandwidthPartGnb> c = i.second;
966 ccPhyConfMap.insert(std::make_pair(i.first, c));
970 rrc->SetNrCcmRrcSapProvider(ccmGnbManager->GetNrCcmRrcSapProvider());
971 ccmGnbManager->SetNrCcmRrcSapUser(rrc->GetNrCcmRrcSapUser());
975 ccmGnbManager->SetNumberOfComponentCarriers(ccMap.size());
976 rrc->ConfigureCarriers(ccPhyConfMap);
981 Ptr<NrGnbRrcProtocolIdeal> rrcProtocol = CreateObject<NrGnbRrcProtocolIdeal>();
982 rrcProtocol->SetNrGnbRrcSapProvider(rrc->GetNrGnbRrcSapProvider());
983 rrc->SetNrGnbRrcSapUser(rrcProtocol->GetNrGnbRrcSapUser());
984 rrc->AggregateObject(rrcProtocol);
988 Ptr<nr::NrGnbRrcProtocolReal> rrcProtocol = CreateObject<nr::NrGnbRrcProtocolReal>();
989 rrcProtocol->SetNrGnbRrcSapProvider(rrc->GetNrGnbRrcSapProvider());
990 rrc->SetNrGnbRrcSapUser(rrcProtocol->GetNrGnbRrcSapUser());
991 rrc->AggregateObject(rrcProtocol);
994 if (m_nrEpcHelper !=
nullptr)
996 EnumValue<NrGnbRrc::NrEpsBearerToRlcMapping_t> epsBearerToRlcMapping;
997 rrc->GetAttribute(
"EpsBearerToRlcMapping", epsBearerToRlcMapping);
999 if (epsBearerToRlcMapping.Get() == NrGnbRrc::RLC_SM_ALWAYS)
1001 rrc->SetAttribute(
"EpsBearerToRlcMapping", EnumValue(NrGnbRrc::RLC_UM_ALWAYS));
1014 rrc->SetNrMacSapProvider(ccmGnbManager->GetNrMacSapProvider());
1015 rrc->SetForwardUpCallback(MakeCallback(&NrGnbNetDevice::Receive, dev));
1017 for (
auto& it : ccMap)
1019 it.second->GetPhy()->SetGnbCphySapUser(rrc->GetNrGnbCphySapUser(it.first));
1020 rrc->SetNrGnbCphySapProvider(it.second->GetPhy()->GetGnbCphySapProvider(), it.first);
1022 rrc->SetNrGnbCmacSapProvider(it.second->GetMac()->GetGnbCmacSapProvider(), it.first);
1023 it.second->GetMac()->SetGnbCmacSapUser(rrc->GetNrGnbCmacSapUser(it.first));
1026 it.second->GetPhy()->SetPhySapUser(it.second->GetMac()->GetPhySapUser());
1027 it.second->GetMac()->SetPhySapProvider(it.second->GetPhy()->GetPhySapProvider());
1031 it.second->GetMac()->SetNrMacSchedSapProvider(
1032 it.second->GetScheduler()->GetMacSchedSapProvider());
1033 it.second->GetMac()->SetNrMacCschedSapProvider(
1034 it.second->GetScheduler()->GetMacCschedSapProvider());
1036 it.second->GetScheduler()->SetMacSchedSapUser(it.second->GetMac()->GetNrMacSchedSapUser());
1037 it.second->GetScheduler()->SetMacCschedSapUser(
1038 it.second->GetMac()->GetNrMacCschedSapUser());
1041 it.second->GetMac()->SetNrCcmMacSapUser(ccmGnbManager->GetNrCcmMacSapUser());
1042 ccmGnbManager->SetCcmMacSapProviders(it.first,
1043 it.second->GetMac()->GetNrCcmMacSapProvider());
1047 ccmGnbManager->SetMacSapProvider(it.first, it.second->GetMac()->GetMacSapProvider());
1050 dev->SetAttribute(
"NrGnbComponentCarrierManager", PointerValue(ccmGnbManager));
1051 dev->SetCcMap(ccMap);
1052 dev->SetAttribute(
"NrGnbRrc", PointerValue(rrc));
1057 if (m_nrEpcHelper !=
nullptr)
1059 NS_LOG_INFO(
"adding this gNB to the EPC");
1060 m_nrEpcHelper->AddGnb(n, dev, dev->GetCellIds());
1061 Ptr<NrEpcGnbApplication> gnbApp = n->GetApplication(0)->GetObject<NrEpcGnbApplication>();
1062 NS_ASSERT_MSG(gnbApp !=
nullptr,
"cannot retrieve NrEpcGnbApplication");
1065 rrc->SetS1SapProvider(gnbApp->GetS1SapProvider());
1066 gnbApp->SetS1SapUser(rrc->GetS1SapUser());
1069 Ptr<NrEpcX2> x2 = n->GetObject<NrEpcX2>();
1070 x2->SetEpcX2SapUser(rrc->GetEpcX2SapUser());
1071 rrc->SetEpcX2SapProvider(x2->GetEpcX2SapProvider());
1077NrHelper::GetHandoverAlgorithmType()
const
1079 return m_handoverAlgorithmFactory.GetTypeId().GetName();
1083NrHelper::SetHandoverAlgorithmType(std::string type)
1085 NS_LOG_FUNCTION(
this << type);
1086 m_handoverAlgorithmFactory = ObjectFactory();
1087 m_handoverAlgorithmFactory.SetTypeId(type);
1091NrHelper::SetHandoverAlgorithmAttribute(std::string n,
const AttributeValue& v)
1093 NS_LOG_FUNCTION(
this << n);
1094 m_handoverAlgorithmFactory.Set(n, v);
1098NrHelper::AddX2Interface(NodeContainer gnbNodes)
1100 NS_LOG_FUNCTION(
this);
1102 NS_ASSERT_MSG(m_nrEpcHelper,
"X2 interfaces cannot be set up when the EPC is not used");
1104 for (
auto i = gnbNodes.Begin(); i != gnbNodes.End(); ++i)
1106 for (
auto j = i + 1; j != gnbNodes.End(); ++j)
1108 AddX2Interface(*i, *j);
1114NrHelper::AddX2Interface(Ptr<Node> gnbNode1, Ptr<Node> gnbNode2)
1116 NS_LOG_FUNCTION(
this);
1117 NS_LOG_INFO(
"setting up the X2 interface");
1119 m_nrEpcHelper->AddX2Interface(gnbNode1, gnbNode2);
1123NrHelper::HandoverRequest(Time hoTime,
1124 Ptr<NetDevice> ueDev,
1125 Ptr<NetDevice> sourceGnbDev,
1126 Ptr<NetDevice> targetGnbDev)
1128 NS_LOG_FUNCTION(
this << ueDev << sourceGnbDev << targetGnbDev);
1129 NS_ASSERT_MSG(m_nrEpcHelper,
1130 "Handover requires the use of the EPC - did you forget to call "
1131 "NrHelper::SetEpcHelper () ?");
1132 uint16_t targetCellId = targetGnbDev->GetObject<NrGnbNetDevice>()->GetCellId();
1133 Simulator::Schedule(hoTime,
1134 &NrHelper::DoHandoverRequest,
1142NrHelper::HandoverRequest(Time hoTime,
1143 Ptr<NetDevice> ueDev,
1144 Ptr<NetDevice> sourceGnbDev,
1145 uint16_t targetCellId)
1147 NS_LOG_FUNCTION(
this << ueDev << sourceGnbDev << targetCellId);
1148 NS_ASSERT_MSG(m_nrEpcHelper,
1149 "Handover requires the use of the EPC - did you forget to call "
1150 "NrHelper::SetEpcHelper () ?");
1151 Simulator::Schedule(hoTime,
1152 &NrHelper::DoHandoverRequest,
1160NrHelper::DoHandoverRequest(Ptr<NetDevice> ueDev,
1161 Ptr<NetDevice> sourceGnbDev,
1162 uint16_t targetCellId)
1164 NS_LOG_FUNCTION(
this << ueDev << sourceGnbDev << targetCellId);
1166 Ptr<NrGnbRrc> sourceRrc = sourceGnbDev->GetObject<NrGnbNetDevice>()->GetRrc();
1167 uint16_t rnti = ueDev->GetObject<NrUeNetDevice>()->GetRrc()->GetRnti();
1168 sourceRrc->SendHandoverRequest(rnti, targetCellId);
1174 NS_LOG_FUNCTION(
this);
1176 for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); i++)
1185 NS_LOG_FUNCTION(
this);
1186 NS_ASSERT_MSG(gnbDevices.GetN() > 0,
"empty gnb device container");
1187 Vector uepos = ueDevice->GetNode()->GetObject<MobilityModel>()->GetPosition();
1188 double minDistance = std::numeric_limits<double>::infinity();
1189 Ptr<NetDevice> closestGnbDevice;
1190 for (NetDeviceContainer::Iterator i = gnbDevices.Begin(); i != gnbDevices.End(); ++i)
1192 Vector gnbpos = (*i)->GetNode()->GetObject<MobilityModel>()->GetPosition();
1193 double distance = CalculateDistance(uepos, gnbpos);
1194 if (distance < minDistance)
1196 minDistance = distance;
1197 closestGnbDevice = *i;
1200 NS_ASSERT(closestGnbDevice);
1208 Ptr<NrGnbNetDevice> gnbNetDev = gnbDevice->GetObject<
NrGnbNetDevice>();
1209 Ptr<NrUeNetDevice> ueNetDev = ueDevice->GetObject<
NrUeNetDevice>();
1211 NS_ABORT_IF(gnbNetDev ==
nullptr || ueNetDev ==
nullptr);
1213 for (uint32_t i = 0; i < gnbNetDev->GetCcMapSize(); ++i)
1215 gnbNetDev->GetPhy(i)->RegisterUe(ueNetDev->GetImsi(), ueNetDev);
1216 ueNetDev->GetPhy(i)->RegisterToGnb(gnbNetDev->GetBwpId(i));
1217 ueNetDev->GetPhy(i)->SetDlAmc(
1218 DynamicCast<NrMacSchedulerNs3>(gnbNetDev->GetScheduler(i))->GetDlAmc());
1219 ueNetDev->GetPhy(i)->SetDlCtrlSyms(gnbNetDev->GetMac(i)->GetDlCtrlSyms());
1220 ueNetDev->GetPhy(i)->SetUlCtrlSyms(gnbNetDev->GetMac(i)->GetUlCtrlSyms());
1221 ueNetDev->GetPhy(i)->SetNumRbPerRbg(gnbNetDev->GetMac(i)->GetNumRbPerRbg());
1222 ueNetDev->GetPhy(i)->SetRbOverhead(gnbNetDev->GetPhy(i)->GetRbOverhead());
1223 ueNetDev->GetPhy(i)->SetSymbolsPerSlot(gnbNetDev->GetPhy(i)->GetSymbolsPerSlot());
1224 ueNetDev->GetPhy(i)->SetNumerology(gnbNetDev->GetPhy(i)->GetNumerology());
1225 ueNetDev->GetPhy(i)->SetPattern(gnbNetDev->GetPhy(i)->GetPattern());
1226 Ptr<NrEpcUeNas> ueNas = ueNetDev->GetNas();
1227 ueNas->Connect(gnbNetDev->GetBwpId(i), gnbNetDev->GetEarfcn(i));
1229 if (m_enableMimoFeedback)
1232 auto pmSearch = m_pmSearchFactory.Create<
NrPmSearch>();
1233 ueNetDev->GetPhy(i)->SetPmSearch(pmSearch);
1235 gnbNetDev->GetPhy(i)->GetSpectrumPhy()->GetAntenna()->GetObject<PhasedArrayModel>();
1237 ueNetDev->GetPhy(i)->GetSpectrumPhy()->GetAntenna()->GetObject<PhasedArrayModel>();
1239 gnbAnt->GetNumHorizontalPorts(),
1240 gnbAnt->GetNumVerticalPorts());
1241 pmSearch->SetUeParams(ueAnt->GetNumPorts());
1242 pmSearch->InitCodebooks();
1249 m_nrEpcHelper->ActivateEpsBearer(ueDevice,
1250 ueNetDev->GetImsi(),
1258 ueNetDev->SetTargetGnb(gnbNetDev);
1261 if (m_beamformingHelper)
1263 m_beamformingHelper->AddBeamformingTask(gnbNetDev, ueNetDev);
1272 NS_LOG_FUNCTION(
this);
1273 for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1284 NS_LOG_FUNCTION(
this);
1286 NS_ASSERT_MSG(m_nrEpcHelper,
"dedicated EPS bearers cannot be set up when the EPC is not used");
1288 uint64_t imsi = ueDevice->GetObject<
NrUeNetDevice>()->GetImsi();
1289 uint8_t bearerId = m_nrEpcHelper->ActivateEpsBearer(ueDevice, imsi, tft, bearer);
1295 Ptr<NetDevice> gnbDevice,
1298 NS_LOG_FUNCTION(
this << ueDevice << bearerId);
1299 NS_ASSERT_MSG(m_nrEpcHelper !=
nullptr,
1300 "Dedicated EPS bearers cannot be de-activated when the EPC is not used");
1301 NS_ASSERT_MSG(bearerId != 1,
1302 "Default bearer cannot be de-activated until and unless and UE is released");
1304 DoDeActivateDedicatedEpsBearer(ueDevice, gnbDevice, bearerId);
1310 NS_LOG_FUNCTION(
this);
1311 m_ueMacFactory.Set(n, v);
1317 NS_LOG_FUNCTION(
this);
1318 m_gnbMacFactory.Set(n, v);
1324 NS_LOG_FUNCTION(
this);
1325 m_gnbSpectrumFactory.Set(n, v);
1331 NS_LOG_FUNCTION(
this);
1332 m_ueSpectrumFactory.Set(n, v);
1338 NS_LOG_FUNCTION(
this);
1339 m_ueChannelAccessManagerFactory.Set(n, v);
1345 NS_LOG_FUNCTION(
this);
1346 m_gnbChannelAccessManagerFactory.Set(n, v);
1352 NS_LOG_FUNCTION(
this);
1353 m_schedFactory.Set(n, v);
1359 NS_LOG_FUNCTION(
this);
1360 m_uePhyFactory.Set(n, v);
1366 NS_LOG_FUNCTION(
this);
1367 m_gnbPhyFactory.Set(n, v);
1373 NS_LOG_FUNCTION(
this);
1374 m_ueAntennaFactory.Set(n, v);
1380 NS_LOG_FUNCTION(
this);
1381 m_gnbAntennaFactory.Set(n, v);
1387 NS_LOG_FUNCTION(
this);
1388 m_ueChannelAccessManagerFactory.SetTypeId(typeId);
1394 NS_LOG_FUNCTION(
this);
1395 m_gnbChannelAccessManagerFactory.SetTypeId(typeId);
1401 NS_LOG_FUNCTION(
this);
1402 m_schedFactory.SetTypeId(typeId);
1408 NS_LOG_FUNCTION(
this);
1409 m_ueBwpManagerAlgoFactory.SetTypeId(typeId);
1413NrHelper::SetPhasedArraySpectrumPropagationLossModelTypeId(
const TypeId& typeId)
1415 NS_LOG_FUNCTION(
this);
1416 m_spectrumPropagationFactory.SetTypeId(typeId);
1422 NS_LOG_FUNCTION(
this);
1423 m_ueBwpManagerAlgoFactory.Set(n, v);
1428 const AttributeValue& v)
1430 NS_LOG_FUNCTION(
this);
1431 m_spectrumPropagationFactory.Set(n, v);
1437 NS_LOG_FUNCTION(
this);
1438 m_channelConditionModelFactory.Set(n, v);
1444 NS_LOG_FUNCTION(
this);
1445 m_pathlossModelFactory.Set(n, v);
1451 NS_LOG_FUNCTION(
this);
1452 m_gnbDlAmcFactory.Set(n, v);
1458 NS_LOG_FUNCTION(
this);
1459 m_gnbUlAmcFactory.Set(n, v);
1463NrHelper::SetGnbBeamManagerAttribute(
const std::string& n,
const AttributeValue& v)
1465 NS_LOG_FUNCTION(
this);
1466 m_gnbBeamManagerFactory.Set(n, v);
1472 NS_LOG_FUNCTION(
this);
1473 m_gnbBeamManagerFactory.SetTypeId(typeId);
1479 NS_LOG_FUNCTION(
this);
1488 NS_LOG_FUNCTION(
this);
1497 int64_t currentStream = stream;
1498 Ptr<NetDevice> netDevice;
1499 for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i)
1502 Ptr<NrGnbNetDevice> nrGnb = DynamicCast<NrGnbNetDevice>(netDevice);
1505 for (uint32_t bwp = 0; bwp < nrGnb->GetCcMapSize(); bwp++)
1507 currentStream += nrGnb->GetPhy(bwp)->GetSpectrumPhy()->AssignStreams(currentStream);
1508 currentStream += nrGnb->GetScheduler(bwp)->AssignStreams(currentStream);
1510 DoAssignStreamsToChannelObjects(nrGnb->GetPhy(bwp)->GetSpectrumPhy(),
1515 Ptr<NrUeNetDevice> nrUe = DynamicCast<NrUeNetDevice>(netDevice);
1518 for (uint32_t bwp = 0; bwp < nrUe->GetCcMapSize(); bwp++)
1520 currentStream += nrUe->GetPhy(bwp)->GetSpectrumPhy()->AssignStreams(currentStream);
1521 currentStream += nrUe->GetMac(bwp)->AssignStreams(currentStream);
1523 DoAssignStreamsToChannelObjects(nrUe->GetPhy(bwp)->GetSpectrumPhy(),
1529 return (currentStream - stream);
1533NrHelper::DoAssignStreamsToChannelObjects(Ptr<NrSpectrumPhy> phy, int64_t currentStream)
1535 int64_t initialStream = currentStream;
1537 Ptr<ThreeGppPropagationLossModel> propagationLossModel =
1538 DynamicCast<ThreeGppPropagationLossModel>(
1539 phy->GetSpectrumChannel()->GetPropagationLossModel());
1540 if (!propagationLossModel)
1543 phy->GetSpectrumChannel()->GetPropagationLossModel()->AssignStreams(currentStream);
1544 return currentStream - initialStream;
1547 if (std::find(m_channelObjectsWithAssignedStreams.begin(),
1548 m_channelObjectsWithAssignedStreams.end(),
1549 propagationLossModel) == m_channelObjectsWithAssignedStreams.end())
1551 currentStream += propagationLossModel->AssignStreams(currentStream);
1552 m_channelObjectsWithAssignedStreams.emplace_back(propagationLossModel);
1555 Ptr<ChannelConditionModel> channelConditionModel =
1556 propagationLossModel->GetChannelConditionModel();
1558 if (std::find(m_channelObjectsWithAssignedStreams.begin(),
1559 m_channelObjectsWithAssignedStreams.end(),
1560 channelConditionModel) == m_channelObjectsWithAssignedStreams.end())
1562 currentStream += channelConditionModel->AssignStreams(currentStream);
1563 m_channelObjectsWithAssignedStreams.emplace_back(channelConditionModel);
1566 Ptr<ThreeGppSpectrumPropagationLossModel> spectrumLossModel =
1567 DynamicCast<ThreeGppSpectrumPropagationLossModel>(
1568 phy->GetSpectrumChannel()->GetPhasedArraySpectrumPropagationLossModel());
1570 if (spectrumLossModel)
1572 if (std::find(m_channelObjectsWithAssignedStreams.begin(),
1573 m_channelObjectsWithAssignedStreams.end(),
1574 spectrumLossModel) == m_channelObjectsWithAssignedStreams.end())
1576 Ptr<ThreeGppChannelModel> channel =
1577 DynamicCast<ThreeGppChannelModel>(spectrumLossModel->GetChannelModel());
1578 currentStream += channel->AssignStreams(currentStream);
1579 m_channelObjectsWithAssignedStreams.emplace_back(spectrumLossModel);
1583 return currentStream - initialStream;
1589 NS_LOG_FUNCTION(
this);
1590 m_gnbBwpManagerAlgoFactory.SetTypeId(typeId);
1596 NS_LOG_FUNCTION(
this);
1597 m_gnbBwpManagerAlgoFactory.Set(n, v);
1601NrHelper::DoDeActivateDedicatedEpsBearer(Ptr<NetDevice> ueDevice,
1602 Ptr<NetDevice> gnbDevice,
1605 NS_LOG_FUNCTION(
this << ueDevice << bearerId);
1608 uint64_t imsi = ueDevice->GetObject<
NrUeNetDevice>()->GetImsi();
1609 uint16_t rnti = ueDevice->GetObject<
NrUeNetDevice>()->GetRrc()->GetRnti();
1611 Ptr<NrGnbRrc> gnbRrc = gnbDevice->GetObject<
NrGnbNetDevice>()->GetRrc();
1613 gnbRrc->DoSendReleaseDataRadioBearer(imsi, rnti, bearerId);
1625 m_beamformingHelper = beamformingHelper;
1626 m_beamformingHelper->Initialize();
1629class NrDrbActivator :
public SimpleRefCount<NrDrbActivator>
1632 NrDrbActivator(Ptr<NetDevice> ueDevice,
NrEpsBearer bearer);
1633 static void ActivateCallback(Ptr<NrDrbActivator> a,
1634 std::string context,
1638 void ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti);
1642 Ptr<NetDevice> m_ueDevice;
1647NrDrbActivator::NrDrbActivator(Ptr<NetDevice> ueDevice, NrEpsBearer bearer)
1649 m_ueDevice(ueDevice),
1651 m_imsi(m_ueDevice->GetObject<NrUeNetDevice>()->GetImsi())
1656NrDrbActivator::ActivateCallback(Ptr<NrDrbActivator> a,
1657 std::string context,
1662 NS_LOG_FUNCTION(a << context << imsi << cellId << rnti);
1663 a->ActivateDrb(imsi, cellId, rnti);
1667NrDrbActivator::ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti)
1669 NS_LOG_FUNCTION(
this << imsi << cellId << rnti << m_active);
1670 if ((!m_active) && (imsi == m_imsi))
1672 Ptr<NrUeRrc> ueRrc = m_ueDevice->GetObject<NrUeNetDevice>()->GetRrc();
1673 NS_ASSERT(ueRrc->GetState() == NrUeRrc::CONNECTED_NORMALLY);
1674 uint16_t rnti = ueRrc->GetRnti();
1675 Ptr<const NrGnbNetDevice> nrGnbDevice =
1676 m_ueDevice->GetObject<NrUeNetDevice>()->GetTargetGnb();
1677 Ptr<NrGnbRrc> gnbRrc = nrGnbDevice->GetObject<NrGnbNetDevice>()->GetRrc();
1678 NS_ASSERT(gnbRrc->HasCellId(ueRrc->GetCellId()));
1679 Ptr<NrUeManager> ueManager = gnbRrc->GetUeManager(rnti);
1680 NS_ASSERT(ueManager->GetState() == NrUeManager::CONNECTED_NORMALLY ||
1681 ueManager->GetState() == NrUeManager::CONNECTION_RECONFIGURATION);
1682 NrEpcGnbS1SapUser::DataRadioBearerSetupRequestParameters params;
1684 params.bearer = m_bearer;
1685 params.bearerId = 0;
1687 gnbRrc->GetS1SapUser()->DataRadioBearerSetupRequest(params);
1695 NS_LOG_FUNCTION(
this);
1696 for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1705 NS_LOG_FUNCTION(
this << ueDevice);
1706 NS_ASSERT_MSG(!m_nrEpcHelper,
"this method must not be used when the EPC is being used");
1713 Ptr<const NrGnbNetDevice> nrGnbDevice = ueDevice->GetObject<
NrUeNetDevice>()->GetTargetGnb();
1715 std::ostringstream path;
1716 path <<
"/NodeList/" << nrGnbDevice->GetNode()->GetId() <<
"/DeviceList/"
1717 << nrGnbDevice->GetIfIndex() <<
"/NrGnbRrc/ConnectionEstablished";
1718 Ptr<NrDrbActivator> arg = Create<NrDrbActivator>(ueDevice, bearer);
1719 Config::Connect(path.str(), MakeBoundCallback(&NrDrbActivator::ActivateCallback, arg));
1749 m_phyStats = CreateObject<NrPhyRxTrace>();
1759 m_macStats = CreateObject<NrMacRxTrace>();
1767 NS_LOG_FUNCTION(
this);
1768 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/DlDataSinr",
1772 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/SpectrumPhy/RxPacketTraceUe",
1773 MakeBoundCallback(&NrPhyRxTrace::RxPacketTraceUeCallback,
GetPhyRxTrace()));
1779 NS_LOG_FUNCTION(
this);
1780 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/DlCtrlSinr",
1787 NS_LOG_FUNCTION(
this);
1788 Config::Connect(
"/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbPhy/GnbPhyRxedCtrlMsgsTrace",
1790 Config::Connect(
"/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbPhy/GnbPhyTxedCtrlMsgsTrace",
1797 NS_LOG_FUNCTION(
this);
1798 Config::Connect(
"/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbMac/GnbMacRxedCtrlMsgsTrace",
1800 Config::Connect(
"/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbMac/GnbMacTxedCtrlMsgsTrace",
1807 NS_LOG_FUNCTION(
this);
1809 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/UePhyRxedCtrlMsgsTrace",
1812 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/UePhyTxedCtrlMsgsTrace",
1814 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/UePhyRxedDlDciTrace",
1817 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/UePhyTxedHarqFeedbackTrace",
1824 NS_LOG_FUNCTION(
this);
1826 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUeMac/UeMacRxedCtrlMsgsTrace",
1829 "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUeMac/UeMacTxedCtrlMsgsTrace",
1836 NS_LOG_FUNCTION(
this);
1838 "/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbPhy/SpectrumPhy/RxPacketTraceGnb",
1839 MakeBoundCallback(&NrPhyRxTrace::RxPacketTraceGnbCallback,
GetPhyRxTrace()));
1845 NS_LOG_FUNCTION(
this);
1847 "/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbPhy/SpectrumPhy/ReportGnbTxRxPacketCount",
1848 MakeBoundCallback(&NrPhyRxTrace::ReportPacketCountGnbCallback,
GetPhyRxTrace()));
1854 NS_LOG_FUNCTION(
this);
1855 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/SpectrumPhy/"
1856 "ReportUeTxRxPacketCount",
1857 MakeBoundCallback(&NrPhyRxTrace::ReportPacketCountUeCallback,
GetPhyRxTrace()));
1863 NS_LOG_FUNCTION(
this);
1864 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/ReportDownlinkTbSize",
1865 MakeBoundCallback(&NrPhyRxTrace::ReportDownLinkTBSize,
GetPhyRxTrace()));
1871 NS_LOG_FUNCTION(
this);
1872 Ptr<NrBearerStatsSimple> rlcStats = CreateObject<NrBearerStatsSimple>(
"RLC");
1873 m_radioBearerStatsConnectorSimpleTraces.
EnableRlcStats(rlcStats);
1879 NS_LOG_FUNCTION(
this);
1880 Ptr<NrBearerStatsSimple> pdcpStats = CreateObject<NrBearerStatsSimple>(
"PDCP");
1887 NS_LOG_FUNCTION(
this);
1888 Ptr<NrBearerStatsCalculator> rlcStats = CreateObject<NrBearerStatsCalculator>(
"RLC");
1895 NS_LOG_FUNCTION(
this);
1896 Ptr<NrBearerStatsCalculator> pdcpStats = CreateObject<NrBearerStatsCalculator>(
"PDCP");
1900Ptr<NrBearerStatsCalculator>
1903 return DynamicCast<NrBearerStatsCalculator>(
1904 m_radioBearerStatsConnectorCalculator.
GetRlcStats());
1907Ptr<NrBearerStatsCalculator>
1910 return DynamicCast<NrBearerStatsCalculator>(
1917 NS_LOG_FUNCTION(
this);
1918 if (!m_macSchedStats)
1920 m_macSchedStats = CreateObject<NrMacSchedulingStats>();
1923 "/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbMac/DlScheduling",
1930 NS_LOG_FUNCTION(
this);
1931 if (!m_macSchedStats)
1933 m_macSchedStats = CreateObject<NrMacSchedulingStats>();
1936 "/NodeList/*/DeviceList/*/BandwidthPartMap/*/NrGnbMac/UlScheduling",
1943 NS_LOG_FUNCTION(
this);
1944 Config::Connect(
"/ChannelList/*/$ns3::SpectrumChannel/PathLoss",
1949NrHelper::EnableDlCtrlPathlossTraces(NetDeviceContainer& ueDevs)
1951 NS_LOG_FUNCTION(
this);
1953 for (uint32_t i = 0; i < ueDevs.GetN(); i++)
1955 Ptr<NrUeNetDevice> ueDev = DynamicCast<NrUeNetDevice>(ueDevs.Get(i));
1956 NS_ASSERT_MSG(ueDev,
1957 "To EnableDlCtrlPathlossTracesfunction is passed device "
1958 "container that contains non UE devices.");
1959 for (uint32_t j = 0; j < ueDev->GetCcMapSize(); j++)
1961 Ptr<NrUePhy> nrUePhy = ueDev->GetPhy(j);
1962 Ptr<NrSpectrumPhy> nrSpectrumPhy = nrUePhy->GetSpectrumPhy();
1963 nrSpectrumPhy->EnableDlCtrlPathlossTrace();
1967 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/NrSpectrumPhy/"
1973NrHelper::EnableDlDataPathlossTraces(NetDeviceContainer& ueDevs)
1975 NS_LOG_FUNCTION(
this);
1977 NS_ASSERT_MSG(ueDevs.GetN(),
1978 "Passed an empty UE net device container EnableDlDataPathlossTraces function");
1980 for (uint32_t i = 0; i < ueDevs.GetN(); i++)
1982 Ptr<NrUeNetDevice> ueDev = DynamicCast<NrUeNetDevice>(ueDevs.Get(i));
1983 NS_ASSERT_MSG(ueDev,
1984 "To EnableDlDataPathlossTracesfunction is passed device "
1985 "container that contains non UE devices.");
1986 for (uint32_t j = 0; j < ueDev->GetCcMapSize(); j++)
1988 Ptr<NrUePhy> nrUePhy = ueDev->GetPhy(j);
1989 Ptr<NrSpectrumPhy> nrSpectrumPhy = nrUePhy->GetSpectrumPhy();
1990 nrSpectrumPhy->EnableDlDataPathlossTrace();
1994 Config::Connect(
"/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/NrUePhy/NrSpectrumPhy/"
2002 m_pmSearchFactory.SetTypeId(typeId);
2008 NS_LOG_FUNCTION(
this);
2009 m_pmSearchFactory.Set(name, value);
2016 "The number of horizontal ports of gNB must divide number of element columns");
2018 "The number of vertical ports of gNB must divide number of element rows");
2020 auto antFactory = ObjectFactory{};
2036 "The number of horizontal ports of UE must divide number of element columns");
2038 "The number of vertical ports of UE must divide number of element rows");
2040 auto antFactory = ObjectFactory{};
2056 SetAttribute(
"EnableMimoFeedback", BooleanValue(
true));
static TypeId GetTypeId()
GetTypeId.
static TypeId GetTypeId()
GetTypeId.
Manages the correct creation of operation bands, component carriers and bandwidth parts.
OperationBandInfo CreateOperationBandContiguousCc(const SimpleOperationBandConf &conf)
Create an operation band with the CC specified.
static BandwidthPartInfoPtrVector GetAllBwps(const std::vector< std::reference_wrapper< OperationBandInfo > > &operationBands)
Get all the BWP pointers from the specified vector of operation bands.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
GetTypeId.
Ptr< NrBearerStatsBase > GetPdcpStats()
void EnablePdcpStats(Ptr< NrBearerStatsBase > pdcpStats)
void EnableRlcStats(Ptr< NrBearerStatsBase > rlcStats)
Ptr< NrBearerStatsBase > GetRlcStats()
Base helper class to handle the creation of the EPC entities.
static Ptr< NrEpcTft > Default()
This class contains the specification of EPS Bearers.
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
static TypeId GetTypeId()
Get the TypeId.
The NrGnbNetDevice class.
void RouteIngoingCtrlMsgs(const std::list< Ptr< NrControlMessage > > &msgList, uint8_t sourceBwpId)
The gNB received a CTRL message list.
void GenerateDataCqiReport(const SpectrumValue &sinr)
Generate a DL CQI report.
void ReportUlHarqFeedback(const UlHarqInfo &mes)
Get the HARQ feedback from NrSpectrumPhy and forward it to the scheduler.
void PhyDataPacketReceived(const Ptr< Packet > &p)
Receive a PHY data packet.
static TypeId GetTypeId()
Get Type id.
void EnableDlDataPhyTraces()
Enable DL DATA PHY traces.
static Ptr< BwpManagerGnb > GetBwpManagerGnb(const Ptr< NetDevice > &gnbDevice)
Get the BwpManager of the GNB.
void AttachToClosestGnb(NetDeviceContainer ueDevices, NetDeviceContainer gnbDevices)
Attach the UE specified to the closest GNB.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, NrEpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices.
void SetPhasedArraySpectrumPropagationLossModelAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the PhasedArraySpectrumPropagationLossModel before it is created.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
void UpdateDeviceConfigs(const NetDeviceContainer &netDevs)
Update netdevice configuration of one or more UEs and/or gNBs.
static Ptr< NrUeMac > GetUeMac(const Ptr< NetDevice > &ueDevice, uint32_t bwpIndex)
Get a pointer to the MAC of the UE at the specified BWP.
void EnableTraces()
Enables the following traces: Transmitted/Received Control Messages DL/UL Phy Traces RLC traces PDCP ...
NetDeviceContainer InstallGnbDevice(const NodeContainer &c, const std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > allBwps)
Install one (or more) GNBs.
void SetBeamformingHelper(Ptr< BeamformingHelperBase > beamformingHelper)
Set an ideal beamforming helper.
void SetGnbDlAmcAttribute(const std::string &n, const AttributeValue &v)
NrHelper()
NrHelper constructor.
Ptr< NrBearerStatsCalculator > GetPdcpStatsCalculator()
Get the PDCP stats calculator object.
void DeActivateDedicatedEpsBearer(Ptr< NetDevice > ueDevice, Ptr< NetDevice > gnbDevice, uint8_t bearerId)
Manually trigger dedicated bearer de-activation at specific simulation time.
void EnableUePhyCtrlMsgsTraces()
Enable UE PHY CTRL TX and RX traces.
void EnableRlcSimpleTraces()
Enable RLC simple traces (DL RLC TX, DL RLC RX, UL DL TX, UL DL RX)
void SetUeAntennaAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the UE antenna, before it is created.
void SetUeChannelAccessManagerAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the UE channel access manager, before it is created.
bool GetSnrTest() const
GetSnrTest.
void EnableGnbPhyCtrlMsgsTraces()
Enable gNB PHY CTRL TX and RX traces.
~NrHelper() override
~NrHelper
void SetGnbBwpManagerAlgorithmTypeId(const TypeId &typeId)
Set the TypeId of the GNB BWP Manager. Works only before it is created.
static Ptr< BwpManagerUe > GetBwpManagerUe(const Ptr< NetDevice > &ueDevice)
Get the BwpManager of the UE.
void EnableDlMacSchedTraces()
std::pair< double, BandwidthPartInfoPtrVector > CreateBandwidthParts(std::vector< CcBwpCreator::SimpleOperationBandConf > bandConfs)
Create BandwidthParts from a vector of band configurations.
void SetUeMacAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the UE MAC, before it is created.
void SetUlErrorModel(const std::string &errorModelTypeId)
Set the ErrorModel for UL AMC and UE spectrum at the same time.
@ INIT_PROPAGATION
Initialize the propagation loss model.
@ INIT_FADING
Initialize the fading model.
@ INIT_CHANNEL
Initialize the channel model.
void SetUeBwpManagerAlgorithmTypeId(const TypeId &typeId)
Set the TypeId of the UE BWP Manager. Works only before it is created.
void EnableUlPhyTraces()
Enable UL PHY traces.
void EnablePathlossTraces()
Enable trace sinks for DL and UL pathloss.
Ptr< NrMacRxTrace > GetMacRxTrace()
Get the mac stats trace object.
void SetPmSearchAttribute(const std::string &name, const AttributeValue &value)
Set attribute of the precoding matrix search algorithm.
void SetGnbAntennaAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB antenna, before it is created.
void SetupGnbAntennas(const AntennaParams &ap)
Set parameters for gNB and UE antenna arrays.
static Ptr< NrGnbPhy > GetGnbPhy(const Ptr< NetDevice > &gnbDevice, uint32_t bwpIndex)
Get a pointer to the PHY of the GNB at the specified BWP.
void AttachToGnb(const Ptr< NetDevice > &ueDevice, const Ptr< NetDevice > &gnbDevice)
Attach a UE to a particular GNB.
void EnableUlMacSchedTraces()
void SetGnbUlAmcAttribute(const std::string &n, const AttributeValue &v)
static uint32_t GetNumberBwp(const Ptr< const NetDevice > &gnbDevice)
Get the number of configured BWP for a specific GNB NetDevice.
void EnableGnbMacCtrlMsgsTraces()
Enable gNB MAC CTRL TX and RX traces.
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, NrEpsBearer bearer, Ptr< NrEpcTft > tft)
void SetUeChannelAccessManagerTypeId(const TypeId &typeId)
Set the TypeId of the UE Channel Access Manager. Works only before it is created.
Ptr< NrBearerStatsCalculator > GetRlcStatsCalculator()
Get the RLC stats calculator object.
void EnableTransportBlockTrace()
Enable transport block trace.
void InitializeOperationBand(OperationBandInfo *band, uint8_t flags=INIT_PROPAGATION|INIT_FADING|INIT_CHANNEL)
Initialize the bandwidth parts by creating and configuring the channel models, if they are not alread...
void EnableGnbPacketCountTrace()
Enable gNB packet count trace.
void SetDlErrorModel(const std::string &errorModelTypeId)
Set the ErrorModel for DL AMC and GNB spectrum at the same time.
void EnableRlcE2eTraces()
Enable RLC calculator and end-to-end RCL traces to file.
void EnablePdcpSimpleTraces()
Enable PDCP traces (DL PDCP TX, DL PDCP RX, UL PDCP TX, UL PDCP RX)
static Ptr< NrMacScheduler > GetScheduler(const Ptr< NetDevice > &gnbDevice, uint32_t bwpIndex)
Get the Scheduler from the GNB specified.
void SetUeBwpManagerAlgorithmAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB BWP Manager, before it is created.
void SetEpcHelper(Ptr< NrEpcHelper > NrEpcHelper)
void SetGnbMacAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB MAC, before it is created.
void SetGnbPhyAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB PHY, before it is created.
void EnableDlCtrlPhyTraces()
Enable DL CTRL PHY traces.
void SetupUeAntennas(const AntennaParams &ap)
Set parameters for gNB and UE antenna arrays.
static Ptr< NrGnbMac > GetGnbMac(const Ptr< NetDevice > &gnbDevice, uint32_t bwpIndex)
Get a pointer to the MAC of the GNB at the specified BWP.
void SetUePhyAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the UE PHY, before it is created.
static Ptr< NrUePhy > GetUePhy(const Ptr< NetDevice > &ueDevice, uint32_t bwpIndex)
Get a pointer to the PHY of the UE at the specified BWP.
void SetupMimoPmi(const MimoPmiParams &mp)
Set parameters for PMI search in MIMO operation.
void EnableUePacketCountTrace()
Enable UE packet count trace.
static TypeId GetTypeId()
GetTypeId.
void SetUeSpectrumAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the UE spectrum, before it is created.
void SetPathlossAttribute(const std::string &n, const AttributeValue &v)
void SetSchedulerAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the scheduler, before it is created.
void EnableUeMacCtrlMsgsTraces()
Enable UE MAC CTRL TX and RX traces.
void SetSchedulerTypeId(const TypeId &typeId)
Set the Scheduler TypeId. Works only before it is created.
void SetGnbBwpManagerAlgorithmAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB BWP Manager, before it is created.
Ptr< NrPhyRxTrace > GetPhyRxTrace()
Get the phy traces object.
void SetGnbSpectrumAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB spectrum, before it is created.
NetDeviceContainer InstallUeDevice(const NodeContainer &c, const std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > &allBwps)
Install one (or more) UEs.
void SetChannelConditionModelAttribute(const std::string &n, const AttributeValue &v)
void SetGnbChannelAccessManagerAttribute(const std::string &n, const AttributeValue &v)
Set an attribute for the GNB channel access manager, before it is created.
void EnablePdcpE2eTraces()
Enable PDCP calculator and end-to-end PDCP traces to file.
void SetGnbChannelAccessManagerTypeId(const TypeId &typeId)
Set the TypeId of the GNB Channel Access Manager. Works only before it is created.
void SetGnbBeamManagerTypeId(const TypeId &typeId)
Set the TypeId of the beam manager.
void SetPmSearchTypeId(const TypeId &typeId)
Set TypeId of the precoding matrix search algorithm.
void SetSnrTest(bool snrTest)
SetSnrTest.
static void RxedGnbMacCtrlMsgsCallback(Ptr< NrMacRxTrace > macStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void TxedGnbMacCtrlMsgsCallback(Ptr< NrMacRxTrace > macStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void RxedUeMacCtrlMsgsCallback(Ptr< NrMacRxTrace > macStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void TxedUeMacCtrlMsgsCallback(Ptr< NrMacRxTrace > macStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static TypeId GetTypeId()
GetTypeId.
static void UlSchedulingCallback(Ptr< NrMacSchedulingStats > macStats, std::string path, NrSchedulingCallbackInfo traceInfo)
static void DlSchedulingCallback(Ptr< NrMacSchedulingStats > macStats, std::string path, NrSchedulingCallbackInfo traceInfo)
static void RxedGnbPhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void ReportDlDataPathloss(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint8_t bwpId, uint32_t ueNodeId, double lossDb, uint8_t cqi)
Write DL DATA pathloss values in a file.
static void PathlossTraceCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, Ptr< const SpectrumPhy > txPhy, Ptr< const SpectrumPhy > rxPhy, double lossDb)
Trace sink for spectrum channel pathloss trace.
static void TxedGnbPhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void TxedUePhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void TxedUePhyHarqFeedbackCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, uint8_t harqId, uint32_t k1Delay)
static void RxedUePhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void DlCtrlSinrCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double avgSinr, uint16_t bwpId)
Trace sink for DL Average SINR of CTRL (in dB).
static void RxedUePhyDlDciCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, uint8_t harqId, uint32_t k1Delay)
static void DlDataSinrCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double avgSinr, uint16_t bwpId)
Trace sink for DL Average SINR of DATA (in dB).
static void ReportDlCtrlPathloss(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint8_t bwpId, uint32_t ueNodeId, double lossDb)
Write DL CTRL pathloss values in a file.
static TypeId GetTypeId()
Get TypeId.
Base class for searching optimal precoding matrices and creating full CQI/PMI feedback This is a most...
void SetGnbParams(bool isDualPol, size_t numHPorts, size_t numVPorts)
Set the antenna parameters of the gNB antenna.
void UpdateSinrPerceived(const SpectrumValue &sinr)
SpectrumPhy that will be called when the SINR for the received DATA is being calculated by the interf...
static TypeId GetTypeId()
Get the object TypeId.
std::function< void(const std::list< Ptr< NrControlMessage > > &, uint8_t)> NrPhyRxCtrlEndOkCallback
This callback method type is used to notify that CTRL is received.
void UpdateSrsSinrPerceived(const SpectrumValue &srsSinr)
SpectrumPhy that will be called when the SINR for the received SRS at gNB is being calculated by the ...
void UpdateMimoSinrPerceived(const std::vector< MimoSinrChunk > &sinr)
Store the SINR chunks for all received signals at end of interference calculations.
Callback< void, const DlHarqInfo & > NrPhyDlHarqFeedbackCallback
void ReportDlCtrlSinr(const SpectrumValue &sinr)
Called when DlCtrlSinr is fired.
The MAC class for the UE.
static TypeId GetTypeId()
Get the Type id.
The User Equipment NetDevice.
void RouteIngoingCtrlMsgs(const std::list< Ptr< NrControlMessage > > &msgList, uint8_t sourceBwpId)
The UE received a CTRL message list.
static TypeId GetTypeId()
GetTypeId.
void EnqueueDlHarqFeedback(const DlHarqInfo &m) const
Spectrum has calculated the HarqFeedback for one DL transmission, and give it to the NetDevice of the...
void ReceivePss(uint16_t cellId, const Ptr< SpectrumValue > &p)
Receive PSS and calculate RSRQ in dBm.
void GenerateDlCqiReport(const SpectrumValue &sinr)
Generate a DL CQI report.
void GenerateDlCqiReportMimo(const std::vector< MimoSignalChunk > &mimoChunks)
Generate DL CQI, PMI, and RI (channel quality precoding matrix and rank indicators)
void PhyDataPacketReceived(const Ptr< Packet > &p)
Receive a PHY data packet.
void ReportRsReceivedPower(const SpectrumValue &power)
Called when rsReceivedPower is fired.
static TypeId GetTypeId()
Get the object TypeId.
@ UMi_Buildings
UMi_StreetCanyon with buildings.
@ UMa_LoS
UMa where all the nodes will be in Line-of-Sight.
@ RMa_LoS
RMa where all the nodes will be in Line-of-Sight.
@ InH_OfficeOpen
InH_OfficeOpen.
@ InH_OfficeOpen_nLoS
indoor office where all the nodes will not be in Line-of-Sight
@ V2V_Highway
V2V_Highway.
@ RMa_nLoS
RMA where all the nodes will not be in Line-of-Sight.
@ InH_OfficeMixed_nLoS
indoor office where all the nodes will not be in Line-of-Sight
@ UMa_Buildings
UMa with buildings.
@ InH_OfficeOpen_LoS
indoor office where all the nodes will be in Line-of-Sight
@ UMa_nLoS
UMa where all the nodes will not be in Line-of-Sight.
@ UMi_StreetCanyon_LoS
UMi_StreetCanyon where all the nodes will be in Line-of-Sight.
@ InH_OfficeMixed
InH_OfficeMixed.
@ UMi_StreetCanyon
UMi_StreetCanyon.
@ InH_OfficeMixed_LoS
indoor office where all the nodes will be in Line-of-Sight
parameters of the gNB or UE antenna arrays
size_t nAntRows
Number of antenna element rows (vertical height)
bool isDualPolarized
true if antennas are cross-polarized (dual-polarized)
double bearingAngle
Bearing angle in radians.
std::string antennaElem
Antenna type.
size_t nHorizPorts
Number of antenna ports in horizontal direction.
size_t nVertPorts
Number of antenna ports in vertical direction.
size_t nAntCols
Number of antenna element columns (horizontal width)
double polSlantAngle
Polarization slant angle in radians.
parameters for the search of optimal rank and precoding matrix indicator (RI, PMI)
uint8_t rankLimit
Limit maximum MIMO rank to model limited UE capabilities.
std::string downsamplingTechnique
Sub-band compression technique.
uint8_t subbandSize
Number of PRBs per subband for downsampling.
std::string fullSearchCb
Codebook when using full-search algorithm.
std::string pmSearchMethod
Precoding matrix search algorithm.
Operation band information structure.
std::vector< ComponentCarrierInfoPtr > m_cc
Operation band component carriers.