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>();
121 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
122 channelHelper->ConfigureFactories(
"UMi",
"LOS");
123 Config::SetDefault(
"ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(0)));
124 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
127 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
128 nrHelper->SetEpcHelper(nrEpcHelper);
129 nrEpcHelper->SetAttribute(
"S1uLinkDelay", 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;
180 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequency, bandwidth, numCcPerBand);
183 band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
184 channelHelper->AssignChannelsToBands({band});
187 uint32_t bwpIdForLowLat = 0;
188 uint32_t bwpIdForVoice = 0;
191 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
192 UintegerValue(bwpIdForLowLat));
193 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
196 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
197 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
200 NetDeviceContainer gNbNetDevs =
202 NetDeviceContainer ueLowLatNetDev = nrHelper->InstallUeDevice(ueLowLatContainer, allBwps);
203 NetDeviceContainer ueVoiceNetDev = nrHelper->InstallUeDevice(ueVoiceContainer, allBwps);
206 randomStream += nrHelper->AssignStreams(gNbNetDevs, randomStream);
207 randomStream += nrHelper->AssignStreams(ueLowLatNetDev, randomStream);
208 randomStream += nrHelper->AssignStreams(ueVoiceNetDev, randomStream);
212 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
213 NodeContainer remoteHostContainer;
214 Ptr<Node> remoteHostLowLat;
215 Ptr<Node> remoteHostVoice;
216 Ptr<Node> remoteHost;
220 remoteHostContainer.Create(1);
221 remoteHost = remoteHostContainer.Get(0);
225 remoteHostContainer.Create(2);
226 remoteHostLowLat = remoteHostContainer.Get(0);
227 remoteHostVoice = remoteHostContainer.Get(1);
230 InternetStackHelper internet;
231 internet.Install(remoteHostContainer);
234 PointToPointHelper p2ph;
235 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
236 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
237 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
239 NetDeviceContainer internetDevicesLowLat;
240 NetDeviceContainer internetDevicesVoice;
241 NetDeviceContainer internetDevices;
243 Ipv4AddressHelper ipv4h;
244 Ipv4InterfaceContainer internetIpIfacesLowLat;
245 Ipv4InterfaceContainer internetIpIfacesVoice;
246 Ipv4InterfaceContainer internetIpIfaces;
247 Ipv4StaticRoutingHelper ipv4RoutingHelper;
249 Ptr<Ipv4StaticRouting> remoteHostStaticRoutingLowLat;
250 Ptr<Ipv4StaticRouting> remoteHostStaticRoutingVoice;
251 Ptr<Ipv4StaticRouting> remoteHostStaticRouting;
255 internetDevices = p2ph.Install(pgw, remoteHost);
257 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
258 internetIpIfaces = ipv4h.Assign(internetDevices);
260 remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
261 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"),
262 Ipv4Mask(
"255.0.0.0"),
267 internetDevicesLowLat = p2ph.Install(pgw, remoteHostLowLat);
268 internetDevicesVoice = p2ph.Install(pgw, remoteHostVoice);
270 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
271 internetIpIfacesLowLat = ipv4h.Assign(internetDevicesLowLat);
272 ipv4h.SetBase(
"2.0.0.0",
"255.0.0.0");
273 internetIpIfacesVoice = ipv4h.Assign(internetDevicesVoice);
275 remoteHostStaticRoutingLowLat =
276 ipv4RoutingHelper.GetStaticRouting(remoteHostLowLat->GetObject<Ipv4>());
277 remoteHostStaticRoutingLowLat->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"),
278 Ipv4Mask(
"255.0.0.0"),
280 remoteHostStaticRoutingVoice =
281 ipv4RoutingHelper.GetStaticRouting(remoteHostVoice->GetObject<Ipv4>());
282 remoteHostStaticRoutingVoice->AddNetworkRouteTo(Ipv4Address(
"8.0.0.0"),
283 Ipv4Mask(
"255.0.0.0"),
289 Ipv4InterfaceContainer ueLowLatIpIface;
290 Ipv4InterfaceContainer ueVoiceIpIface;
291 ueLowLatIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLowLatNetDev));
292 ueVoiceIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueVoiceNetDev));
295 nrHelper->AttachToClosestGnb(ueLowLatNetDev, gNbNetDevs);
296 nrHelper->AttachToClosestGnb(ueVoiceNetDev, gNbNetDevs);
302 uint16_t dlPortLowLat = 1234;
303 uint16_t dlPortVoice = 1235;
305 uint16_t ulPortLowLat = 2000;
306 uint16_t ulPortVoice = 2001;
308 ApplicationContainer clientAppsDl;
309 ApplicationContainer serverAppsDlLowLat;
310 ApplicationContainer serverAppsDlVoice;
312 ApplicationContainer clientAppsUl;
313 ApplicationContainer serverAppsUlLowLat;
314 ApplicationContainer serverAppsUlVoice;
318 UdpServerHelper ulPacketSinkLowLat(ulPortLowLat);
319 UdpServerHelper ulPacketSinkVoice(ulPortVoice);
321 serverAppsUlLowLat = (ulPacketSinkLowLat.Install(remoteHostLowLat));
322 serverAppsUlVoice = (ulPacketSinkVoice.Install(remoteHostVoice));
324 UdpClientHelper ulClientLowlat;
325 ulClientLowlat.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
326 ulClientLowlat.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeULL));
327 ulClientLowlat.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaULL)));
329 Ptr<NrEpcTft> ulLowLatTft = Create<NrEpcTft>();
330 NrEpcTft::PacketFilter ulpfLowLat;
331 ulpfLowLat.remotePortStart = ulPortLowLat;
332 ulpfLowLat.remotePortEnd = ulPortLowLat;
333 ulpfLowLat.direction = NrEpcTft::UPLINK;
334 ulLowLatTft->Add(ulpfLowLat);
338 UdpClientHelper ulClientVoice;
339 ulClientVoice.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
340 ulClientVoice.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
341 ulClientVoice.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
343 Ptr<NrEpcTft> ulVoiceTft = Create<NrEpcTft>();
344 NrEpcTft::PacketFilter ulpfVoice;
345 ulpfVoice.remotePortStart = ulPortVoice;
346 ulpfVoice.remotePortEnd = ulPortVoice;
347 ulpfVoice.direction = NrEpcTft::UPLINK;
348 ulVoiceTft->Add(ulpfVoice);
353 for (uint32_t j = 0; j < ueLowLatContainer.GetN(); ++j)
355 ulClientLowlat.SetAttribute(
"Remote",
356 AddressValue(addressUtils::ConvertToSocketAddress(
357 internetIpIfacesLowLat.GetAddress(1),
359 clientAppsUl.Add(ulClientLowlat.Install(ueLowLatContainer.Get(j)));
360 nrHelper->ActivateDedicatedEpsBearer(ueLowLatNetDev.Get(j), bearerLowLat, ulLowLatTft);
364 for (uint32_t j = 0; j < ueVoiceContainer.GetN(); ++j)
366 ulClientVoice.SetAttribute(
"Remote",
367 AddressValue(addressUtils::ConvertToSocketAddress(
368 internetIpIfacesVoice.GetAddress(1),
370 clientAppsUl.Add(ulClientVoice.Install(ueVoiceContainer.Get(j)));
371 nrHelper->ActivateDedicatedEpsBearer(ueVoiceNetDev.Get(j), bearerVoice, ulVoiceTft);
374 serverAppsUlLowLat.Start(udpAppStartTimeUl);
375 serverAppsUlVoice.Start(udpAppStartTimeUl);
376 clientAppsUl.Start(udpAppStartTimeUl);
378 serverAppsUlLowLat.Stop(udpAppStopTimeUl);
379 serverAppsUlVoice.Stop(udpAppStopTimeUl);
380 clientAppsUl.Stop(udpAppStopTimeUl);
385 UdpServerHelper dlPacketSinkLowLat(dlPortLowLat);
386 UdpServerHelper dlPacketSinkVoice(dlPortVoice);
388 serverAppsDlLowLat = (dlPacketSinkLowLat.Install(ueLowLatContainer));
389 serverAppsDlVoice = (dlPacketSinkVoice.Install(ueVoiceContainer));
391 Ptr<NrEpcTft> dlLowLatTft = Create<NrEpcTft>();
392 NrEpcTft::PacketFilter dlpfLowLat;
393 dlpfLowLat.localPortStart = dlPortLowLat;
394 dlpfLowLat.localPortEnd = dlPortLowLat;
395 dlpfLowLat.direction = NrEpcTft::DOWNLINK;
396 dlLowLatTft->Add(dlpfLowLat);
400 Ptr<NrEpcTft> dlVoiceTft = Create<NrEpcTft>();
401 NrEpcTft::PacketFilter dlpfVoice;
402 dlpfVoice.localPortStart = dlPortVoice;
403 dlpfVoice.localPortEnd = dlPortVoice;
404 dlpfVoice.direction = NrEpcTft::DOWNLINK;
405 dlVoiceTft->Add(dlpfVoice);
409 for (uint32_t j = 0; j < ueLowLatContainer.GetN(); ++j)
411 UdpClientHelper dlClient(ueLowLatIpIface.GetAddress(j), dlPortLowLat);
412 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
413 dlClient.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeULL));
414 dlClient.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaULL)));
415 clientAppsDl.Add(dlClient.Install(remoteHost));
417 nrHelper->ActivateDedicatedEpsBearer(ueLowLatNetDev.Get(j), bearerLowlat, dlLowLatTft);
420 for (uint32_t j = 0; j < ueVoiceContainer.GetN(); ++j)
422 UdpClientHelper dlClient(ueVoiceIpIface.GetAddress(j), dlPortVoice);
423 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
424 dlClient.SetAttribute(
"PacketSize", UintegerValue(udpPacketSizeBe));
425 dlClient.SetAttribute(
"Interval", TimeValue(Seconds(1.0 / lambdaBe)));
426 clientAppsDl.Add(dlClient.Install(remoteHost));
428 nrHelper->ActivateDedicatedEpsBearer(ueVoiceNetDev.Get(j), bearerVoice, dlVoiceTft);
432 serverAppsDlLowLat.Start(udpAppStartTimeDl);
433 serverAppsDlVoice.Start(udpAppStartTimeDl);
434 clientAppsDl.Start(udpAppStartTimeDl);
436 serverAppsDlLowLat.Stop(udpAppStopTimeDl);
437 serverAppsDlVoice.Stop(udpAppStopTimeDl);
438 clientAppsDl.Stop(udpAppStopTimeDl);
442 Simulator::Stop(simTime);
445 uint32_t appTime = (simTime.GetSeconds() - udpAppStartTimeDl.GetSeconds());
450 double dlThroughputLowLat = 0;
451 double dlThroughputVoice = 0;
452 double ulThroughputLowLat = 0;
453 double ulThroughputVoice = 0;
457 for (uint32_t i = 0; i < serverAppsDlLowLat.GetN(); i++)
459 Ptr<UdpServer> serverApp = serverAppsDlLowLat.Get(i)->GetObject<UdpServer>();
460 dlThroughputLowLat += (serverApp->GetReceived() * udpPacketSizeULL * 8) / appTime;
462 for (uint32_t i = 0; i < serverAppsDlVoice.GetN(); i++)
464 Ptr<UdpServer> serverApp = serverAppsDlVoice.Get(i)->GetObject<UdpServer>();
465 dlThroughputVoice += (serverApp->GetReceived() * udpPacketSizeBe * 8) / appTime;
470 double qciRatio = (100 - m_p1) / (100 - m_p2);
471 double throughputRatio = dlThroughputVoice / dlThroughputLowLat;
475 std::cout <<
"dlThroughputLowLat: " << dlThroughputVoice
476 <<
" dlThroughputVoice: " << dlThroughputLowLat << std::endl;
477 std::cout <<
"ratio: " << qciRatio <<
" throughput ratio: " << throughputRatio
481 NS_TEST_ASSERT_MSG_EQ_TOL(qciRatio,
484 "DL qci Ratio and throughput Ratio are not "
485 "equal within tolerance");
489 for (uint32_t i = 0; i < serverAppsUlLowLat.GetN(); i++)
491 Ptr<UdpServer> serverApp = serverAppsUlLowLat.Get(i)->GetObject<UdpServer>();
492 ulThroughputLowLat += (serverApp->GetReceived() * udpPacketSizeULL * 8) / appTime;
494 for (uint32_t i = 0; i < serverAppsUlVoice.GetN(); i++)
496 Ptr<UdpServer> serverApp = serverAppsUlVoice.Get(i)->GetObject<UdpServer>();
497 ulThroughputVoice += (serverApp->GetReceived() * udpPacketSizeBe * 8) / appTime;
500 double qciRatio = (100 - m_p1) / (100 - 90);
501 double throughputRatio = ulThroughputVoice / ulThroughputLowLat;
505 std::cout <<
"ulThroughputLowLat: " << ulThroughputVoice
506 <<
" ulThroughputVoice: " << ulThroughputLowLat << std::endl;
507 std::cout <<
"ratio: " << qciRatio <<
" throughput ratio: " << throughputRatio
511 NS_TEST_ASSERT_MSG_EQ_TOL(qciRatio,
514 "UL qci Ratio and throughput Ratio are not "
515 "equal within tolerance");
518 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
This test case checks if the throughput obtained is as expected for the QoS scheduling logic.