5#include "ns3/antenna-module.h"
6#include "ns3/applications-module.h"
7#include "ns3/core-module.h"
8#include "ns3/internet-module.h"
9#include "ns3/mobility-module.h"
10#include "ns3/network-module.h"
11#include "ns3/nr-eps-bearer-tag.h"
12#include "ns3/nr-module.h"
13#include "ns3/point-to-point-helper.h"
14#include "ns3/three-gpp-channel-model.h"
34class NrTestFdmOfNumerologiesCase1 :
public TestCase
37 NrTestFdmOfNumerologiesCase1(std::string name,
43 ~NrTestFdmOfNumerologiesCase1()
override;
46 void DoRun()
override;
48 uint32_t m_numerology;
56NrTestFdmOfNumerologiesCase1::NrTestFdmOfNumerologiesCase1(std::string name,
64 m_numerology = numerology;
67 m_isDownlink = isDownlnk;
68 m_isUplink = isUplink;
73NrTestFdmOfNumerologiesCase1::~NrTestFdmOfNumerologiesCase1()
78NrTestFdmOfNumerologiesCase1::DoRun()
82 double udpAppStartTime = 0.1;
83 double totalTxPower = 4;
85 uint16_t ueNumPergNb = 2;
86 uint32_t packetSize = 1000;
88 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
89 Config::SetDefault(
"ns3::NrEpsBearer::Release", UintegerValue(15));
91 RngSeedManager::SetSeed(1);
92 RngSeedManager::SetRun(1);
95 NodeContainer gNbNodes;
96 NodeContainer ueNodes;
97 MobilityHelper mobility;
99 double gNbHeight = 10;
100 double ueHeight = 1.5;
102 gNbNodes.Create(gNbNum);
103 ueNodes.Create(ueNumPergNb * gNbNum);
105 Ptr<ListPositionAllocator> apPositionAlloc = CreateObject<ListPositionAllocator>();
106 Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator>();
107 apPositionAlloc->Add(Vector(0.0, 20, gNbHeight));
108 staPositionAlloc->Add(Vector(1, 1, ueHeight));
109 staPositionAlloc->Add(Vector(-1, 1, ueHeight));
110 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
111 mobility.SetPositionAllocator(apPositionAlloc);
112 mobility.Install(gNbNodes);
113 mobility.SetPositionAllocator(staPositionAlloc);
114 mobility.Install(ueNodes);
116 double totalBandwidth = 0;
117 totalBandwidth = m_bw1 + m_bw2;
119 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
120 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
121 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
122 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
124 channelHelper->ConfigureFactories(
"UMi",
"LOS");
126 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
128 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
131 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(2));
132 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(4));
133 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
134 PointerValue(CreateObject<IsotropicAntennaModel>()));
137 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(4));
138 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(8));
139 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
140 PointerValue(CreateObject<IsotropicAntennaModel>()));
142 nrHelper->SetEpcHelper(nrEpcHelper);
147 const uint8_t numCcPerBand = 2;
151 channelHelper->AssignChannelsToBands({band1});
153 band1.
m_cc[0]->m_bwp[0]->m_channelBandwidth = m_bw1;
154 band1.
m_cc[1]->m_bwp[0]->m_channelBandwidth = m_bw2;
158 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(0));
159 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(1));
161 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(0));
162 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"GBR_CONV_VOICE", UintegerValue(1));
165 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
166 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, allBwps);
168 double x = pow(10, totalTxPower / 10);
170 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
171 ->SetAttribute(
"Numerology", UintegerValue(m_numerology));
172 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
173 ->SetAttribute(
"Numerology", UintegerValue(m_numerology));
175 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
176 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw1 / totalBandwidth) * x)));
177 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
178 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw2 / totalBandwidth) * x)));
180 nrHelper->GetUePhy(ueNetDev.Get(0), 0)
181 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw1 / totalBandwidth) * x)));
182 nrHelper->GetUePhy(ueNetDev.Get(0), 1)
183 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw2 / totalBandwidth) * x)));
185 nrHelper->GetUePhy(ueNetDev.Get(1), 0)
186 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw1 / totalBandwidth) * x)));
187 nrHelper->GetUePhy(ueNetDev.Get(1), 1)
188 ->SetAttribute(
"TxPower", DoubleValue(10 * log10((m_bw2 / totalBandwidth) * x)));
190 for (uint32_t j = 0; j < gNbNodes.GetN(); ++j)
193 for (uint8_t bwpId = 0; bwpId < 2; bwpId++)
195 Ptr<const NrSpectrumPhy> txSpectrumPhy =
196 nrHelper->GetGnbPhy(gnbNetDev.Get(j), bwpId)->GetSpectrumPhy();
197 Ptr<SpectrumChannel> txSpectrumChannel = txSpectrumPhy->GetSpectrumChannel();
198 Ptr<ThreeGppPropagationLossModel> propagationLossModel =
199 DynamicCast<ThreeGppPropagationLossModel>(
200 txSpectrumChannel->GetPropagationLossModel());
201 NS_ASSERT(propagationLossModel !=
nullptr);
202 propagationLossModel->AssignStreams(1);
203 Ptr<ChannelConditionModel> channelConditionModel =
204 propagationLossModel->GetChannelConditionModel();
205 channelConditionModel->AssignStreams(1);
206 Ptr<ThreeGppSpectrumPropagationLossModel> spectrumLossModel =
207 DynamicCast<ThreeGppSpectrumPropagationLossModel>(
208 txSpectrumChannel->GetPhasedArraySpectrumPropagationLossModel());
209 NS_ASSERT(spectrumLossModel !=
nullptr);
210 Ptr<ThreeGppChannelModel> channel =
211 DynamicCast<ThreeGppChannelModel>(spectrumLossModel->GetChannelModel());
212 channel->AssignStreams(1);
216 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
219 for (uint8_t bwpId = 0; bwpId < 2; bwpId++)
221 Ptr<const NrSpectrumPhy> txSpectrumPhy =
222 nrHelper->GetUePhy(ueNetDev.Get(j), bwpId)->GetSpectrumPhy();
223 Ptr<SpectrumChannel> txSpectrumChannel = txSpectrumPhy->GetSpectrumChannel();
224 Ptr<ThreeGppPropagationLossModel> propagationLossModel =
225 DynamicCast<ThreeGppPropagationLossModel>(
226 txSpectrumChannel->GetPropagationLossModel());
227 NS_ASSERT(propagationLossModel !=
nullptr);
228 propagationLossModel->AssignStreams(1);
229 Ptr<ChannelConditionModel> channelConditionModel =
230 propagationLossModel->GetChannelConditionModel();
231 channelConditionModel->AssignStreams(1);
232 Ptr<ThreeGppSpectrumPropagationLossModel> spectrumLossModel =
233 DynamicCast<ThreeGppSpectrumPropagationLossModel>(
234 txSpectrumChannel->GetPhasedArraySpectrumPropagationLossModel());
235 NS_ASSERT(spectrumLossModel !=
nullptr);
236 Ptr<ThreeGppChannelModel> channel =
237 DynamicCast<ThreeGppChannelModel>(spectrumLossModel->GetChannelModel());
238 channel->AssignStreams(1);
244 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
245 NodeContainer remoteHostContainer;
246 remoteHostContainer.Create(1);
247 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
248 InternetStackHelper internet;
249 internet.Install(remoteHostContainer);
251 PointToPointHelper p2ph;
252 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
253 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
254 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
255 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
256 Ipv4AddressHelper ipv4h;
257 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
258 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
260 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
262 Ipv4StaticRoutingHelper ipv4RoutingHelper;
263 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
264 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
265 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"), Ipv4Mask(
"255.0.0.0"), 1);
266 internet.Install(ueNodes);
267 Ipv4InterfaceContainer ueIpIface;
268 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
271 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
273 Ptr<Ipv4StaticRouting> ueStaticRouting =
274 ipv4RoutingHelper.GetStaticRouting(ueNodes.Get(j)->GetObject<Ipv4>());
275 ueStaticRouting->SetDefaultRoute(nrEpcHelper->GetUeDefaultGatewayAddress(), 1);
279 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
282 uint16_t dlPort = 1234;
283 uint16_t ulPort = 2000;
284 ApplicationContainer clientAppsDl;
285 ApplicationContainer serverAppsDl;
286 ApplicationContainer clientAppsUl;
287 ApplicationContainer serverAppsUl;
293 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
295 UdpServerHelper ulPacketSinkHelper(ulPort);
296 serverAppsUl.Add(ulPacketSinkHelper.Install(remoteHost));
298 UdpClientHelper ulClient(remoteHostAddr, ulPort);
299 ulClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
300 ulClient.SetAttribute(
"PacketSize", UintegerValue(packetSize));
301 ulClient.SetAttribute(
303 TimeValue(Seconds(0.00001)));
305 clientAppsUl.Add(ulClient.Install(ueNodes.Get(j)));
307 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
325 nrHelper->ActivateDedicatedEpsBearer(ueNetDev.Get(j), bearer, tft);
330 serverAppsUl.Start(Seconds(udpAppStartTime));
331 clientAppsUl.Start(Seconds(udpAppStartTime));
332 serverAppsUl.Stop(Seconds(simTime));
333 clientAppsUl.Stop(Seconds(simTime));
338 UdpServerHelper dlPacketSinkHelper(dlPort);
339 serverAppsDl.Add(dlPacketSinkHelper.Install(ueNodes));
342 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
344 UdpClientHelper dlClient(ueIpIface.GetAddress(j), dlPort);
345 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
346 dlClient.SetAttribute(
"PacketSize", UintegerValue(packetSize));
347 dlClient.SetAttribute(
349 TimeValue(Seconds(0.00001)));
351 clientAppsDl.Add(dlClient.Install(remoteHost));
353 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
371 nrHelper->ActivateDedicatedEpsBearer(ueNetDev.Get(j), bearer, tft);
375 serverAppsDl.Start(Seconds(udpAppStartTime));
376 clientAppsDl.Start(Seconds(udpAppStartTime));
377 serverAppsDl.Stop(Seconds(simTime));
378 clientAppsDl.Stop(Seconds(simTime));
382 Simulator::Stop(Seconds(simTime));
387 Ptr<UdpServer> serverApp1 = serverAppsDl.Get(0)->GetObject<UdpServer>();
388 Ptr<UdpServer> serverApp2 = serverAppsDl.Get(1)->GetObject<UdpServer>();
390 (serverApp1->GetReceived() * (packetSize + 28) * 8) / (simTime - udpAppStartTime);
392 (serverApp2->GetReceived() * (packetSize + 28) * 8) / (simTime - udpAppStartTime);
394 NS_TEST_ASSERT_MSG_EQ_TOL(throughput2,
395 throughput1 * m_bw2 / m_bw1,
396 std::max(throughput1, throughput2) * 0.2,
397 "Throughputs are not equal within tolerance");
398 NS_TEST_ASSERT_MSG_NE(throughput1, 0,
"Throughput should be a non-zero value");
399 std::cout <<
"Total DL UDP throughput 1 (bps):" << throughput1 / 10e6 <<
"Mbps"
401 std::cout <<
"Total DL UDP throughput 2 (bps):" << throughput2 / 10e6 <<
"Mbps"
403 std::cout <<
"\n Test value throughput 1: " << (throughput2 * m_bw1 / m_bw2) / 10e6
404 <<
"Mbps" << std::endl;
405 std::cout <<
"\n Test value throughput 2: " << (throughput1 * m_bw2 / m_bw1) / 10e6
406 <<
"Mbps" << std::endl;
410 Ptr<UdpServer> serverApp1 = serverAppsUl.Get(0)->GetObject<UdpServer>();
411 Ptr<UdpServer> serverApp2 = serverAppsUl.Get(1)->GetObject<UdpServer>();
413 (serverApp1->GetReceived() * (packetSize + 28) * 8) / (simTime - udpAppStartTime);
415 (serverApp2->GetReceived() * (packetSize + 28) * 8) / (simTime - udpAppStartTime);
417 std::cout <<
"\nBw1:" << m_bw1 <<
", bwp2:" << m_bw2 << std::endl;
418 std::cout <<
"Total UL UDP throughput 1 (bps):" << throughput1 / 10e6 <<
"Mbps"
420 std::cout <<
"Total UL UDP throughput 2 (bps):" << throughput2 / 10e6 <<
"Mbps"
422 std::cout <<
"Test expected throughput 1: " << (throughput2 * m_bw1 / m_bw2) / 10e6
423 <<
"Mbps" << std::endl;
424 std::cout <<
"Test expected throughput 2: " << (throughput1 * m_bw2 / m_bw1) / 10e6
425 <<
"Mbps" << std::endl;
427 NS_TEST_ASSERT_MSG_EQ_TOL(throughput2,
428 throughput1 * m_bw2 / m_bw1,
429 std::max(throughput1, throughput2) * 0.5,
430 "Throughputs are not equal within tolerance");
432 NS_TEST_ASSERT_MSG_NE(throughput1, 0,
"Throughput should be a non-zero value");
435 Simulator::Destroy();
442class NrTestFdmOfNumerologiesTestSuiteDlFour :
public TestSuite
445 NrTestFdmOfNumerologiesTestSuiteDlFour();
448NrTestFdmOfNumerologiesTestSuiteDlFour::NrTestFdmOfNumerologiesTestSuiteDlFour()
449 : TestSuite(
"nr-test-fdm-of-numerologies-dl-4", Type::SYSTEM)
453 new NrTestFdmOfNumerologiesCase1(
"fdm dl 4, 50e6, 150e6", 4, 50e6, 150e6,
true,
false),
456 new NrTestFdmOfNumerologiesCase1(
"fdm dl 4, 100e6, 100e6", 4, 100e6, 100e6,
true,
false),
459 new NrTestFdmOfNumerologiesCase1(
"fdm dl 4, 80e6, 120e6", 4, 80e6, 120e6,
true,
false),
462 new NrTestFdmOfNumerologiesCase1(
"fdm dl 4 60e6, 140e6", 4, 60e6, 140e6,
true,
false),
467static NrTestFdmOfNumerologiesTestSuiteDlFour nrTestFdmOfNumerologiesTestSuiteDlFour;
471class NrTestFdmOfNumerologiesTestSuiteDlTwo :
public TestSuite
474 NrTestFdmOfNumerologiesTestSuiteDlTwo();
477NrTestFdmOfNumerologiesTestSuiteDlTwo::NrTestFdmOfNumerologiesTestSuiteDlTwo()
478 : TestSuite(
"nr-test-fdm-of-numerologies-dl-2", Type::SYSTEM)
481 new NrTestFdmOfNumerologiesCase1(
"fdm dl 2 50e6 150e6", 2, 50e6, 150e6,
true,
false),
484 new NrTestFdmOfNumerologiesCase1(
"fdm dl 2 100e6 100e6", 2, 100e6, 100e6,
true,
false),
487 new NrTestFdmOfNumerologiesCase1(
"fdm dl 2 80e6 120e6", 2, 80e6, 120e6,
true,
false),
490 new NrTestFdmOfNumerologiesCase1(
"fdm dl 2 60e6 140e6", 2, 60e6, 140e6,
true,
false),
495static NrTestFdmOfNumerologiesTestSuiteDlTwo nrTestFdmOfNumerologiesTestSuiteDlTwo;
499class NrTestFdmOfNumerologiesTestSuiteUlFour :
public TestSuite
502 NrTestFdmOfNumerologiesTestSuiteUlFour();
505NrTestFdmOfNumerologiesTestSuiteUlFour::NrTestFdmOfNumerologiesTestSuiteUlFour()
506 : TestSuite(
"nr-test-fdm-of-numerologies-ul-4", Type::SYSTEM)
509 new NrTestFdmOfNumerologiesCase1(
"fdm ul 4, 50e6, 150e6", 4, 50e6, 150e6,
false,
true),
512 new NrTestFdmOfNumerologiesCase1(
"fdm ul 4, 100e6, 100e6", 4, 100e6, 100e6,
false,
true),
515 new NrTestFdmOfNumerologiesCase1(
"fdm ul 4, 80e6, 120e6", 4, 80e6, 120e6,
false,
true),
518 new NrTestFdmOfNumerologiesCase1(
"fdm ul 4 60e6, 140e6", 4, 60e6, 140e6,
false,
true),
523static NrTestFdmOfNumerologiesTestSuiteUlFour nrTestFdmOfNumerologiesTestSuiteUlFour;
527class NrTestFdmOfNumerologiesTestSuiteUlTwo :
public TestSuite
530 NrTestFdmOfNumerologiesTestSuiteUlTwo();
533NrTestFdmOfNumerologiesTestSuiteUlTwo::NrTestFdmOfNumerologiesTestSuiteUlTwo()
534 : TestSuite(
"nr-test-fdm-of-numerologies-ul-2", Type::SYSTEM)
537 new NrTestFdmOfNumerologiesCase1(
"fdm ul 2 50e6 150e6", 2, 50e6, 150e6,
false,
true),
547static NrTestFdmOfNumerologiesTestSuiteUlTwo nrTestFdmOfNumerologiesTestSuiteUlTwo;
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.
This class contains the specification of EPS Bearers.
@ NGBR_LOW_LAT_EMBB
Non-GBR Low Latency eMBB applications.
@ GBR_CONV_VOICE
GBR Conversational Voice.
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
uint16_t remotePortEnd
end of the port number range of the remote host
uint16_t localPortStart
start of the port number range of the UE
uint16_t remotePortStart
start of the port number range of the remote host
uint16_t localPortEnd
end of the port number range of the UE
Operation band information structure.
std::vector< ComponentCarrierInfoPtr > m_cc
Operation band component carriers.