18#include "ns3/antenna-module.h"
19#include "ns3/applications-module.h"
20#include "ns3/buildings-helper.h"
21#include "ns3/config-store.h"
22#include "ns3/core-module.h"
23#include "ns3/internet-module.h"
24#include "ns3/ipv4-global-routing-helper.h"
26#include "ns3/mobility-module.h"
27#include "ns3/nr-helper.h"
28#include "ns3/nr-mac-scheduler-tdma-rr.h"
29#include "ns3/nr-module.h"
30#include "ns3/nr-point-to-point-epc-helper.h"
31#include "ns3/point-to-point-helper.h"
36main(
int argc,
char* argv[])
38 std::string scenario =
"UMa";
39 double frequency = 28e9;
40 double bandwidth = 100e6;
41 double mobility =
false;
50 CommandLine cmd(__FILE__);
51 cmd.AddValue(
"scenario",
52 "The scenario for the simulation. Choose among 'RMa', 'UMa', 'UMi', "
53 "'InH-OfficeMixed', 'InH-OfficeOpen'.",
55 cmd.AddValue(
"frequency",
"The central carrier frequency in Hz.", frequency);
56 cmd.AddValue(
"mobility",
57 "If set to 1 UEs will be mobile, when set to 0 UE will be static. By default, "
60 cmd.AddValue(
"logging",
"If set to 0, log components will be disabled.", logging);
61 cmd.Parse(argc, argv);
67 LogComponentEnable(
"ThreeGppPropagationLossModel", LOG_LEVEL_ALL);
80 Config::SetDefault(
"ns3::NrRlcUm::MaxTxBufferSize", UintegerValue(999999999));
84 if (scenario ==
"RMa")
89 else if (scenario ==
"UMa")
94 else if (scenario ==
"UMi-StreetCanyon")
99 else if (scenario ==
"InH-OfficeMixed" || scenario ==
"InH-OfficeOpen")
106 NS_ABORT_MSG(
"Scenario not supported. Choose among 'RMa', 'UMa', 'UMi', "
107 "'InH-OfficeMixed', and 'InH-OfficeOpen'.");
111 NodeContainer gnbNodes;
112 NodeContainer ueNodes;
117 Ptr<ListPositionAllocator> gnbPositionAlloc = CreateObject<ListPositionAllocator>();
118 gnbPositionAlloc->Add(Vector(0.0, 0.0, hBS));
119 gnbPositionAlloc->Add(Vector(0.0, 80.0, hBS));
120 MobilityHelper gnbMobility;
121 gnbMobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
122 gnbMobility.SetPositionAllocator(gnbPositionAlloc);
123 gnbMobility.Install(gnbNodes);
126 MobilityHelper uemobility;
127 uemobility.SetMobilityModel(
"ns3::ConstantVelocityMobilityModel");
128 uemobility.Install(ueNodes);
132 ueNodes.Get(0)->GetObject<MobilityModel>()->SetPosition(
133 Vector(90, 15, hUT));
134 ueNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(
135 Vector(0, speed, 0));
137 ueNodes.Get(1)->GetObject<MobilityModel>()->SetPosition(
138 Vector(30, 50.0, hUT));
139 ueNodes.Get(1)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(
140 Vector(-speed, 0, 0));
144 ueNodes.Get(0)->GetObject<MobilityModel>()->SetPosition(Vector(90, 15, hUT));
145 ueNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(Vector(0, 0, 0));
147 ueNodes.Get(1)->GetObject<MobilityModel>()->SetPosition(Vector(30, 50.0, hUT));
148 ueNodes.Get(1)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(Vector(0, 0, 0));
154 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
155 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
156 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
157 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
158 nrHelper->SetEpcHelper(nrEpcHelper);
166 const uint8_t numCcPerBand = 1;
181 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
183 channelHelper->ConfigureFactories(
187 channelHelper->AssignChannelsToBands({band});
191 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
198 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(2));
199 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(4));
200 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
201 PointerValue(CreateObject<IsotropicAntennaModel>()));
204 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(8));
205 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(8));
206 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
207 PointerValue(CreateObject<IsotropicAntennaModel>()));
210 NetDeviceContainer gnbNetDev = nrHelper->InstallGnbDevice(gnbNodes, allBwps);
211 NetDeviceContainer ueNetDev = nrHelper->InstallUeDevice(ueNodes, allBwps);
213 int64_t randomStream = 1;
214 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
215 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
217 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetTxPower(txPower);
218 nrHelper->GetGnbPhy(gnbNetDev.Get(1), 0)->SetTxPower(txPower);
222 auto [remoteHost, remoteHostIpv4Address] =
223 nrEpcHelper->SetupRemoteHost(
"100Gb/s", 2500, Seconds(0.010));
225 InternetStackHelper internet;
226 internet.Install(ueNodes);
228 Ipv4InterfaceContainer ueIpIface;
229 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
232 uint16_t dlPort = 1234;
233 ApplicationContainer clientApps;
234 ApplicationContainer serverApps;
235 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
237 Ptr<Node> ueNode = ueNodes.Get(u);
238 UdpServerHelper dlPacketSinkHelper(dlPort);
239 serverApps.Add(dlPacketSinkHelper.Install(ueNodes.Get(u)));
241 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort);
242 dlClient.SetAttribute(
"Interval", TimeValue(MicroSeconds(1)));
244 dlClient.SetAttribute(
"MaxPackets", UintegerValue(10));
245 dlClient.SetAttribute(
"PacketSize", UintegerValue(1500));
246 clientApps.Add(dlClient.Install(remoteHost));
250 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
253 serverApps.Start(Seconds(0.4));
254 clientApps.Start(Seconds(0.4));
255 serverApps.Stop(Seconds(simTime));
256 clientApps.Stop(Seconds(simTime - 0.2));
259 nrHelper->EnableTraces();
261 Simulator::Stop(Seconds(simTime));
264 Ptr<UdpServer> serverApp = serverApps.Get(0)->GetObject<UdpServer>();
265 uint64_t receivedPackets = serverApp->GetReceived();
267 Simulator::Destroy();
269 if (receivedPackets == 10)
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.
static TypeId GetTypeId()
GetTypeId.
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
Operation band information structure.