5G-LENA nr-v3.3-120-gdac69c56
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
cttc-3gpp-channel-simple-fdm.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/ipv4-global-routing-helper.h"
47#include "ns3/log.h"
48#include "ns3/mobility-module.h"
49#include "ns3/network-module.h"
50#include "ns3/nr-eps-bearer-tag.h"
51#include "ns3/nr-helper.h"
52#include "ns3/nr-module.h"
53#include "ns3/nr-point-to-point-epc-helper.h"
54#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
55
56using namespace ns3;
57
58NS_LOG_COMPONENT_DEFINE("Cttc3gppChannelSimpleFdm");
59
61 false;
64 false;
66
74static void
75SendPacket(Ptr<NetDevice> device, Address& addr, uint32_t packetSize)
76{
77 Ptr<Packet> pkt = Create<Packet>(packetSize);
78 // Adding empty IPV4 header after adding the IPV6 support for NR module.
79 // NrNetDevice::Receive need to peek the header to know the IP protocol.
80 // Since, there are no apps install in this test, this packet will be
81 // dropped in Ipv4L3Protocol::Receive method upon not finding the route.
82 Ipv4Header ipHeader;
83 pkt->AddHeader(ipHeader);
84
85 // the dedicated bearer that we activate in the simulation
86 // will have bearerId = 2
87 NrEpsBearerTag tag(1, 2);
88 pkt->AddPacketTag(tag);
89 device->Send(pkt, addr, Ipv4L3Protocol::PROT_NUMBER);
90}
91
101void
102RxPdcpPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t pdcpDelay)
103{
104 std::cout << "\n Packet PDCP delay:" << pdcpDelay << "\n";
106}
107
118void
119RxRlcPDU(std::string path, uint16_t rnti, uint8_t lcid, uint32_t bytes, uint64_t rlcDelay)
120{
121 std::cout << "\n\n Data received by UE RLC at:" << Simulator::Now() << std::endl;
122 std::cout << "\n rnti:" << rnti << std::endl;
123 std::cout << "\n lcid:" << (unsigned)lcid << std::endl;
124 std::cout << "\n bytes :" << bytes << std::endl;
125 std::cout << "\n delay :" << rlcDelay << std::endl;
127}
128
132void
134{
135 // after recent changes in the EPC UE node ID has changed to 3
136 // dedicated bearer that we have activated has bearer id 2
137 Config::Connect("/NodeList/*/DeviceList/*/NrUeRrc/DataRadioBearerMap/*/NrPdcp/RxPDU",
138 MakeCallback(&RxPdcpPDU));
139 // after recent changes in the EPC UE node ID has changed to 3
140 // dedicated bearer that we have activated has bearer id 2
141 Config::Connect("/NodeList/*/DeviceList/*/NrUeRrc/DataRadioBearerMap/*/NrRlc/RxPDU",
142 MakeCallback(&RxRlcPDU));
143}
144
145int
146main(int argc, char* argv[])
147{
148 uint16_t gNbNum = 1;
149 uint16_t ueNumPergNb = 1;
150 uint16_t numerologyBwp1 = 4;
151 uint16_t numerologyBwp2 = 2;
152 double centralFrequencyBand = 28.1e9;
153 double bandwidthBand = 200e6;
154 double txPowerPerBwp = 4;
155 uint32_t packetSize = 1000;
156 bool isUll = true; // Whether the flow is a low latency type of traffic.
157
158 Time sendPacketTime = Seconds(0.4);
159
160 CommandLine cmd(__FILE__);
161 cmd.AddValue("gNbNum", "The number of gNbs in multiple-ue topology", gNbNum);
162 cmd.AddValue("ueNumPergNb", "The number of UE per gNb in multiple-ue topology", ueNumPergNb);
163 cmd.AddValue("numerologyBwp1", "The numerology to be used in bandwidth part 1", numerologyBwp1);
164 cmd.AddValue("numerologyBwp2", "The numerology to be used in bandwidth part 2", numerologyBwp2);
165 cmd.AddValue("frequency", "The system frequency", centralFrequencyBand);
166 cmd.AddValue("bandwidthBand", "The system bandwidth", bandwidthBand);
167 cmd.AddValue("packetSize", "packet size in bytes", packetSize);
168 cmd.AddValue("isUll", "Enable Uplink", isUll);
169 cmd.Parse(argc, argv);
170
171 int64_t randomStream = 1;
172 // Create the scenario
173 GridScenarioHelper gridScenario;
174 gridScenario.SetRows(1);
175 gridScenario.SetColumns(gNbNum);
176 gridScenario.SetHorizontalBsDistance(5.0);
177 gridScenario.SetBsHeight(10.0);
178 gridScenario.SetUtHeight(1.5);
179 // must be set before BS number
180 gridScenario.SetSectorization(GridScenarioHelper::SINGLE);
181 gridScenario.SetBsNumber(gNbNum);
182 gridScenario.SetUtNumber(ueNumPergNb * gNbNum);
183 gridScenario.SetScenarioHeight(3); // Create a 3x3 scenario where the UE will
184 gridScenario.SetScenarioLength(3); // be distributed.
185 randomStream += gridScenario.AssignStreams(randomStream);
186 gridScenario.CreateScenario();
187
188 Config::SetDefault("ns3::NrEpsBearer::Release", UintegerValue(15));
189
190 Ptr<NrPointToPointEpcHelper> nrEpcHelper = CreateObject<NrPointToPointEpcHelper>();
191 Ptr<IdealBeamformingHelper> idealBeamformingHelper = CreateObject<IdealBeamformingHelper>();
192 Ptr<NrHelper> nrHelper = CreateObject<NrHelper>();
193 Ptr<NrChannelHelper> channelHelper = CreateObject<NrChannelHelper>();
194
195 nrHelper->SetBeamformingHelper(idealBeamformingHelper);
196 nrHelper->SetEpcHelper(nrEpcHelper);
197 // Set the spectrum channel using UMi scenario, default channel condition and 3GPP channel model
198 channelHelper->ConfigureFactories("UMi", "Default", "ThreeGpp");
199 // Disable shadowing
200 channelHelper->SetPathlossAttribute("ShadowingEnabled", BooleanValue(false));
201 // Create one operational band containing one CC with 2 bandwidth parts
203 CcBwpCreator ccBwpCreator;
204 const uint8_t numCcPerBand = 1; // one CC per Band
205
206 // Create the configuration for the CcBwpHelper
207 CcBwpCreator::SimpleOperationBandConf bandConf(centralFrequencyBand,
208 bandwidthBand,
209 numCcPerBand);
210 bandConf.m_numBwp = 2; // two BWPs per CC
211
212 // By using the configuration created, it is time to make the operation band
213 OperationBandInfo band = ccBwpCreator.CreateOperationBandContiguousCc(bandConf);
214 // Set and create channel for this band
215 channelHelper->AssignChannelsToBands({band});
216 allBwps = CcBwpCreator::GetAllBwps({band});
217
218 // Beamforming method
219 idealBeamformingHelper->SetAttribute("BeamformingMethod",
220 TypeIdValue(DirectPathBeamforming::GetTypeId()));
221
222 // Antennas for all the UEs
223 nrHelper->SetUeAntennaAttribute("NumRows", UintegerValue(2));
224 nrHelper->SetUeAntennaAttribute("NumColumns", UintegerValue(4));
225 nrHelper->SetUeAntennaAttribute("AntennaElement",
226 PointerValue(CreateObject<IsotropicAntennaModel>()));
227
228 // Antennas for all the gNbs
229 nrHelper->SetGnbAntennaAttribute("NumRows", UintegerValue(4));
230 nrHelper->SetGnbAntennaAttribute("NumColumns", UintegerValue(8));
231 nrHelper->SetGnbAntennaAttribute("AntennaElement",
232 PointerValue(CreateObject<IsotropicAntennaModel>()));
233
234 uint32_t bwpIdForLowLat = 0;
235 uint32_t bwpIdForVoice = 1;
236
237 // gNb routing between Bearer and bandwidh part
238 nrHelper->SetGnbBwpManagerAlgorithmAttribute("NGBR_LOW_LAT_EMBB",
239 UintegerValue(bwpIdForLowLat));
240 nrHelper->SetGnbBwpManagerAlgorithmAttribute("GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
241
242 // Ue routing between Bearer and bandwidth part
243 nrHelper->SetUeBwpManagerAlgorithmAttribute("NGBR_LOW_LAT_EMBB", UintegerValue(bwpIdForLowLat));
244 nrHelper->SetUeBwpManagerAlgorithmAttribute("GBR_CONV_VOICE", UintegerValue(bwpIdForVoice));
245
246 // Install and get the pointers to the NetDevices
247 NetDeviceContainer gnbNetDev =
248 nrHelper->InstallGnbDevice(gridScenario.GetBaseStations(), allBwps);
249 NetDeviceContainer ueNetDev =
250 nrHelper->InstallUeDevice(gridScenario.GetUserTerminals(), allBwps);
251
252 randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
253 randomStream += nrHelper->AssignStreams(ueNetDev, randomStream);
254
255 // Set the attribute of the netdevice (gnbNetDev.Get (0)) and bandwidth part (0)/(1)
256 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)
257 ->SetAttribute("Numerology", UintegerValue(numerologyBwp1));
258 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)
259 ->SetAttribute("Numerology", UintegerValue(numerologyBwp2));
260 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 0)->SetTxPower(txPowerPerBwp);
261 nrHelper->GetGnbPhy(gnbNetDev.Get(0), 1)->SetTxPower(txPowerPerBwp);
262
263 InternetStackHelper internet;
264 internet.Install(gridScenario.GetUserTerminals());
265 Ipv4InterfaceContainer ueIpIface;
266 ueIpIface = nrEpcHelper->AssignUeIpv4Address(NetDeviceContainer(ueNetDev));
267
268 Simulator::Schedule(sendPacketTime,
269 &SendPacket,
270 gnbNetDev.Get(0),
271 ueNetDev.Get(0)->GetAddress(),
272 packetSize);
273
274 // attach UEs to the closest gNB
275 nrHelper->AttachToClosestGnb(ueNetDev, gnbNetDev);
276
277 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
279 dlpf.localPortStart = 1234;
280 dlpf.localPortEnd = 1235;
281 tft->Add(dlpf);
282 enum NrEpsBearer::Qci q;
283
284 if (isUll)
285 {
287 }
288 else
289 {
291 }
292
293 NrEpsBearer bearer(q);
294 nrHelper->ActivateDedicatedEpsBearer(ueNetDev, bearer, tft);
295
296 Simulator::Schedule(Seconds(0.2), &ConnectPdcpRlcTraces);
297
298 nrHelper->EnableTraces();
299
300 Simulator::Stop(Seconds(1));
301 Simulator::Run();
302 Simulator::Destroy();
303
305 {
306 return EXIT_SUCCESS;
307 }
308 else
309 {
310 return EXIT_FAILURE;
311 }
312}
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()
Get the type id.
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.
This class contains the specification of EPS Bearers.
@ NGBR_LOW_LAT_EMBB
Non-GBR Low Latency eMBB applications.
@ GBR_CONV_VOICE
GBR Conversational Voice.
void SetBsHeight(double h)
SetGnbHeight.
void SetUtHeight(double h)
SetUeHeight.
void SetSectorization(SiteSectorizationType numSectors)
Sets the number of sectors of every site.
static int g_pdcpTraceCallbackCalled
static void SendPacket(Ptr< NetDevice > device, Address &addr, uint32_t packetSize)
static int g_rlcTraceCallbackCalled
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.
uint16_t localPortStart
start of the port number range of the UE
Definition nr-epc-tft.h:118
uint16_t localPortEnd
end of the port number range of the UE
Definition nr-epc-tft.h:119
Operation band information structure.