18#include "ns3/antenna-module.h"
19#include "ns3/config-store.h"
20#include "ns3/core-module.h"
21#include "ns3/grid-scenario-helper.h"
22#include "ns3/internet-module.h"
23#include "ns3/ipv4-global-routing-helper.h"
25#include "ns3/mobility-module.h"
26#include "ns3/network-module.h"
27#include "ns3/nr-eps-bearer-tag.h"
28#include "ns3/nr-helper.h"
29#include "ns3/nr-module.h"
30#include "ns3/nr-point-to-point-epc-helper.h"
39NS_LOG_COMPONENT_DEFINE(
"Cttc3gppChannelSimpleRan");
41static bool g_rxPdcpCallbackCalled =
false;
42static bool g_rxRxRlcPDUCallbackCalled =
false;
52SendPacket(Ptr<NetDevice> device, Address& addr, uint32_t packetSize)
54 Ptr<Packet> pkt = Create<Packet>(packetSize);
55 Ipv4Header ipv4Header;
56 ipv4Header.SetProtocol(UdpL4Protocol::PROT_NUMBER);
57 pkt->AddHeader(ipv4Header);
59 pkt->AddPacketTag(tag);
60 device->Send(pkt, addr, Ipv4L3Protocol::PROT_NUMBER);
73RxPdcpPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t pdcpDelay)
75 std::cout <<
"\n Packet PDCP delay:" << pdcpDelay <<
"\n";
76 g_rxPdcpCallbackCalled =
true;
90RxRlcPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t rlcDelay)
92 std::cout <<
"\n\n Data received at RLC layer at:" << Simulator::Now() << std::endl;
93 std::cout <<
"\n rnti:" << rnti << std::endl;
94 std::cout <<
"\n lcid:" << (unsigned)lcid << std::endl;
95 std::cout <<
"\n bytes :" << bytes << std::endl;
96 std::cout <<
"\n delay :" << rlcDelay << std::endl;
97 g_rxRxRlcPDUCallbackCalled =
true;
106 Config::Connect(
"/NodeList/*/DeviceList/*/NrUeRrc/DataRadioBearerMap/1/NrPdcp/RxPDU",
109 Config::Connect(
"/NodeList/*/DeviceList/*/NrUeRrc/DataRadioBearerMap/1/NrRlc/RxPDU",
119 Config::Connect(
"/NodeList/*/DeviceList/*/NrGnbRrc/UeMap/*/DataRadioBearerMap/*/NrPdcp/RxPDU",
122 Config::Connect(
"/NodeList/*/DeviceList/*/NrGnbRrc/UeMap/*/DataRadioBearerMap/*/NrRlc/RxPDU",
127main(
int argc,
char* argv[])
129 uint16_t numerologyBwp1 = 0;
130 uint32_t udpPacketSize = 1000;
131 double centralFrequencyBand1 = 28e9;
132 double bandwidthBand1 = 400e6;
134 uint16_t ueNumPergNb = 1;
135 bool enableUl =
false;
137 Time sendPacketTime = Seconds(0.4);
139 CommandLine cmd(__FILE__);
140 cmd.AddValue(
"numerologyBwp1",
"The numerology to be used in bandwidth part 1", numerologyBwp1);
141 cmd.AddValue(
"centralFrequencyBand1",
142 "The system frequency to be used in band 1",
143 centralFrequencyBand1);
144 cmd.AddValue(
"bandwidthBand1",
"The system bandwidth to be used in band 1", bandwidthBand1);
145 cmd.AddValue(
"packetSize",
"packet size in bytes", udpPacketSize);
146 cmd.AddValue(
"enableUl",
"Enable Uplink", enableUl);
147 cmd.Parse(argc, argv);
149 int64_t randomStream = 1;
161 gridScenario.SetScenarioHeight(3);
162 gridScenario.SetScenarioLength(3);
166 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
167 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
168 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
169 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
171 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
172 nrHelper->SetEpcHelper(nrEpcHelper);
174 channelHelper->ConfigureFactories(
"UMi",
"Default",
"ThreeGpp");
175 Config::SetDefault(
"ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue(MilliSeconds(0)));
176 channelHelper->SetChannelConditionModelAttribute(
"UpdatePeriod", TimeValue(MilliSeconds(0)));
177 channelHelper->SetPathlossAttribute(
"ShadowingEnabled", BooleanValue(
false));
182 const uint8_t numCcPerBand = 1;
192 channelHelper->AssignChannelsToBands({band1});
195 nrHelper->SetSchedulerAttribute(
"FixedMcsDl", BooleanValue(
true));
196 nrHelper->SetSchedulerAttribute(
"StartingMcsDl", UintegerValue(28));
199 idealBeamformingHelper->SetAttribute(
"BeamformingMethod",
203 nrHelper->SetUeAntennaAttribute(
"NumRows", UintegerValue(2));
204 nrHelper->SetUeAntennaAttribute(
"NumColumns", UintegerValue(4));
205 nrHelper->SetUeAntennaAttribute(
"AntennaElement",
206 PointerValue(CreateObject<IsotropicAntennaModel>()));
209 nrHelper->SetGnbAntennaAttribute(
"NumRows", UintegerValue(4));
210 nrHelper->SetGnbAntennaAttribute(
"NumColumns", UintegerValue(8));
211 nrHelper->SetGnbAntennaAttribute(
"AntennaElement",
212 PointerValue(CreateObject<IsotropicAntennaModel>()));
215 NetDeviceContainer gnbNetDev =
217 NetDeviceContainer ueNetDev =
220 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
221 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
224 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
225 ->SetAttribute(
"Numerology", UintegerValue(numerologyBwp1));
227 InternetStackHelper internet;
229 Ipv4InterfaceContainer ueIpIface;
230 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
234 Simulator::Schedule(sendPacketTime,
237 gnbNetDev.Get(0)->GetAddress(),
242 Simulator::Schedule(sendPacketTime,
245 ueNetDev.Get(0)->GetAddress(),
250 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
254 std::cout <<
"\n Sending data in uplink." << std::endl;
259 std::cout <<
"\n Sending data in downlink." << std::endl;
263 nrHelper->EnableTraces();
265 Simulator::Stop(Seconds(1));
267 Simulator::Destroy();
269 if (g_rxPdcpCallbackCalled && g_rxRxRlcPDUCallbackCalled)
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.
The GridScenarioHelper class.
void SetRows(uint32_t r)
SetRows.
void SetHorizontalBsDistance(double d)
SetHorizontalBsDistance.
void CreateScenario() override
Create the scenario, with the configured parameter.
int64_t AssignStreams(int64_t stream)
void SetColumns(uint32_t c)
SetColumns.
const NodeContainer & GetUserTerminals() const
Get the list of user nodes.
void SetBsNumber(std::size_t n)
Set the number of base stations.
void SetUtNumber(std::size_t n)
Set the number of UT/UE.
const NodeContainer & GetBaseStations() const
Get the list of gnb/base station nodes.
void SetBsHeight(double h)
SetGnbHeight.
void SetUtHeight(double h)
SetUeHeight.
void SetSectorization(SiteSectorizationType numSectors)
Sets the number of sectors of every site.
void ConnectUlPdcpRlcTraces()
static void SendPacket(Ptr< NetDevice > device, Address &addr, uint32_t packetSize)
void ConnectPdcpRlcTraces()
void RxPdcpPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t pdcpDelay)
void RxRlcPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t rlcDelay)
std::vector< std::reference_wrapper< BandwidthPartInfoPtr > > BandwidthPartInfoPtrVector
vector of unique_ptr of BandwidthPartInfo
Minimum configuration requirements for a OperationBand.
Operation band information structure.