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"
22SystemSchedulerTest::CountPkts([[maybe_unused]] Ptr<const Packet> pkt)
25 if (m_packets == m_limit)
32 uint32_t usersPerBeamNum,
38 const std::string& schedulerType)
41 m_numerology = numerology;
43 m_isDownlink = isDownlnk;
44 m_isUplink = isUplink;
45 m_usersPerBeamNum = usersPerBeamNum;
46 NS_ABORT_MSG_UNLESS(numOfBeams <= 4,
47 "Test program is designed to support up to 4 beams per gNB");
48 m_numOfBeams = numOfBeams;
49 m_schedulerType = schedulerType;
60SystemSchedulerTest::DoRun()
62 NS_ABORT_IF(!m_isUplink && !m_isDownlink);
65 Time simTime = MilliSeconds(800);
66 Time udpAppStartTimeDl = MilliSeconds(400);
67 Time udpAppStartTimeUl = MilliSeconds(400);
68 Time udpAppStopTimeDl = MilliSeconds(800);
69 Time udpAppStopTimeUl = MilliSeconds(800);
71 uint32_t packetSize = 100;
72 uint32_t maxPackets = 400;
73 DataRate udpRate = DataRate(
"320kbps");
75 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
76 Config::SetDefault(
"ns3::NrRlcUm::ReorderingTimer", TimeValue(Seconds(1)));
77 Config::SetDefault(
"ns3::NrEpsBearer::Release", UintegerValue(15));
80 "ns3::NrUePhy::EnableUplinkPowerControl",
86 NodeContainer gNbNodes;
87 NodeContainer ueNodes;
88 MobilityHelper mobility;
90 double gNbHeight = 10;
91 double ueHeight = 1.5;
92 gNbNodes.Create(gNbNum);
93 ueNodes.Create(m_usersPerBeamNum * m_numOfBeams * gNbNum);
95 Ptr<ListPositionAllocator> apPositionAlloc = CreateObject<ListPositionAllocator>();
96 Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator>();
101 for (uint32_t gNb = 0; gNb < gNbNum; gNb++)
103 apPositionAlloc->Add(Vector(gNbx, gNby, gNbHeight));
105 for (uint32_t beam = 1; beam <= m_numOfBeams; beam++)
107 for (uint32_t uePerBeamIndex = 0; uePerBeamIndex < m_usersPerBeamNum; uePerBeamIndex++)
111 staPositionAlloc->Add(Vector(gNbx + 1 + 0.1 * uePerBeamIndex,
112 gNby + 10 + 0.1 * uePerBeamIndex,
117 staPositionAlloc->Add(Vector(gNbx + 10 + 0.1 * uePerBeamIndex,
118 gNby - 1 + 0.1 * uePerBeamIndex,
123 staPositionAlloc->Add(Vector(gNbx - 1 + 0.1 * uePerBeamIndex,
124 gNby - 10 + 0.1 * uePerBeamIndex,
129 staPositionAlloc->Add(Vector(gNbx - 10 + 0.1 * uePerBeamIndex,
130 gNby + 1 + 0.1 * uePerBeamIndex,
140 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
141 mobility.SetPositionAllocator(apPositionAlloc);
142 mobility.Install(gNbNodes);
143 mobility.SetPositionAllocator(staPositionAlloc);
144 mobility.Install(ueNodes);
147 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
149 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
150 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
152 idealBeamformingHelper->SetBeamformingAlgorithmAttribute(
"BeamSearchAngleStep",
155 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
156 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
158 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
160 channelHelper->ConfigureFactories(
"UMi",
"LOS");
161 Config::SetDefault(
"ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(0)));
163 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
165 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(2));
166 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(4));
167 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
168 PointerValue(CreateObject<IsotropicAntennaModel>()));
171 nrHelper->SetUePhyAttribute(
"TxPower", DoubleValue(20.0));
174 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(4));
175 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(8));
176 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
177 PointerValue(CreateObject<ThreeGppAntennaModel>()));
180 nrHelper->SetGnbPhyAttribute(
"TxPower", DoubleValue(44.0));
183 nrHelper->SetGnbPhyAttribute(
"Numerology", UintegerValue(m_numerology));
186 nrHelper->SetSchedulerTypeId(TypeId::LookupByName(m_schedulerType));
187 Config::SetDefault(
"ns3::NrAmc::ErrorModelType",
188 TypeIdValue(TypeId::LookupByName(
"ns3::NrEesmCcT1")));
189 nrHelper->SetSchedulerAttribute(
"FixedMcsDl", BooleanValue(
true));
190 nrHelper->SetSchedulerAttribute(
"FixedMcsUl", BooleanValue(
true));
191 nrHelper->SetSchedulerAttribute(
"StartingMcsDl", UintegerValue(28));
192 nrHelper->SetSchedulerAttribute(
"StartingMcsUl", UintegerValue(28));
194 nrHelper->SetEpcHelper(nrEpcHelper);
204 CcBwpCreator ccBwpCreator;
205 double centralFrequency = 28e9;
206 double bandwidth = m_bw1;
207 const uint8_t numCcPerBand = 1;
208 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequency, bandwidth, numCcPerBand);
211 OperationBandInfo band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
213 channelHelper->AssignChannelsToBands({band});
216 uint32_t bwpIdForLowLat = 0;
218 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
219 UintegerValue(bwpIdForLowLat));
221 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
224 NetDeviceContainer gNbNetDevs = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
225 NetDeviceContainer ueNetDevs = nrHelper->InstallUeDevice(ueNodes, allBwps);
227 int64_t randomStream = 1;
228 randomStream += nrHelper->AssignStreams(gNbNetDevs, randomStream);
229 randomStream += nrHelper->AssignStreams(ueNetDevs, randomStream);
233 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
234 NodeContainer remoteHostContainer;
235 remoteHostContainer.Create(1);
236 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
237 InternetStackHelper internet;
238 internet.Install(remoteHostContainer);
240 PointToPointHelper p2ph;
241 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
242 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
243 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
244 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
245 Ipv4AddressHelper ipv4h;
246 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
247 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
249 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
251 Ipv4StaticRoutingHelper ipv4RoutingHelper;
252 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
253 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
254 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"), Ipv4Mask(
"255.0.0.0"), 1);
255 internet.Install(ueNodes);
256 Ipv4InterfaceContainer ueIpIface;
257 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDevs));
260 nrHelper->AttachToClosestGnb(ueNetDevs, gNbNetDevs);
263 uint16_t dlPort = 1234;
264 uint16_t ulPort = 2000;
265 ApplicationContainer clientAppsDl;
266 ApplicationContainer serverAppsDl;
267 ApplicationContainer clientAppsUl;
268 ApplicationContainer serverAppsUl;
271 Time udpInterval = NanoSeconds(1);
275 UdpServerHelper ulPacketSinkHelper(ulPort);
276 serverAppsUl.Add(ulPacketSinkHelper.Install(remoteHost));
279 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
281 UdpClientHelper ulClient(remoteHostAddr, ulPort);
282 ulClient.SetAttribute(
"MaxPackets", UintegerValue(maxPackets));
283 ulClient.SetAttribute(
"PacketSize", UintegerValue(packetSize));
284 ulClient.SetAttribute(
286 TimeValue(udpInterval));
288 clientAppsUl.Add(ulClient.Install(ueNodes.Get(j)));
290 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
291 NrEpcTft::PacketFilter ulpf;
292 ulpf.remotePortStart = ulPort;
293 ulpf.remotePortEnd = ulPort;
294 ulpf.direction = NrEpcTft::UPLINK;
298 nrHelper->ActivateDedicatedEpsBearer(ueNetDevs.Get(j), bearer, tft);
301 serverAppsUl.Start(udpAppStartTimeUl);
302 clientAppsUl.Start(udpAppStartTimeUl);
303 serverAppsUl.Stop(udpAppStopTimeUl);
304 clientAppsUl.Stop(udpAppStopTimeUl);
309 UdpServerHelper dlPacketSinkHelper(dlPort);
310 serverAppsDl.Add(dlPacketSinkHelper.Install(ueNodes));
313 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
315 UdpClientHelper dlClient(ueIpIface.GetAddress(j), dlPort);
316 dlClient.SetAttribute(
"MaxPackets", UintegerValue(maxPackets));
317 dlClient.SetAttribute(
"PacketSize", UintegerValue(packetSize));
318 dlClient.SetAttribute(
320 TimeValue(udpInterval));
322 clientAppsDl.Add(dlClient.Install(remoteHost));
324 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
325 NrEpcTft::PacketFilter dlpf;
326 dlpf.localPortStart = dlPort;
327 dlpf.localPortEnd = dlPort;
328 dlpf.direction = NrEpcTft::DOWNLINK;
332 nrHelper->ActivateDedicatedEpsBearer(ueNetDevs.Get(j), bearer, tft);
335 serverAppsDl.Start(udpAppStartTimeDl);
336 clientAppsDl.Start(udpAppStartTimeDl);
337 serverAppsDl.Stop(udpAppStopTimeDl);
338 clientAppsDl.Stop(udpAppStopTimeDl);
341 m_limit = ueNodes.GetN() * maxPackets * ((m_isUplink && m_isDownlink) ? 2 : 1);
343 for (
auto it = serverAppsDl.Begin(); it != serverAppsDl.End(); ++it)
345 (*it)->TraceConnectWithoutContext(
"Rx",
346 MakeCallback(&SystemSchedulerTest::CountPkts,
this));
349 for (
auto it = serverAppsUl.Begin(); it != serverAppsUl.End(); ++it)
351 (*it)->TraceConnectWithoutContext(
"Rx",
352 MakeCallback(&SystemSchedulerTest::CountPkts,
this));
356 Simulator::Stop(simTime);
359 double dataRecvDl = 0;
360 double dataRecvUl = 0;
364 for (uint32_t i = 0; i < serverAppsDl.GetN(); i++)
366 Ptr<UdpServer> serverApp = serverAppsDl.Get(i)->GetObject<UdpServer>();
367 double data = (serverApp->GetReceived() * packetSize * 8);
373 for (uint32_t i = 0; i < serverAppsUl.GetN(); i++)
375 Ptr<UdpServer> serverApp = serverAppsUl.Get(i)->GetObject<UdpServer>();
376 double data = (serverApp->GetReceived() * packetSize * 8);
381 double expectedBitRate =
382 udpRate.GetBitRate() * ueNodes.GetN() * ((m_isUplink && m_isDownlink) ? 2 : 1);
383 NS_TEST_ASSERT_MSG_EQ_TOL(dataRecvDl + dataRecvUl,
385 expectedBitRate * 0.05,
386 "Wrong total DL + UL throughput");
388 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.
@ NGBR_LOW_LAT_EMBB
Non-GBR Low Latency eMBB applications.
SystemSchedulerTest(const std::string &name, uint32_t usersPerNumOfBeams, uint32_t numOfBeams, uint32_t numerology, double bw1, bool isDownlink, bool isUplink, const std::string &schedulerType)
SystemSchedulerTest is a test constructor which is used to initialise the test parameters.
~SystemSchedulerTest() override
~SystemSchedulerTest
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
This test case checks if the throughput obtained per UE is as expected for the specified scheduling l...