5G-LENA nr-v4.0
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
rem-beam-example.cc
Go to the documentation of this file.
1// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
42#include "ns3/antenna-module.h"
43#include "ns3/config-store.h"
44#include "ns3/core-module.h"
45#include "ns3/internet-module.h"
46#include "ns3/log.h"
47#include "ns3/mobility-module.h"
48#include "ns3/network-module.h"
49#include "ns3/nr-helper.h"
50#include "ns3/nr-module.h"
51
52using namespace ns3;
53
54int
55main(int argc, char* argv[])
56{
57 // gnb antenna parameters
58 uint32_t numRowsGnb = 1;
59 uint32_t numColumnsGnb = 1;
60 uint16_t sector = 0;
61 double theta = 60;
62 double simTime = 1;
63
64 // Rem parameters
65 double xMin = -1000.0;
66 double xMax = 1000.0;
67 uint16_t xRes = 100;
68 double yMin = -1000.0;
69 double yMax = 1000.0;
70 uint16_t yRes = 100;
71 std::string simTag = "";
72
73 CommandLine cmd(__FILE__);
74 cmd.AddValue("simTag", "The simTag to be used for REM files creation", simTag);
75 cmd.AddValue("numRowsGnb", "Number of rows for the gNB antenna", numRowsGnb);
76 cmd.AddValue("numColumnsGnb", "Number of columns for the gNB antenna", numColumnsGnb);
77 cmd.AddValue("sector", "sector to be configured for", sector);
78 cmd.AddValue("theta", "thea angle to be configured", theta);
79 cmd.AddValue("xMin", "The min x coordinate of the rem map", xMin);
80 cmd.AddValue("xMax", "The max x coordinate of the rem map", xMax);
81 cmd.AddValue("xRes", "The resolution on the x axis of the rem map", xRes);
82 cmd.AddValue("yMin", "The min y coordinate of the rem map", yMin);
83 cmd.AddValue("yMax", "The max y coordinate of the rem map", yMax);
84 cmd.AddValue("yRes", "The resolution on the y axis of the rem map", yRes);
85
86 cmd.Parse(argc, argv);
87
88 // create gNB and UE
89 NodeContainer gnbNodes;
90 NodeContainer ueNodes;
91 gnbNodes.Create(1);
92 ueNodes.Create(1);
93
94 // install mobility and initialize positions
95 MobilityHelper mobility;
96 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
97 mobility.Install(gnbNodes);
98 gnbNodes.Get(0)->GetObject<MobilityModel>()->SetPosition(Vector(0, 0, 10));
99 mobility.Install(ueNodes);
100 ueNodes.Get(0)->GetObject<MobilityModel>()->SetPosition(Vector(10, 10, 1.5));
101
102 // Create and configure helpers
103 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
104 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
105 idealBeamformingHelper->SetAttribute("BeamformingMethod",
107 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
108
109 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
110 nrHelper->SetEpcHelper(nrEpcHelper);
111
112 /*
113 * Create spectrum configuration: a single operational band with 1 CC and 1 BWP.
114 *
115 * |---------------Band---------------|
116 * |---------------CC-----------------|
117 * |---------------BWP----------------|
118 */
120 CcBwpCreator ccBwpCreator;
121 const uint8_t numCcPerBand = 1;
122
123 CcBwpCreator::SimpleOperationBandConf bandConf(2e9, 20e6, numCcPerBand);
124 OperationBandInfo band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
125 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
126 // Use the default spectrum channel: RMa - Default - ThreeGpp
127 channelHelper->ConfigureFactories();
128 // Set attributes to the spectrum channel and set it to the band.
129 channelHelper->SetChannelConditionModelAttribute("UpdatePeriod", TimeValue(MilliSeconds(0)));
130 channelHelper->SetPathlossAttribute("ShadowingEnabled", BooleanValue(false));
131 channelHelper->AssignChannelsToBands({band});
132 singleBwp = CcBwpCreator::GetAllBwps({band});
133
134 // Antennas for the UEs
135 nrHelper->SetUeAntennaAttribute("NumRows", UintegerValue(1));
136 nrHelper->SetUeAntennaAttribute("NumColumns", UintegerValue(1));
137 nrHelper->SetUeAntennaAttribute("AntennaElement",
138 PointerValue(CreateObject<IsotropicAntennaModel>()));
139
140 // Configuration of phy and antenna for the gNbs
141 nrHelper->SetGnbPhyAttribute("TxPower", DoubleValue(10));
142 nrHelper->SetGnbPhyAttribute("Numerology", UintegerValue(0));
143 nrHelper->SetGnbAntennaAttribute("NumRows", UintegerValue(numRowsGnb));
144 nrHelper->SetGnbAntennaAttribute("NumColumns", UintegerValue(numColumnsGnb));
145 nrHelper->SetGnbAntennaAttribute("AntennaElement",
146 PointerValue(CreateObject<ThreeGppAntennaModel>()));
147
148 // install nr net devices
149 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gnbNodes, singleBwp);
150 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, singleBwp);
151
152 int64_t randomStream = 1;
153 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
154 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
155
156 // install the IP stack on the UEs, this is needed to allow attachment
157 InternetStackHelper internet;
158 internet.Install(ueNodes);
159 nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
160
161 // we need to attach UEs to gNB so that they obtain the same configuration of channel as gNB
162 nrHelper->AttachToGnb(ueNetDev.Get(0), gnbNetDev.Get(0));
163
164 // configure REM parameters
165 Ptr<NrRadioEnvironmentMapHelper> remHelper = CreateObject<NrRadioEnvironmentMapHelper>();
166 remHelper->SetMinX(xMin);
167 remHelper->SetMaxX(xMax);
168 remHelper->SetResX(xRes);
169 remHelper->SetMinY(yMin);
170 remHelper->SetMaxY(yMax);
171 remHelper->SetResY(yRes);
172 remHelper->SetSimTag(simTag);
173 remHelper->SetRemMode(NrRadioEnvironmentMapHelper::BEAM_SHAPE);
174
175 // configure beam that will be shown in REM map
176 DynamicCast<NrGnbNetDevice>(gnbNetDev.Get(0))
177 ->GetPhy(0)
178 ->GetSpectrumPhy()
179 ->GetBeamManager()
180 ->SetSector(sector, theta);
181 DynamicCast<NrUeNetDevice>(ueNetDev.Get(0))
182 ->GetPhy(0)
183 ->GetSpectrumPhy()
184 ->GetBeamManager()
185 ->ChangeToQuasiOmniBeamformingVector();
186 remHelper->CreateRem(gnbNetDev, ueNetDev.Get(0), 0);
187
188 Simulator::Stop(Seconds(simTime));
189 Simulator::Run();
190 Simulator::Destroy();
191 return 0;
192}
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.
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
Operation band information structure.