1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License version 2 as |
|
7 * published by the Free Software Foundation; |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 * |
|
18 * Author: Marco Miozzo <marco.miozzo@cttc.es> |
|
19 */ |
|
20 |
|
21 #include "ns3/simulator.h" |
|
22 |
|
23 #include "ns3/log.h" |
|
24 |
|
25 #include "ns3/spectrum-test.h" |
|
26 |
|
27 #include "ns3/lte-phy-tag.h" |
|
28 #include "ns3/lte-test-ue-phy.h" |
|
29 #include "ns3/lte-sinr-chunk-processor.h" |
|
30 |
|
31 #include "ns3/lte-test-pathloss-model.h" |
|
32 #include <ns3/buildings-propagation-loss-model.h> |
|
33 #include <ns3/node-container.h> |
|
34 #include <ns3/mobility-helper.h> |
|
35 #include <ns3/lena-helper.h> |
|
36 #include <ns3/single-model-spectrum-channel.h> |
|
37 #include "ns3/string.h" |
|
38 #include "ns3/double.h" |
|
39 #include <ns3/building.h> |
|
40 #include <ns3/enum.h> |
|
41 #include <ns3/net-device-container.h> |
|
42 #include <ns3/lte-ue-net-device.h> |
|
43 #include <ns3/lte-enb-net-device.h> |
|
44 #include <ns3/lte-ue-rrc.h> |
|
45 #include <ns3/lena-helper.h> |
|
46 #include <ns3/lte-enb-phy.h> |
|
47 #include <ns3/lte-ue-phy.h> |
|
48 #include "lte-test-sinr-chunk-processor.h" |
|
49 |
|
50 NS_LOG_COMPONENT_DEFINE ("LtePathlossModelTest"); |
|
51 |
|
52 using namespace ns3; |
|
53 |
|
54 |
|
55 /** |
|
56 * Test 1.1 Pathloss compound test |
|
57 */ |
|
58 |
|
59 /** |
|
60 * This TestSuite tests the BuildingPathlossModel by reproducing |
|
61 * several communication scenarios |
|
62 */ |
|
63 |
|
64 |
|
65 void |
|
66 LteTestPathlossDlSchedCallback (LtePathlossModelSystemTestCase *testcase, std::string path, |
|
67 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, |
|
68 uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) |
|
69 { |
|
70 testcase->DlScheduling (frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); |
|
71 } |
|
72 |
|
73 |
|
74 |
|
75 LtePathlossModelTestSuite::LtePathlossModelTestSuite () |
|
76 : TestSuite ("lte-pathloss-model", SYSTEM) |
|
77 { |
|
78 |
|
79 |
|
80 // -------------- COMPOUND TESTS ---------------------------------- |
|
81 |
|
82 LogComponentEnable ("LtePathlossModelTest", LOG_LEVEL_ALL); |
|
83 |
|
84 // NS_LOG_INFO ("Creating LteDownlinkSinrTestSuite"); |
|
85 |
|
86 Ptr<LenaHelper> lena = CreateObject<LenaHelper> (); |
|
87 |
|
88 lena->SetAttribute ("PropagationModel", StringValue ("ns3::BuildingsPropagationLossModel")); |
|
89 |
|
90 // Create Nodes: eNodeB, home eNB, UE and home UE (UE attached to HeNB) |
|
91 NodeContainer enbNodes; |
|
92 NodeContainer henbNodes; |
|
93 NodeContainer ueNodes; |
|
94 NodeContainer hueNodes; |
|
95 enbNodes.Create (1); |
|
96 henbNodes.Create (2); |
|
97 ueNodes.Create (5); |
|
98 hueNodes.Create (3); |
|
99 |
|
100 // Install Mobility Model |
|
101 MobilityHelper mobility; |
|
102 mobility.SetMobilityModel ("ns3::BuildingsMobilityModel"); |
|
103 mobility.Install (enbNodes); |
|
104 mobility.Install (henbNodes); |
|
105 mobility.Install (ueNodes); |
|
106 mobility.Install (hueNodes); |
|
107 |
|
108 NetDeviceContainer enbDevs; |
|
109 NetDeviceContainer henbDevs; |
|
110 NetDeviceContainer ueDevs; |
|
111 NetDeviceContainer hueDevs; |
|
112 enbDevs = lena->InstallEnbDevice (enbNodes); |
|
113 ueDevs = lena->InstallUeDevice (ueNodes); |
|
114 henbDevs = lena->InstallEnbDevice (henbNodes); |
|
115 hueDevs = lena->InstallUeDevice (hueNodes); |
|
116 |
|
117 |
|
118 |
|
119 lena->Attach (ueDevs, enbDevs.Get (0)); |
|
120 lena->Attach (hueDevs, henbDevs.Get (0)); |
|
121 |
|
122 // Test #1 Okumura Hata Model (150 < freq < 1500 MHz) (Macro<->UE) |
|
123 |
|
124 double distance = 2000; |
|
125 double hm = 1; |
|
126 double hb = 30; |
|
127 double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101 |
|
128 Ptr<BuildingsMobilityModel> mm1 = enbNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
129 mm1->SetPosition (Vector (0.0, 0.0, hb)); |
|
130 |
|
131 Ptr<BuildingsMobilityModel> mm2 = ueNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
132 mm2->SetPosition (Vector (distance, 0.0, hm)); |
|
133 |
|
134 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 137.93, "OH Urban Large city = ??")); |
|
135 |
|
136 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Small, 137.88, "OH Urban small city = ??")); |
|
137 |
|
138 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::SubUrban, BuildingsPropagationLossModel::Large, 128.03, "loss OH SubUrban")); |
|
139 |
|
140 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::OpenAreas, BuildingsPropagationLossModel::Large, 110.21, "loss OH OpenAreas")); |
|
141 |
|
142 // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE) |
|
143 |
|
144 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
145 |
|
146 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 148.55, "COST231 Urban Large city")); |
|
147 |
|
148 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Small, 150.64, "COST231 Urban small city and suburban")); |
|
149 |
|
150 // Test #3 2.6 GHz model (Macro<->UE) |
|
151 |
|
152 freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101 |
|
153 |
|
154 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm2, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Small, 121.83, "2.6GHz model")); |
|
155 |
|
156 // Test #4 ITU1411 LOS model (Macro<->UE) |
|
157 |
|
158 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
159 distance = 100; |
|
160 Ptr<BuildingsMobilityModel> mm3 = ueNodes.Get (1)->GetObject<BuildingsMobilityModel> (); |
|
161 mm3->SetPosition (Vector (distance, 0.0, hm)); |
|
162 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm3, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 81.00, "ITU1411 LOS")); |
|
163 |
|
164 // Test #5 ITU1411 NLOS model (Macro<->UE) |
|
165 |
|
166 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
167 distance = 900; |
|
168 |
|
169 Ptr<BuildingsMobilityModel> mm4 = ueNodes.Get (2)->GetObject<BuildingsMobilityModel> (); |
|
170 mm4->SetPosition (Vector (distance, 0.0, hm)); |
|
171 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm4, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 143.69, "ITU1411 NLOS")); |
|
172 |
|
173 // Test #6 ITUP1238 (HeNB <-> UE) |
|
174 |
|
175 distance = 30; |
|
176 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
177 double henbHeight = 10.0; |
|
178 Ptr<BuildingsMobilityModel> mm5 = henbNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
179 mm5->SetPosition (Vector (0.0, 0.0, henbHeight)); |
|
180 Ptr<Building> building1 = Create<Building> (0.0, 10.0, 0.0, 10.0, 0.0, 20.0/*, 1, 1, 1*/); |
|
181 building1->SetBuildingType (Building::Residential); |
|
182 building1->SetExtWallsType (Building::ConcreteWithWindows); |
|
183 mm5->SetIndoor (building1); |
|
184 Ptr<BuildingsMobilityModel> mm6 = hueNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
185 mm6->SetPosition (Vector (distance, 0.0, hm)); |
|
186 mm6->SetIndoor (building1); |
|
187 mm6->SetFloorNumber (2); |
|
188 AddTestCase (new LtePathlossModelTestCase (freq, mm5, mm6, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 88.3855, "ITUP1238")); |
|
189 |
|
190 // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE) |
|
191 |
|
192 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
193 distance = 2000; |
|
194 // The loss is as in test #2 (large city) plus the building penetration loss |
|
195 // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55 |
|
196 Ptr<BuildingsMobilityModel> mm7 = ueNodes.Get (3)->GetObject<BuildingsMobilityModel> (); |
|
197 mm7->SetPosition (Vector (distance, 0.0, hm)); |
|
198 mm7->SetIndoor (building1); |
|
199 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm7, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 155.55, "Okumura Hata Outdoor -> Indoor")); |
|
200 |
|
201 // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE) |
|
202 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
203 distance = 100; |
|
204 Ptr<BuildingsMobilityModel> mm8 = ueNodes.Get (4)->GetObject<BuildingsMobilityModel> (); |
|
205 mm8->SetPosition (Vector (distance, 0.0, hm)); |
|
206 mm8->SetIndoor (building1); |
|
207 // The loss is as in test #4 plus the building penetration loss |
|
208 // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000 |
|
209 AddTestCase (new LtePathlossModelTestCase (freq, mm1, mm8, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 88.000, "ITU1411 LOS Outdoor -> Indoor")); |
|
210 |
|
211 // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE) |
|
212 |
|
213 distance = 100; |
|
214 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
215 Ptr<BuildingsMobilityModel> mm9 = henbNodes.Get (1)->GetObject<BuildingsMobilityModel> (); |
|
216 mm9->SetPosition (Vector (0.0, 0.0, henbHeight)); |
|
217 mm9->SetIndoor (building1); |
|
218 mm9->SetFloorNumber (2); |
|
219 Ptr<BuildingsMobilityModel> mm10 = hueNodes.Get (1)->GetObject<BuildingsMobilityModel> (); |
|
220 mm10->SetPosition (Vector (distance, 0.0, hm)); |
|
221 // The loss is similar of test #4 plus the building penetration loss |
|
222 // which for ConcreteWithWindows is equal to 7 dB and the height gain |
|
223 // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838 |
|
224 AddTestCase (new LtePathlossModelTestCase (freq, mm9, mm10, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 84.838, "ITU1411 LOS Indoor -> Outdoor")); |
|
225 |
|
226 // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE) |
|
227 |
|
228 distance = 500; |
|
229 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101 |
|
230 Ptr<BuildingsMobilityModel> mm11 = hueNodes.Get (2)->GetObject<BuildingsMobilityModel> (); |
|
231 mm11->SetPosition (Vector (distance, 0.0, hm)); |
|
232 // The loss is similar as in test #4 plus the building penetration loss |
|
233 // which for ConcreteWithWindows is equal to 7 dB and the height gain |
|
234 // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90 |
|
235 AddTestCase (new LtePathlossModelTestCase (freq, mm9, mm11, BuildingsPropagationLossModel::Urban, BuildingsPropagationLossModel::Large, 183.90, "ITU1411 NLOS Indoor -> Outdoor")); |
|
236 |
|
237 |
|
238 //------------------- SYSTEM TEST ------------------------------ |
|
239 |
|
240 LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); |
|
241 // |
|
242 // LogComponentEnable ("LenaHelper", logLevel); |
|
243 LogComponentEnable ("LtePathlossModelTest", logLevel); |
|
244 // LogComponentEnable ("BuildingsPropagationLossModel", logLevel); |
|
245 // LogComponentEnable ("LteInterference", logLevel); |
|
246 // LogComponentEnable ("LteSpectrumValueHelper", logLevel); |
|
247 |
|
248 |
|
249 struct SnrEfficiencyMcs |
|
250 { |
|
251 double snrDb; |
|
252 double efficiency; |
|
253 int mcsIndex; |
|
254 }; |
|
255 |
|
256 /** |
|
257 * Test vectors: SNRDB, Spectral Efficiency, MCS index |
|
258 * From XXX |
|
259 */ |
|
260 SnrEfficiencyMcs snrEfficiencyMcs[] = { |
|
261 { -5.00000, 0.08024, -1}, |
|
262 { -4.00000, 0.10030, -1}, |
|
263 { -3.00000, 0.12518, -1}, |
|
264 { -2.00000, 0.15589, 0}, |
|
265 { -1.00000, 0.19365, 0}, |
|
266 { 0.00000, 0.23983, 2}, |
|
267 { 1.00000, 0.29593, 2}, |
|
268 { 2.00000, 0.36360, 2}, |
|
269 { 3.00000, 0.44451, 4}, |
|
270 { 4.00000, 0.54031, 4}, |
|
271 { 5.00000, 0.65251, 6}, |
|
272 { 6.00000, 0.78240, 6}, |
|
273 { 7.00000, 0.93086, 8}, |
|
274 { 8.00000, 1.09835, 8}, |
|
275 { 9.00000, 1.28485, 10}, |
|
276 { 10.00000, 1.48981, 12}, |
|
277 { 11.00000, 1.71229, 12}, |
|
278 { 12.00000, 1.95096, 14}, |
|
279 { 13.00000, 2.20429, 14}, |
|
280 { 14.00000, 2.47062, 16}, |
|
281 { 15.00000, 2.74826, 18}, |
|
282 { 16.00000, 3.03560, 18}, |
|
283 { 17.00000, 3.33115, 20}, |
|
284 { 18.00000, 3.63355, 20}, |
|
285 { 19.00000, 3.94163, 22}, |
|
286 { 20.00000, 4.25439, 22}, |
|
287 { 21.00000, 4.57095, 24}, |
|
288 { 22.00000, 4.89060, 24}, |
|
289 { 23.00000, 5.21276, 26}, |
|
290 { 24.00000, 5.53693, 26}, |
|
291 { 25.00000, 5.86271, 28}, |
|
292 { 26.00000, 6.18980, 28}, |
|
293 { 27.00000, 6.51792, 28}, |
|
294 { 28.00000, 6.84687, 28}, |
|
295 { 29.00000, 7.17649, 28}, |
|
296 { 30.00000, 7.50663, 28}, |
|
297 }; |
|
298 |
|
299 |
|
300 double txPowerDbm = 30; // default eNB TX power over whole bandwdith |
|
301 double txPowerLin = pow (10, (txPowerDbm - 30)/10); |
|
302 double ktDbm = -174; // reference LTE noise PSD |
|
303 double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units |
|
304 double receiverNoiseFigureDb = 9.0; // default UE noise figure |
|
305 double noiseLin = pow (10, (noisePowerDbm-30+receiverNoiseFigureDb)/10); |
|
306 double loss[] = {81.021418, 134.038391, 144.190675}; |
|
307 double dist[] = {100.0, 500.0, 1500}; |
|
308 |
|
309 int numOfTests = sizeof (loss) / sizeof (double); |
|
310 for ( int i = 0 ; i < numOfTests; i++ ) |
|
311 { |
|
312 // double lossDb = txPowerDbm - snrEfficiencyMcs[i].snrDb - noisePowerDbm - receiverNoiseFigureDb; |
|
313 double sinrLin = (txPowerLin/(pow(10, loss[i]/10))) / noiseLin; |
|
314 // double sinrDb = txPowerDbm- noisePowerDbm - receiverNoiseFigureDb - loss[i]; |
|
315 double sinrDb = 10*log10(sinrLin); |
|
316 NS_LOG_INFO (" Ptx " << txPowerDbm << " Pn " << noisePowerDbm << " Fn " << receiverNoiseFigureDb << " Pl " << loss[i] << " dist " << dist[i]); |
|
317 std::ostringstream name; |
|
318 name << " snr= " << sinrDb << " dB, " |
|
319 << " mcs= " << snrEfficiencyMcs[i].mcsIndex; |
|
320 AddTestCase (new LtePathlossModelSystemTestCase (name.str (), sinrDb, dist[i], snrEfficiencyMcs[i].mcsIndex)); |
|
321 } |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 } |
|
328 |
|
329 static LtePathlossModelTestSuite ltePathlossModelTestSuite; |
|
330 |
|
331 |
|
332 /** |
|
333 * TestCase |
|
334 */ |
|
335 |
|
336 LtePathlossModelTestCase::LtePathlossModelTestCase (double freq, Ptr<BuildingsMobilityModel> m1, Ptr<BuildingsMobilityModel> m2, BuildingsPropagationLossModel::Environment env, BuildingsPropagationLossModel::CitySize city, double refValue, std::string name) |
|
337 : TestCase ("LOSS calculation: " + name), |
|
338 m_freq (freq), |
|
339 m_node1 (m1), |
|
340 m_node2 (m2), |
|
341 m_env (env), |
|
342 m_city (city), |
|
343 m_lossRef (refValue) |
|
344 { |
|
345 } |
|
346 |
|
347 LtePathlossModelTestCase::~LtePathlossModelTestCase () |
|
348 { |
|
349 } |
|
350 |
|
351 void |
|
352 LtePathlossModelTestCase::DoRun (void) |
|
353 { |
|
354 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); |
|
355 |
|
356 // LogComponentEnable ("LteEnbRrc", logLevel); |
|
357 // LogComponentEnable ("LteUeRrc", logLevel); |
|
358 // LogComponentEnable ("LteEnbMac", logLevel); |
|
359 // LogComponentEnable ("LteUeMac", logLevel); |
|
360 // LogComponentEnable ("LteRlc", logLevel); |
|
361 // LogComponentEnable ("RrPacketScheduler", logLevel); |
|
362 // |
|
363 // LogComponentEnable ("LtePhy", logLevel); |
|
364 // LogComponentEnable ("LteEnbPhy", logLevel); |
|
365 // LogComponentEnable ("LteUePhy", logLevel); |
|
366 // |
|
367 // LogComponentEnable ("LteSpectrumPhy", logLevel); |
|
368 // LogComponentEnable ("LteInterference", logLevel); |
|
369 // LogComponentEnable ("LteSinrChunkProcessor", logLevel); |
|
370 // |
|
371 // LogComponentEnable ("LtePropagationLossModel", logLevel); |
|
372 // LogComponentEnable ("LossModel", logLevel); |
|
373 // LogComponentEnable ("ShadowingLossModel", logLevel); |
|
374 // LogComponentEnable ("PenetrationLossModel", logLevel); |
|
375 // LogComponentEnable ("MultipathLossModel", logLevel); |
|
376 // LogComponentEnable ("PathLossModel", logLevel); |
|
377 // |
|
378 // LogComponentEnable ("LteNetDevice", logLevel); |
|
379 // LogComponentEnable ("LteUeNetDevice", logLevel); |
|
380 // LogComponentEnable ("LteEnbNetDevice", logLevel); |
|
381 |
|
382 LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); |
|
383 NS_LOG_INFO ("Testing " << GetName()); |
|
384 |
|
385 Ptr<SpectrumChannel> m_downlinkChannel = CreateObject<SingleModelSpectrumChannel> (); |
|
386 Ptr<SpectrumChannel> m_uplinkChannel = CreateObject<SingleModelSpectrumChannel> (); |
|
387 Ptr<BuildingsPropagationLossModel> m_downlinkPropagationLossModel = CreateObject<BuildingsPropagationLossModel> (); |
|
388 m_downlinkPropagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); |
|
389 m_downlinkPropagationLossModel->SetAttribute ("Lambda", DoubleValue (300000000.0 /m_freq)); |
|
390 m_downlinkPropagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); |
|
391 m_downlinkPropagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); |
|
392 // cancel shadowing effect |
|
393 m_downlinkPropagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); |
|
394 m_downlinkPropagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); |
|
395 m_downlinkPropagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); |
|
396 Ptr<BuildingsPropagationLossModel> m_uplinkPropagationLossModel = CreateObject<BuildingsPropagationLossModel> (); |
|
397 m_uplinkPropagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); |
|
398 m_uplinkPropagationLossModel->SetAttribute ("Lambda", DoubleValue (300000000.0 /m_freq)); |
|
399 // cancel shadowing effect |
|
400 m_uplinkPropagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); |
|
401 m_uplinkPropagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); |
|
402 m_uplinkPropagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); |
|
403 m_downlinkChannel->AddPropagationLossModel (m_downlinkPropagationLossModel); |
|
404 m_uplinkChannel->AddPropagationLossModel (m_uplinkPropagationLossModel); |
|
405 |
|
406 |
|
407 |
|
408 Simulator::Stop (Seconds (0.1)); |
|
409 Simulator::Run (); |
|
410 Simulator::Destroy (); |
|
411 double loss = m_downlinkPropagationLossModel->GetLoss (m_node1, m_node2); |
|
412 |
|
413 NS_LOG_INFO ("Calculated loss: " << loss); |
|
414 NS_LOG_INFO ("Theoretical loss: " << m_lossRef); |
|
415 |
|
416 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss !"); |
|
417 } |
|
418 |
|
419 |
|
420 //-------------------- SYSTEM TEST --------------------------------- |
|
421 |
|
422 |
|
423 LtePathlossModelSystemTestCase::LtePathlossModelSystemTestCase (std::string name, double snrDb, double dist, uint16_t mcsIndex) |
|
424 : TestCase (name), |
|
425 m_snrDb (snrDb), |
|
426 m_distance (dist), |
|
427 m_mcsIndex (mcsIndex) |
|
428 { |
|
429 std::ostringstream sstream1, sstream2; |
|
430 sstream1 << " snr=" << snrDb |
|
431 << " mcs=" << mcsIndex << " distance=" << dist; |
|
432 |
|
433 NS_LOG_INFO ("Creating LtePathlossModelSystemTestCase: " + sstream1.str ()); |
|
434 } |
|
435 |
|
436 LtePathlossModelSystemTestCase::~LtePathlossModelSystemTestCase () |
|
437 { |
|
438 } |
|
439 |
|
440 void |
|
441 LtePathlossModelSystemTestCase::DoRun (void) |
|
442 { |
|
443 /** |
|
444 * Simulation Topology |
|
445 */ |
|
446 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); |
|
447 // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL); |
|
448 // LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); |
|
449 // LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); |
|
450 // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); |
|
451 // LogComponentEnable ("SingleModelSpectrumChannel", LOG_LEVEL_ALL); |
|
452 LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); |
|
453 LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL); |
|
454 // LogComponentDisable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); |
|
455 // |
|
456 Ptr<LenaHelper> lena = CreateObject<LenaHelper> (); |
|
457 // lena->EnableLogComponents (); |
|
458 lena->EnableMacTraces (); |
|
459 lena->EnableRlcTraces (); |
|
460 lena->SetAttribute ("PropagationModel", StringValue ("ns3::BuildingsPropagationLossModel")); |
|
461 // set frequency |
|
462 // this should not be done, since it is charge the Helper of this task using the netdevice settings (earfc parameter) |
|
463 double freq = 2.114e+09; |
|
464 lena->SetPropagationModelAttribute ("Frequency", DoubleValue (freq)); |
|
465 lena->SetPropagationModelAttribute ("Lambda", DoubleValue (300000000.0 /freq)); |
|
466 |
|
467 // remove shadowing component |
|
468 lena->SetPropagationModelAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); |
|
469 lena->SetPropagationModelAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); |
|
470 lena->SetPropagationModelAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); |
|
471 |
|
472 // Create Nodes: eNodeB and UE |
|
473 NodeContainer enbNodes; |
|
474 NodeContainer ueNodes; |
|
475 enbNodes.Create (1); |
|
476 ueNodes.Create (1); |
|
477 NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes ); |
|
478 |
|
479 // Install Mobility Model |
|
480 MobilityHelper mobility; |
|
481 mobility.SetMobilityModel ("ns3::BuildingsMobilityModel"); |
|
482 mobility.Install (allNodes); |
|
483 |
|
484 // Create Devices and install them in the Nodes (eNB and UE) |
|
485 NetDeviceContainer enbDevs; |
|
486 NetDeviceContainer ueDevs; |
|
487 lena->SetSchedulerType ("ns3::RrFfMacScheduler"); |
|
488 enbDevs = lena->InstallEnbDevice (enbNodes); |
|
489 ueDevs = lena->InstallUeDevice (ueNodes); |
|
490 |
|
491 Ptr<BuildingsMobilityModel> mm_enb = enbNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
492 mm_enb->SetPosition (Vector (0.0, 0.0, 30.0)); |
|
493 Ptr<BuildingsMobilityModel> mm_ue = ueNodes.Get (0)->GetObject<BuildingsMobilityModel> (); |
|
494 mm_ue->SetPosition (Vector (m_distance, 0.0, 1.0)); |
|
495 |
|
496 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> (); |
|
497 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy (); |
|
498 enbPhy->SetAttribute ("TxPower", DoubleValue (30.0)); |
|
499 enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); |
|
500 |
|
501 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (0)->GetObject<LteUeNetDevice> (); |
|
502 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy (); |
|
503 uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); |
|
504 uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); |
|
505 |
|
506 |
|
507 // Attach a UE to a eNB |
|
508 lena->Attach (ueDevs, enbDevs.Get (0)); |
|
509 |
|
510 |
|
511 // Activate an EPS bearer |
|
512 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
|
513 EpsBearer bearer (q); |
|
514 lena->ActivateEpsBearer (ueDevs, bearer); |
|
515 |
|
516 // Use testing chunk processor in the PHY layer |
|
517 // It will be used to test that the SNR is as intended |
|
518 //Ptr<LtePhy> uePhy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> (); |
|
519 Ptr<LteTestSinrChunkProcessor> testSinr = Create<LteTestSinrChunkProcessor> (uePhy); |
|
520 uePhy->GetDownlinkSpectrumPhy ()->AddSinrChunkProcessor (testSinr); |
|
521 |
|
522 // Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling", |
|
523 // MakeBoundCallback (&LteTestPathlossDlSchedCallback, this)); |
|
524 |
|
525 Simulator::Stop (Seconds (0.005)); |
|
526 Simulator::Run (); |
|
527 |
|
528 double calculatedSinrDb = 10.0 * log10 (testSinr->GetSinr ()[0]); |
|
529 NS_LOG_INFO ("Distance " << m_distance << " Calculated SINR " << calculatedSinrDb << " ref " << m_snrDb); |
|
530 Simulator::Destroy (); |
|
531 NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.001, "Wrong SINR !"); |
|
532 } |
|
533 |
|
534 |
|
535 void |
|
536 LtePathlossModelSystemTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, |
|
537 uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) |
|
538 { |
|
539 static bool firstTime = true; |
|
540 |
|
541 if ( firstTime ) |
|
542 { |
|
543 firstTime = false; |
|
544 NS_LOG_INFO ("SNR\tRef_MCS\tCalc_MCS"); |
|
545 } |
|
546 |
|
547 /** |
|
548 * Note: |
|
549 * For first 4 subframeNo in the first frameNo, the MCS cannot be properly evaluated, |
|
550 * because CQI feedback is still not available at the eNB. |
|
551 */ |
|
552 if ( (frameNo > 1) || (subframeNo > 4) ) |
|
553 { |
|
554 NS_LOG_INFO (m_snrDb << "\t" << m_mcsIndex << "\t" << (uint16_t)mcsTb1); |
|
555 |
|
556 NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcsTb1, m_mcsIndex, "Wrong MCS index"); |
|
557 } |
|
558 } |
|
559 |
|