5G-LENA nr-v3.3-120-gdac69c56
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
lena-v1-utils.cc
1// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "lena-v1-utils.h"
6
7#include "lena-v2-utils.h"
8
9namespace ns3
10{
11
12void
13LenaV1Utils::SetLenaV1SimulatorParameters(const double sector0AngleRad,
14 std::string scenario,
15 NodeContainer enbSector1Container,
16 NodeContainer enbSector2Container,
17 NodeContainer enbSector3Container,
18 NodeContainer ueSector1Container,
19 NodeContainer ueSector2Container,
20 NodeContainer ueSector3Container,
21 Ptr<PointToPointEpcHelper>& epcHelper,
22 Ptr<LteHelper>& lteHelper,
23 NetDeviceContainer& enbSector1NetDev,
24 NetDeviceContainer& enbSector2NetDev,
25 NetDeviceContainer& enbSector3NetDev,
26 NetDeviceContainer& ueSector1NetDev,
27 NetDeviceContainer& ueSector2NetDev,
28 NetDeviceContainer& ueSector3NetDev,
29 bool calibration,
30 bool enableUlPc,
31 SinrOutputStats* sinrStats,
32 PowerOutputStats* powerStats,
33 const std::string& scheduler,
34 uint32_t bandwidthMHz,
35 uint32_t freqScenario,
36 [[maybe_unused]] double downtiltAngle)
37{
38 /*
39 * An example of how the spectrum is being used, for 20 MHz bandwidth..
40 *
41 * centralEarfcnFrequencyBand = 350
42 * |
43 * 200 RB 200 RB 200 RB
44 * |---------------------|---------------------|---------------------|
45 *
46 * 100RB 100RB 100RB 100RB 100RB 100RB
47 * |----------|----------|----------|----------|----------|----------|
48 * DL UL DL UL DL UL
49 *
50 * |-----|----|-----|----|-----|----|-----|----|-----|----|-----|----|
51 * fc_dl fc_ul fc_dl fc_ul fc_dl fc_ul
52 *
53 * For comparison, the 5GLENA FDD NON_OVERLAPPING case is
54 *
55 * Scenario 0: sectors NON_OVERLAPPING in frequency
56 *
57 * FDD scenario 0:
58 *
59 * |--------Band0--------|--------Band1--------|--------Band2--------|
60 * |---------CC0---------|---------CC1---------|---------CC2---------|
61 * |---BWP0---|---BWP1---|---BWP2---|---BWP3---|---BWP4---|---BWP5---|
62 *
63 * Sector i will go in Bandi
64 * DL in the first BWP, UL in the second BWP
65 *
66 */
67
68 uint32_t bandwidthBandDlRB;
69 uint32_t bandwidthBandUlRB;
70
71 if (bandwidthMHz == 20)
72 {
73 bandwidthBandDlRB = 100;
74 bandwidthBandUlRB = 100;
75 }
76 else if (bandwidthMHz == 15)
77 {
78 bandwidthBandDlRB = 75;
79 bandwidthBandUlRB = 75;
80 }
81 else if (bandwidthMHz == 10)
82 {
83 bandwidthBandDlRB = 50;
84 bandwidthBandUlRB = 50;
85 }
86 else if (bandwidthMHz == 5)
87 {
88 bandwidthBandDlRB = 25;
89 bandwidthBandUlRB = 25;
90 }
91 else
92 {
93 NS_ABORT_MSG("The configured bandwidth in MHz not supported:" << bandwidthMHz);
94 }
95
96 uint32_t centralFrequencyBand0Dl;
97 uint32_t centralFrequencyBand0Ul;
98 uint32_t centralFrequencyBand1Dl;
99 uint32_t centralFrequencyBand1Ul;
100 uint32_t centralFrequencyBand2Dl;
101 uint32_t centralFrequencyBand2Ul;
102
103 if (freqScenario == 0) // NON_OVERLAPPING
104 {
105 centralFrequencyBand0Dl = 100; // 2120 MHz
106 centralFrequencyBand0Ul = 200;
107 centralFrequencyBand1Dl = 300;
108 centralFrequencyBand1Ul = 400;
109 centralFrequencyBand2Dl = 500;
110 centralFrequencyBand2Ul = 600;
111 }
112 else
113 {
114 // OVERLAPPING
115 centralFrequencyBand0Dl = 100; // 2120 MHz
116 centralFrequencyBand0Ul = 18100; // 1930 MHz
117 centralFrequencyBand1Dl = 100;
118 centralFrequencyBand1Ul = 18100;
119 centralFrequencyBand2Dl = 100;
120 centralFrequencyBand2Ul = 18100;
121 }
122
123 double txPower;
124 double ueTxPower = 23;
125 std::string pathlossModel;
126 if (scenario == "UMa")
127 {
128 txPower = 43;
129 pathlossModel = "ns3::ThreeGppUmaPropagationLossModel";
130 }
131 else if (scenario == "UMi")
132 {
133 txPower = 30;
134 pathlossModel = "ns3::ThreeGppUmiStreetCanyonPropagationLossModel";
135 }
136 else if (scenario == "RMa")
137 {
138 txPower = 43;
139 pathlossModel = "ns3::ThreeGppRmaPropagationLossModel";
140 }
141 else
142 {
143 NS_FATAL_ERROR("Selected scenario " << scenario
144 << " not valid. Valid values: UMa, UMi, RMa");
145 }
146
147 lteHelper = CreateObject<LteHelper>();
148 lteHelper->SetEpcHelper(epcHelper);
149
150 // ALL SECTORS AND BANDS configuration
151 Config::SetDefault("ns3::FfMacScheduler::UlCqiFilter", EnumValue(FfMacScheduler::PUSCH_UL_CQI));
152 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
153 Config::SetDefault("ns3::LteRlcUm::MaxTxBufferSize", UintegerValue(999999999));
154 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(txPower));
155 Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(ueTxPower));
156 Config::SetDefault("ns3::LteUePhy::NoiseFigure", DoubleValue(9.0));
157 Config::SetDefault("ns3::LteUePhy::EnableRlfDetection", BooleanValue(false));
158 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
159 lteHelper->SetAttribute("PathlossModel",
160 StringValue(pathlossModel)); // for each band the same pathloss model
161
162 // Disable shadowing in calibration, and enable it in non-calibration mode
163 lteHelper->SetPathlossModelAttribute("ShadowingEnabled", BooleanValue(!calibration));
164
165 if (scheduler == "PF")
166 {
167 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
168 }
169 else if (scheduler == "RR")
170 {
171 lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
172 }
173
174 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(enableUlPc));
175
176 if (calibration)
177 {
178 lteHelper->SetEnbAntennaModelType("ns3::IsotropicAntennaModel");
179 }
180 else
181 {
182 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
183 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(130));
184 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0));
185 }
186 lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(bandwidthBandDlRB));
187 lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(bandwidthBandUlRB));
188
189 // SECTOR 1 eNB configuration
190 if (!calibration)
191 {
192 double orientationDegrees = sector0AngleRad * 180.0 / M_PI;
193 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(orientationDegrees));
194 }
195 lteHelper->SetEnbDeviceAttribute("DlEarfcn", UintegerValue(centralFrequencyBand0Dl));
196 lteHelper->SetEnbDeviceAttribute("UlEarfcn", UintegerValue(centralFrequencyBand0Ul));
197 enbSector1NetDev = lteHelper->InstallEnbDevice(enbSector1Container);
198
199 // SECTOR 2 eNB configuration
200 if (!calibration)
201 {
202 double orientationDegrees = sector0AngleRad * 180.0 / M_PI + 120;
203 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(orientationDegrees));
204 }
205
206 lteHelper->SetEnbDeviceAttribute("DlEarfcn", UintegerValue(centralFrequencyBand1Dl));
207 lteHelper->SetEnbDeviceAttribute("UlEarfcn", UintegerValue(centralFrequencyBand1Ul));
208 enbSector2NetDev = lteHelper->InstallEnbDevice(enbSector2Container);
209
210 // SECTOR 3 eNB configuration
211 if (!calibration)
212 {
213 double orientationDegrees = sector0AngleRad * 180.0 / M_PI - 120;
214 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(orientationDegrees));
215 }
216 lteHelper->SetEnbDeviceAttribute("DlEarfcn", UintegerValue(centralFrequencyBand2Dl));
217 lteHelper->SetEnbDeviceAttribute("UlEarfcn", UintegerValue(centralFrequencyBand2Ul));
218 enbSector3NetDev = lteHelper->InstallEnbDevice(enbSector3Container);
219
220 ueSector1NetDev = lteHelper->InstallUeDevice(ueSector1Container);
221 NetDeviceContainer ueNetDevs(ueSector1NetDev);
222 ueSector2NetDev = lteHelper->InstallUeDevice(ueSector2Container);
223 ueNetDevs.Add(ueSector2NetDev);
224 ueSector3NetDev = lteHelper->InstallUeDevice(ueSector3Container);
225
226 int64_t randomStream = 1;
227 randomStream += lteHelper->AssignStreams(enbSector1NetDev, randomStream);
228 randomStream += lteHelper->AssignStreams(enbSector2NetDev, randomStream);
229 randomStream += lteHelper->AssignStreams(enbSector3NetDev, randomStream);
230 randomStream += lteHelper->AssignStreams(ueSector1NetDev, randomStream);
231 randomStream += lteHelper->AssignStreams(ueSector2NetDev, randomStream);
232 randomStream += lteHelper->AssignStreams(ueSector3NetDev, randomStream);
233
234 ueNetDevs.Add(ueSector3NetDev);
235
236 for (auto nd = ueNetDevs.Begin(); nd != ueNetDevs.End(); ++nd)
237 {
238 auto ueNetDevice = DynamicCast<LteUeNetDevice>(*nd);
239 NS_ASSERT(ueNetDevice->GetCcMap().size() == 1);
240 auto uePhy = ueNetDevice->GetPhy();
241
242 uePhy->TraceConnectWithoutContext("ReportCurrentCellRsrpSinr",
243 MakeBoundCallback(&ReportSinrLena, sinrStats));
244 uePhy->TraceConnectWithoutContext("ReportPowerSpectralDensity",
245 MakeBoundCallback(&ReportPowerLena, powerStats));
246 }
247
248 lteHelper->Initialize();
249 auto dlSp = DynamicCast<ThreeGppPropagationLossModel>(
250 lteHelper->GetDownlinkSpectrumChannel()->GetPropagationLossModel());
251 auto ulSp = DynamicCast<ThreeGppPropagationLossModel>(
252 lteHelper->GetUplinkSpectrumChannel()->GetPropagationLossModel());
253
254 NS_ASSERT(dlSp != nullptr);
255 NS_ASSERT(ulSp != nullptr);
256
257 NS_ASSERT(dlSp->GetNext() == nullptr);
258 NS_ASSERT(ulSp->GetNext() == nullptr);
259
260 ObjectFactory f;
261 f.SetTypeId(TypeId::LookupByName("ns3::AlwaysLosChannelConditionModel"));
262 dlSp->SetChannelConditionModel(f.Create<ChannelConditionModel>());
263 ulSp->SetChannelConditionModel(f.Create<ChannelConditionModel>());
264}
265
266void
267LenaV1Utils::ReportSinrLena(SinrOutputStats* stats,
268 uint16_t cellId,
269 uint16_t rnti,
270 [[maybe_unused]] double power,
271 double avgSinr,
272 uint8_t bwpId)
273{
274 LenaV2Utils::ReportSinrNr(stats, cellId, rnti, avgSinr, static_cast<uint16_t>(bwpId));
275}
276
277void
278LenaV1Utils::ReportPowerLena(PowerOutputStats* stats, uint16_t rnti, Ptr<SpectrumValue> txPsd)
279{
280 // Please note that LENA has less output than NR... so we have to save less information.
281 LenaV2Utils::ReportPowerNr(stats, SfnSf(), txPsd, MilliSeconds(0), rnti, 0, 0, 0);
282}
283
284} // namespace ns3