7#include <ns3/antenna-module.h>
8#include <ns3/applications-module.h>
10#include <ns3/internet-module.h>
11#include <ns3/nr-module.h>
12#include <ns3/packet.h>
13#include <ns3/point-to-point-helper.h>
14#include <ns3/pointer.h>
15#include <ns3/simulator.h>
16#include <ns3/uinteger.h>
28 uint32_t priorityTrafficScenario,
29 const std::string& schedulerType)
30 : TestCase(
"QoS Scheduler Test Case")
32 m_ueNumPergNb = ueNumPergNb;
33 m_numerology = numerology;
35 m_isDownlink = isDownlnk;
36 m_isUplink = isUplink;
39 m_priorityTrafficScenario = priorityTrafficScenario;
40 m_schedulerType = schedulerType;
50SystemSchedulerTestQos::DoRun()
52 NS_ABORT_IF(!m_isUplink && !m_isDownlink);
55 Time simTime = MilliSeconds(1500);
56 Time udpAppStartTimeDl = MilliSeconds(500);
57 Time udpAppStartTimeUl = MilliSeconds(500);
58 Time udpAppStopTimeDl = MilliSeconds(1500);
59 Time udpAppStopTimeUl = MilliSeconds(1500);
62 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
63 Config::SetDefault(
"ns3::NrRlcUm::ReorderingTimer", TimeValue(Seconds(1)));
64 Config::SetDefault(
"ns3::NrEpsBearer::Release", UintegerValue(15));
67 int64_t randomStream = 1;
80 gridScenario.SetScenarioHeight(3);
81 gridScenario.SetScenarioLength(3);
87 std::cout <<
"Test case: Scheduler type: " << m_schedulerType
88 <<
" numerology: " << m_numerology <<
" BW: " << m_bw1 <<
" DL: " << m_isDownlink
89 <<
" UL: " << m_isUplink <<
" number of UEs: " << m_ueNumPergNb << std::endl;
92 uint32_t udpPacketSizeULL = 3000;
93 uint32_t udpPacketSizeBe = 3000;
94 uint32_t lambdaULL = 1000;
95 uint32_t lambdaBe = 1000;
97 if (m_priorityTrafficScenario == 1)
99 udpPacketSizeBe = 1252;
102 NodeContainer ueLowLatContainer;
103 NodeContainer ueVoiceContainer;
108 j % 2 == 0 ? ueLowLatContainer.Add(ue) : ueVoiceContainer.Add(ue);
111 if (m_priorityTrafficScenario == 1)
113 lambdaULL = 1000 / ueLowLatContainer.GetN();
114 lambdaBe = 1000 / ueVoiceContainer.GetN();
118 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
119 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
120 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
123 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
124 nrHelper->SetEpcHelper(nrEpcHelper);
126 nrHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
127 nrEpcHelper->SetAttribute(
"S1uLinkDelay", TimeValue(MilliSeconds(0)));
128 Config::SetDefault(
"ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(0)));
129 nrHelper->SetChannelConditionModelAttribute(
"UpdatePeriod", TimeValue(MilliSeconds(0)));
132 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(m_schedulerType));
134 uint16_t mcsTable = 2;
136 std::string errorModel =
"ns3::NrEesmIrT" + std::to_string(mcsTable);
137 nrHelper->SetDlErrorModel(errorModel);
138 nrHelper->SetUlErrorModel(errorModel);
145 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
149 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(1));
150 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(1));
151 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
152 PointerValue(CreateObject<IsotropicAntennaModel>()));
155 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(1));
156 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(1));
157 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
158 PointerValue(CreateObject<ThreeGppAntennaModel>()));
161 nrHelper->SetGnbPhyAttribute(
"TxPower", DoubleValue(43.0));
162 nrHelper->SetUePhyAttribute(
"TxPower", DoubleValue(43.0));
165 nrHelper->SetGnbPhyAttribute(
"Numerology", UintegerValue(m_numerology));
175 CcBwpCreator ccBwpCreator;
176 OperationBandInfo band;
177 double centralFrequency = 4e9;
178 double bandwidth = m_bw1;
179 const uint8_t numCcPerBand = 1;
181 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequency,
187 band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
189 nrHelper->InitializeOperationBand(&band);
192 uint32_t bwpIdForLowLat = 0;
193 uint32_t bwpIdForVoice = 0;
196 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
197 UintegerValue(bwpIdForLowLat));
198 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
201 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
202 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
205 NetDeviceContainer gNbNetDevs =
207 NetDeviceContainer ueLowLatNetDev = nrHelper->InstallUeDevice(ueLowLatContainer, allBwps);
208 NetDeviceContainer ueVoiceNetDev = nrHelper->InstallUeDevice(ueVoiceContainer, allBwps);
211 randomStream += nrHelper->AssignStreams(gNbNetDevs, randomStream);
212 randomStream += nrHelper->AssignStreams(ueLowLatNetDev, randomStream);
213 randomStream += nrHelper->AssignStreams(ueVoiceNetDev, randomStream);
215 for (
auto it = gNbNetDevs.Begin(); it != gNbNetDevs.End(); ++it)
217 DynamicCast<NrGnbNetDevice>(*it)->UpdateConfig();
220 for (
auto it = ueLowLatNetDev.Begin(); it != ueLowLatNetDev.End(); ++it)
222 DynamicCast<NrUeNetDevice>(*it)->UpdateConfig();
224 for (
auto it = ueVoiceNetDev.Begin(); it != ueVoiceNetDev.End(); ++it)
226 DynamicCast<NrUeNetDevice>(*it)->UpdateConfig();
231 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
232 NodeContainer remoteHostContainer;
233 Ptr<Node> remoteHostLowLat;
234 Ptr<Node> remoteHostVoice;
235 Ptr<Node> remoteHost;
239 remoteHostContainer.Create(1);
240 remoteHost = remoteHostContainer.Get(0);
244 remoteHostContainer.Create(2);
245 remoteHostLowLat = remoteHostContainer.Get(0);
246 remoteHostVoice = remoteHostContainer.Get(1);
249 InternetStackHelper internet;
250 internet.Install(remoteHostContainer);
253 PointToPointHelper p2ph;
254 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
255 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
256 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
258 NetDeviceContainer internetDevicesLowLat;
259 NetDeviceContainer internetDevicesVoice;
260 NetDeviceContainer internetDevices;
262 Ipv4AddressHelper ipv4h;
263 Ipv4InterfaceContainer internetIpIfacesLowLat;
264 Ipv4InterfaceContainer internetIpIfacesVoice;
265 Ipv4InterfaceContainer internetIpIfaces;
266 Ipv4StaticRoutingHelper ipv4RoutingHelper;
268 Ptr<Ipv4StaticRouting> remoteHostStaticRoutingLowLat;
269 Ptr<Ipv4StaticRouting> remoteHostStaticRoutingVoice;
270 Ptr<Ipv4StaticRouting> remoteHostStaticRouting;
274 internetDevices = p2ph.Install(pgw, remoteHost);
276 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
277 internetIpIfaces = ipv4h.Assign(internetDevices);
279 remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
280 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"),
281 Ipv4Mask(
"255.0.0.0"),
286 internetDevicesLowLat = p2ph.Install(pgw, remoteHostLowLat);
287 internetDevicesVoice = p2ph.Install(pgw, remoteHostVoice);
289 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
290 internetIpIfacesLowLat = ipv4h.Assign(internetDevicesLowLat);
291 ipv4h.SetBase(
"2.0.0.0",
"255.0.0.0");
292 internetIpIfacesVoice = ipv4h.Assign(internetDevicesVoice);
294 remoteHostStaticRoutingLowLat =
295 ipv4RoutingHelper.GetStaticRouting(remoteHostLowLat->GetObject<Ipv4>());
296 remoteHostStaticRoutingLowLat->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"),
297 Ipv4Mask(
"255.0.0.0"),
299 remoteHostStaticRoutingVoice =
300 ipv4RoutingHelper.GetStaticRouting(remoteHostVoice->GetObject<Ipv4>());
301 remoteHostStaticRoutingVoice->AddNetworkRouteTo(Ipv4Address(
"8.0.0.0"),
302 Ipv4Mask(
"255.0.0.0"),
308 Ipv4InterfaceContainer ueLowLatIpIface;
309 Ipv4InterfaceContainer ueVoiceIpIface;
310 ueLowLatIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLowLatNetDev));
311 ueVoiceIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueVoiceNetDev));
316 Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting(
318 ueStaticRouting->SetDefaultRoute(nrEpcHelper->GetUeDefaultGatewayAddress(), 1);
322 nrHelper->AttachToClosestGnb(ueLowLatNetDev, gNbNetDevs);
323 nrHelper->AttachToClosestGnb(ueVoiceNetDev, gNbNetDevs);
329 uint16_t dlPortLowLat = 1234;
330 uint16_t dlPortVoice = 1235;
332 uint16_t ulPortLowLat = 2000;
333 uint16_t ulPortVoice = 2001;
335 ApplicationContainer clientAppsDl;
336 ApplicationContainer serverAppsDlLowLat;
337 ApplicationContainer serverAppsDlVoice;
339 ApplicationContainer clientAppsUl;
340 ApplicationContainer serverAppsUlLowLat;
341 ApplicationContainer serverAppsUlVoice;
345 UdpServerHelper ulPacketSinkLowLat(ulPortLowLat);
346 UdpServerHelper ulPacketSinkVoice(ulPortVoice);
348 serverAppsUlLowLat = (ulPacketSinkLowLat.Install(remoteHostLowLat));
349 serverAppsUlVoice = (ulPacketSinkVoice.Install(remoteHostVoice));
351 UdpClientHelper ulClientLowlat;
352 ulClientLowlat.SetAttribute(
"RemotePort", UintegerValue(ulPortLowLat));
353 ulClientLowlat.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
354 ulClientLowlat.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeULL));
355 ulClientLowlat.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaULL)));
357 Ptr<NrEpcTft> ulLowLatTft = Create<NrEpcTft>();
358 NrEpcTft::PacketFilter ulpfLowLat;
359 ulpfLowLat.remotePortStart = ulPortLowLat;
360 ulpfLowLat.remotePortEnd = ulPortLowLat;
361 ulpfLowLat.direction = NrEpcTft::UPLINK;
362 ulLowLatTft->Add(ulpfLowLat);
366 UdpClientHelper ulClientVoice;
367 ulClientVoice.SetAttribute(
"RemotePort", UintegerValue(ulPortVoice));
368 ulClientVoice.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
369 ulClientVoice.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
370 ulClientVoice.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
372 Ptr<NrEpcTft> ulVoiceTft = Create<NrEpcTft>();
373 NrEpcTft::PacketFilter ulpfVoice;
374 ulpfVoice.remotePortStart = ulPortVoice;
375 ulpfVoice.remotePortEnd = ulPortVoice;
376 ulpfVoice.direction = NrEpcTft::UPLINK;
377 ulVoiceTft->Add(ulpfVoice);
382 for (uint32_t j = 0; j < ueLowLatContainer.GetN(); ++j)
384 ulClientLowlat.SetAttribute(
"RemoteAddress",
385 AddressValue(internetIpIfacesLowLat.GetAddress(1)));
386 clientAppsUl.Add(ulClientLowlat.Install(ueLowLatContainer.Get(j)));
387 nrHelper->ActivateDedicatedEpsBearer(ueLowLatNetDev.Get(j), bearerLowLat, ulLowLatTft);
391 for (uint32_t j = 0; j < ueVoiceContainer.GetN(); ++j)
393 ulClientVoice.SetAttribute(
"RemoteAddress",
394 AddressValue(internetIpIfacesVoice.GetAddress(1)));
395 clientAppsUl.Add(ulClientVoice.Install(ueVoiceContainer.Get(j)));
396 nrHelper->ActivateDedicatedEpsBearer(ueVoiceNetDev.Get(j), bearerVoice, ulVoiceTft);
399 serverAppsUlLowLat.Start(udpAppStartTimeUl);
400 serverAppsUlVoice.Start(udpAppStartTimeUl);
401 clientAppsUl.Start(udpAppStartTimeUl);
403 serverAppsUlLowLat.Stop(udpAppStopTimeUl);
404 serverAppsUlVoice.Stop(udpAppStopTimeUl);
405 clientAppsUl.Stop(udpAppStopTimeUl);
410 UdpServerHelper dlPacketSinkLowLat(dlPortLowLat);
411 UdpServerHelper dlPacketSinkVoice(dlPortVoice);
413 serverAppsDlLowLat = (dlPacketSinkLowLat.Install(ueLowLatContainer));
414 serverAppsDlVoice = (dlPacketSinkVoice.Install(ueVoiceContainer));
416 Ptr<NrEpcTft> dlLowLatTft = Create<NrEpcTft>();
417 NrEpcTft::PacketFilter dlpfLowLat;
418 dlpfLowLat.localPortStart = dlPortLowLat;
419 dlpfLowLat.localPortEnd = dlPortLowLat;
420 dlpfLowLat.direction = NrEpcTft::DOWNLINK;
421 dlLowLatTft->Add(dlpfLowLat);
425 Ptr<NrEpcTft> dlVoiceTft = Create<NrEpcTft>();
426 NrEpcTft::PacketFilter dlpfVoice;
427 dlpfVoice.localPortStart = dlPortVoice;
428 dlpfVoice.localPortEnd = dlPortVoice;
429 dlpfVoice.direction = NrEpcTft::DOWNLINK;
430 dlVoiceTft->Add(dlpfVoice);
434 for (uint32_t j = 0; j < ueLowLatContainer.GetN(); ++j)
436 UdpClientHelper dlClient(ueLowLatIpIface.GetAddress(j), dlPortLowLat);
437 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
438 dlClient.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeULL));
439 dlClient.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaULL)));
440 clientAppsDl.Add(dlClient.Install(remoteHost));
442 nrHelper->ActivateDedicatedEpsBearer(ueLowLatNetDev.Get(j), bearerLowlat, dlLowLatTft);
445 for (uint32_t j = 0; j < ueVoiceContainer.GetN(); ++j)
447 UdpClientHelper dlClient(ueVoiceIpIface.GetAddress(j), dlPortVoice);
448 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
449 dlClient.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
450 dlClient.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
451 clientAppsDl.Add(dlClient.Install(remoteHost));
453 nrHelper->ActivateDedicatedEpsBearer(ueVoiceNetDev.Get(j), bearerVoice, dlVoiceTft);
457 serverAppsDlLowLat.Start(udpAppStartTimeDl);
458 serverAppsDlVoice.Start(udpAppStartTimeDl);
459 clientAppsDl.Start(udpAppStartTimeDl);
461 serverAppsDlLowLat.Stop(udpAppStopTimeDl);
462 serverAppsDlVoice.Stop(udpAppStopTimeDl);
463 clientAppsDl.Stop(udpAppStopTimeDl);
467 Simulator::Stop(simTime);
470 uint32_t appTime = (simTime.GetSeconds() - udpAppStartTimeDl.GetSeconds());
475 double dlThroughputLowLat = 0;
476 double dlThroughputVoice = 0;
477 double ulThroughputLowLat = 0;
478 double ulThroughputVoice = 0;
482 for (uint32_t i = 0; i < serverAppsDlLowLat.GetN(); i++)
484 Ptr<UdpServer> serverApp = serverAppsDlLowLat.Get(i)->GetObject<UdpServer>();
485 dlThroughputLowLat += (serverApp->GetReceived() * udpPacketSizeULL * 8) / appTime;
487 for (uint32_t i = 0; i < serverAppsDlVoice.GetN(); i++)
489 Ptr<UdpServer> serverApp = serverAppsDlVoice.Get(i)->GetObject<UdpServer>();
490 dlThroughputVoice += (serverApp->GetReceived() * udpPacketSizeBe * 8) / appTime;
495 double qciRatio = (100 - m_p1) / (100 - m_p2);
496 double throughputRatio = dlThroughputVoice / dlThroughputLowLat;
500 std::cout <<
"dlThroughputLowLat: " << dlThroughputVoice
501 <<
" dlThroughputVoice: " << dlThroughputLowLat << std::endl;
502 std::cout <<
"ratio: " << qciRatio <<
" throughput ratio: " << throughputRatio
506 NS_TEST_ASSERT_MSG_EQ_TOL(qciRatio,
509 "DL qci Ratio and throughput Ratio are not "
510 "equal within tolerance");
514 for (uint32_t i = 0; i < serverAppsUlLowLat.GetN(); i++)
516 Ptr<UdpServer> serverApp = serverAppsUlLowLat.Get(i)->GetObject<UdpServer>();
517 ulThroughputLowLat += (serverApp->GetReceived() * udpPacketSizeULL * 8) / appTime;
519 for (uint32_t i = 0; i < serverAppsUlVoice.GetN(); i++)
521 Ptr<UdpServer> serverApp = serverAppsUlVoice.Get(i)->GetObject<UdpServer>();
522 ulThroughputVoice += (serverApp->GetReceived() * udpPacketSizeBe * 8) / appTime;
525 double qciRatio = (100 - m_p1) / (100 - 90);
526 double throughputRatio = ulThroughputVoice / ulThroughputLowLat;
530 std::cout <<
"ulThroughputLowLat: " << ulThroughputVoice
531 <<
" ulThroughputVoice: " << ulThroughputLowLat << std::endl;
532 std::cout <<
"ratio: " << qciRatio <<
" throughput ratio: " << throughputRatio
536 NS_TEST_ASSERT_MSG_EQ_TOL(qciRatio,
539 "UL qci Ratio and throughput Ratio are not "
540 "equal within tolerance");
543 Simulator::Destroy();
static BandwidthPartInfoPtrVector GetAllBwps(const std::vector< std::reference_wrapper< OperationBandInfo > > &operationBands)
Get all the BWP pointers from the specified vector of operation bands.
The GridScenarioHelper class.
void SetRows(uint32_t r)
SetRows.
void SetHorizontalBsDistance(double d)
SetHorizontalBsDistance.
void SetVerticalBsDistance(double d)
SetVerticalBsDistance.
void CreateScenario() override
Create the scenario, with the configured parameter.
int64_t AssignStreams(int64_t stream)
void SetColumns(uint32_t c)
SetColumns.
const NodeContainer & GetUserTerminals() const
Get the list of user nodes.
void SetBsNumber(std::size_t n)
Set the number of base stations.
void SetUtNumber(std::size_t n)
Set the number of UT/UE.
const NodeContainer & GetBaseStations() const
Get the list of gnb/base station nodes.
@ ErrorModel
Error Model version (can use different error models, see NrErrorModel)
@ NGBR_LOW_LAT_EMBB
Non-GBR Low Latency eMBB applications.
@ GBR_CONV_VOICE
GBR Conversational Voice.
void SetBsHeight(double h)
SetGnbHeight.
void SetUtHeight(double h)
SetUeHeight.
void SetSectorization(SiteSectorizationType numSectors)
Sets the number of sectors of every site.
@ SINGLE
Site with a 360ยบ-width sector.
SystemSchedulerTestQos(uint32_t ueNumPergNb, uint32_t numerology, double bw1, bool isDownlink, bool isUplink, double p1, double p2, uint32_t priorityTrafficScenario, const std::string &schedulerType)
SystemSchedulerTest is a test constructor which is used to initialise the test parameters.
~SystemSchedulerTestQos() override
~SystemSchedulerTestQos
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Scenario
Different types for the propagation loss model of this bandwidth part.
@ UMi_StreetCanyon_LoS
UMi_StreetCanyon where all the nodes will be in Line-of-Sight.
This test case checks if the throughput obtained is as expected for the QoS scheduling logic.