5#include "ns3/antenna-module.h"
6#include "ns3/applications-module.h"
7#include "ns3/config-store-module.h"
8#include "ns3/config-store.h"
9#include "ns3/core-module.h"
10#include "ns3/internet-module.h"
11#include "ns3/mobility-module.h"
12#include "ns3/network-module.h"
13#include "ns3/nr-module.h"
14#include "ns3/point-to-point-module.h"
33class TestAntenna3gppModelConf :
public TestCase
36 enum DirectionGnbUeXYAngle
48 TestAntenna3gppModelConf(
const std::string& name,
49 DirectionGnbUeXYAngle conf,
50 bool gNbOmniAntennaElem,
51 bool ueOmniAntennaElem,
52 uint8_t ueNoOfAntennas,
53 std::string losCondition);
54 ~TestAntenna3gppModelConf()
override;
58 void DoRun()
override;
60 DirectionGnbUeXYAngle m_conf;
61 bool m_ueOmniAntennaElem;
62 bool m_gNbOmniAntennaElem;
64 uint8_t m_ueNoOfAntennas;
65 std::string m_losCondition;
66 Ptr<MinMaxAvgTotalCalculator<double>> m_sinrCell1;
67 Ptr<MinMaxAvgTotalCalculator<double>> m_sinrCell2;
68 Ptr<MinMaxAvgTotalCalculator<double>> m_mcsCell1;
69 Ptr<MinMaxAvgTotalCalculator<double>> m_mcsCell2;
70 Ptr<MinMaxAvgTotalCalculator<double>> m_rbNumCell1;
71 Ptr<MinMaxAvgTotalCalculator<double>> m_rbNumCell2;
77 test->UeReception(params);
83 if (params.m_cellId == 1)
85 m_sinrCell1->Update(params.m_sinr);
86 m_mcsCell1->Update(params.m_mcs);
87 m_rbNumCell1->Update(params.m_rbAssignedNum);
89 else if (params.m_cellId == 2)
91 m_sinrCell2->Update(params.m_sinr);
92 m_mcsCell2->Update(params.m_mcs);
93 m_rbNumCell2->Update(params.m_rbAssignedNum);
97 NS_ABORT_MSG(
"Cell does not exist ... ");
101TestAntenna3gppModelConf::TestAntenna3gppModelConf(
const std::string& name,
102 DirectionGnbUeXYAngle conf,
103 bool gNbOmniAntennaElem,
104 bool ueOmniAntennaElem,
105 uint8_t ueNoOfAntennas,
106 std::string losCondition)
111 m_gNbOmniAntennaElem = gNbOmniAntennaElem;
112 m_ueOmniAntennaElem = ueOmniAntennaElem;
113 m_ueNoOfAntennas = ueNoOfAntennas;
114 m_losCondition = losCondition;
115 m_sinrCell1 = Create<MinMaxAvgTotalCalculator<double>>();
116 m_sinrCell2 = Create<MinMaxAvgTotalCalculator<double>>();
117 m_mcsCell1 = Create<MinMaxAvgTotalCalculator<double>>();
118 m_mcsCell2 = Create<MinMaxAvgTotalCalculator<double>>();
119 m_rbNumCell1 = Create<MinMaxAvgTotalCalculator<double>>();
120 m_rbNumCell2 = Create<MinMaxAvgTotalCalculator<double>>();
125TestAntenna3gppModelConf::~TestAntenna3gppModelConf()
130TestAntenna3gppModelConf::DoRun()
132 std::cout <<
"\n\n\n" << m_name << std::endl;
134 Time simTime = MilliSeconds(800);
135 Time udpAppStartTimeDl = MilliSeconds(400);
136 Time udpAppStopTimeDl = MilliSeconds(800);
137 uint32_t packetSize = 1000;
138 DataRate udpRate = DataRate(
"2Mbps");
140 Config::SetDefault(
"ns3::LteRlcUm::MaxTxBufferSize", UintegerValue(999999999));
141 Config::SetDefault(
"ns3::NrEpsBearer::Release", UintegerValue(15));
144 NodeContainer gNbNodes;
145 NodeContainer ueNodes;
146 MobilityHelper mobility;
148 double gNbHeight = 1.5;
149 double ueHeight = 1.5;
153 Ptr<ListPositionAllocator> gNbPositionAlloc = CreateObject<ListPositionAllocator>();
154 Ptr<ListPositionAllocator> uePositionAlloc = CreateObject<ListPositionAllocator>();
156 gNbPositionAlloc->Add(Vector(0, 0, gNbHeight));
158 if (m_conf == DirectionGnbUe_45)
160 uePositionAlloc->Add(Vector(20, 20, ueHeight));
162 else if (m_conf == DirectionGnbUe_135)
164 uePositionAlloc->Add(Vector(-20, 20, ueHeight));
166 else if (m_conf == DirectionGnbUe_225)
168 uePositionAlloc->Add(Vector(-20, -20, ueHeight));
170 else if (m_conf == DirectionGnbUe_315)
172 uePositionAlloc->Add(Vector(20, -20, ueHeight));
174 else if (m_conf == DirectionGnbUe_0)
176 uePositionAlloc->Add(Vector(20, 0, ueHeight));
178 else if (m_conf == DirectionGnbUe_90)
180 uePositionAlloc->Add(Vector(0, 20, ueHeight));
182 else if (m_conf == DirectionGnbUe_180)
184 uePositionAlloc->Add(Vector(-20, 0, ueHeight));
186 else if (m_conf == DirectionGnbUe_270)
188 uePositionAlloc->Add(Vector(0, -20, ueHeight));
191 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
192 mobility.SetPositionAllocator(gNbPositionAlloc);
193 mobility.Install(gNbNodes);
195 mobility.SetPositionAllocator(uePositionAlloc);
196 mobility.Install(ueNodes);
198 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
199 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
200 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
202 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
204 double beamSearchAngleStep = 30.0;
205 idealBeamformingHelper->SetBeamformingAlgorithmAttribute(
"BeamSearchAngleStep",
206 DoubleValue(beamSearchAngleStep));
207 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
210 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(sqrt(m_ueNoOfAntennas)));
211 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(sqrt(m_ueNoOfAntennas)));
212 if (m_ueOmniAntennaElem)
214 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
215 PointerValue(CreateObject<IsotropicAntennaModel>()));
219 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
220 PointerValue(CreateObject<ThreeGppAntennaModel>()));
223 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(4));
224 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(8));
225 if (m_gNbOmniAntennaElem)
227 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
228 PointerValue(CreateObject<IsotropicAntennaModel>()));
232 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
233 PointerValue(CreateObject<ThreeGppAntennaModel>()));
237 nrHelper->SetUePhyAttribute(
"TxPower", DoubleValue(20.0));
240 nrHelper->SetGnbPhyAttribute(
"TxPower", DoubleValue(44.0));
242 nrHelper->SetGnbPhyAttribute(
"Numerology", UintegerValue(3.0));
244 nrHelper->SetEpcHelper(nrEpcHelper);
255 double centralFrequency = 28e9;
256 double bandwidth = 20e6;
257 const uint8_t numCcPerBand = 1;
262 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
264 channelHelper->ConfigureFactories(
"UMi", m_losCondition);
266 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
267 channelHelper->AssignChannelsToBands({band});
270 uint32_t bwpIdForLowLat = 0;
272 nrHelper->SetGnbBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB",
273 UintegerValue(bwpIdForLowLat));
275 nrHelper->SetUeBwpManagerAlgorithmAttribute(
"NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
278 NetDeviceContainer gNbDevs = nrHelper->InstallGnbDevice(gNbNodes, allBwps);
279 NetDeviceContainer ueNetDevs = nrHelper->InstallUeDevice(ueNodes, allBwps);
283 Ptr<Node> pgw = nrEpcHelper->GetPgwNode();
284 NodeContainer remoteHostContainer;
285 remoteHostContainer.Create(1);
286 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
287 InternetStackHelper internet;
288 internet.Install(remoteHostContainer);
290 PointToPointHelper p2ph;
291 p2ph.SetDeviceAttribute(
"DataRate", DataRateValue(DataRate(
"100Gb/s")));
292 p2ph.SetDeviceAttribute(
"Mtu", UintegerValue(2500));
293 p2ph.SetChannelAttribute(
"Delay", TimeValue(Seconds(0.000)));
294 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
295 Ipv4AddressHelper ipv4h;
296 ipv4h.SetBase(
"1.0.0.0",
"255.0.0.0");
297 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
301 Ipv4StaticRoutingHelper ipv4RoutingHelper;
302 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
303 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
304 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address(
"7.0.0.0"), Ipv4Mask(
"255.0.0.0"), 1);
305 internet.Install(ueNodes);
306 Ipv4InterfaceContainer ueIpIface;
307 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDevs));
310 for (uint32_t j = 0; j < ueNodes.GetN(); ++j)
312 Ptr<Ipv4StaticRouting> ueStaticRouting =
313 ipv4RoutingHelper.GetStaticRouting(ueNodes.Get(j)->GetObject<Ipv4>());
314 ueStaticRouting->SetDefaultRoute(nrEpcHelper->GetUeDefaultGatewayAddress(), 1);
318 nrHelper->AttachToClosestGnb(ueNetDevs, gNbDevs);
321 uint16_t dlPort = 1234;
322 ApplicationContainer clientAppsDl;
323 ApplicationContainer serverAppsDl;
326 Time::FromDouble((packetSize * 8) /
static_cast<double>(udpRate.GetBitRate()), Time::S);
328 UdpServerHelper dlPacketSinkHelper(dlPort);
329 serverAppsDl.Add(dlPacketSinkHelper.Install(ueNodes));
331 UdpClientHelper dlClient(ueIpIface.GetAddress(0), dlPort);
332 dlClient.SetAttribute(
"PacketSize", UintegerValue(packetSize));
333 dlClient.SetAttribute(
"Interval", TimeValue(udpInterval));
334 dlClient.SetAttribute(
"MaxPackets", UintegerValue(0xFFFFFFFF));
335 clientAppsDl.Add(dlClient.Install(remoteHost));
337 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
344 nrHelper->ActivateDedicatedEpsBearer(ueNetDevs.Get(0), bearer, tft);
347 serverAppsDl.Start(udpAppStartTimeDl);
348 clientAppsDl.Start(udpAppStartTimeDl);
350 serverAppsDl.Stop(udpAppStopTimeDl);
351 clientAppsDl.Stop(udpAppStopTimeDl);
353 Ptr<NrSpectrumPhy> ue1SpectrumPhy = nrHelper->GetUePhy(ueNetDevs.Get(0), 0)->GetSpectrumPhy();
354 ue1SpectrumPhy->TraceConnectWithoutContext(
"RxPacketTraceUe",
355 MakeBoundCallback(&UETraceReception,
this));
358 Simulator::Stop(simTime);
361 std::cout << serverAppsDl.GetN() << std::endl;
362 Ptr<UdpServer> serverApp1 = serverAppsDl.Get(0)->GetObject<UdpServer>();
365 double throughput1 = (serverApp1->GetReceived() * (packetSize + 28) * 8) /
366 (udpAppStopTimeDl - udpAppStartTimeDl).GetSeconds();
368 std::cout <<
"\n UE: " << throughput1 / 1e6 <<
" Mbps"
369 <<
"\t Avg.SINR:" << 10 * log10(m_sinrCell1->getMean())
370 <<
"\t Avg.MCS:" << m_mcsCell1->getMean()
371 <<
"\t Avg. RB Num:" << m_rbNumCell1->getMean();
373 Simulator::Destroy();
380class Antenna3gppModelConfTestSuite :
public TestSuite
383 Antenna3gppModelConfTestSuite();
386Antenna3gppModelConfTestSuite::Antenna3gppModelConfTestSuite()
387 : TestSuite(
"nr-antenna-3gpp-model-conf", Type::SYSTEM)
389 std::list<TestAntenna3gppModelConf::DirectionGnbUeXYAngle> conf = {
390 TestAntenna3gppModelConf::DirectionGnbUe_45,
391 TestAntenna3gppModelConf::DirectionGnbUe_135,
392 TestAntenna3gppModelConf::DirectionGnbUe_225,
393 TestAntenna3gppModelConf::DirectionGnbUe_315,
394 TestAntenna3gppModelConf::DirectionGnbUe_0,
395 TestAntenna3gppModelConf::DirectionGnbUe_90,
396 TestAntenna3gppModelConf::DirectionGnbUe_180,
397 TestAntenna3gppModelConf::DirectionGnbUe_270};
399 std::list<uint8_t> ueNoOfAntennas = {16};
401 std::list<std::string> losConditions = {
"LOS"};
405 std::list<bool> gNbOmniAntennaElement = {
false,
true};
409 std::list<bool> ueOmniAntennaElement = {
false,
true};
411 for (
const auto& losCondition : losConditions)
413 for (
const auto& c : conf)
415 for (
const auto& oaaGnb : gNbOmniAntennaElement)
417 for (
const auto& oaaUe : ueOmniAntennaElement)
419 for (
const auto& n : ueNoOfAntennas)
421 std::stringstream ss;
424 if (c == TestAntenna3gppModelConf::DirectionGnbUe_45)
426 ss <<
"DirectionGnbUe_45";
428 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_135)
430 ss <<
"DirectionGnbUe_135";
432 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_225)
434 ss <<
"DirectionGnbUe_225";
436 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_315)
438 ss <<
"DirectionGnbUe_315";
440 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_0)
442 ss <<
"DirectionGnbUe_0";
444 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_90)
446 ss <<
"DirectionGnbUe_90";
448 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_180)
450 ss <<
"DirectionGnbUe_180";
452 else if (c == TestAntenna3gppModelConf::DirectionGnbUe_270)
454 ss <<
"DirectionGnbUe_270";
457 ss <<
" , channelCondition: " << losCondition;
459 ss <<
" , UE number of antennas:" << (unsigned)n;
463 ss <<
" , gNB antenna element type: omni";
467 ss <<
" , gNB antenna element type: 3gpp";
472 ss <<
" , UE antenna element type: omni";
476 ss <<
" , UE antenna element type: 3gpp";
479 AddTestCase(
new TestAntenna3gppModelConf(ss.str(),
494static Antenna3gppModelConfTestSuite testSuite;
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.
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
uint16_t localPortStart
start of the port number range of the UE
uint16_t localPortEnd
end of the port number range of the UE
Operation band information structure.
The RxPacketTraceParams struct.