A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-pathloss-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
11
12#include "ns3/building.h"
13#include "ns3/buildings-helper.h"
14#include "ns3/constant-position-mobility-model.h"
15#include "ns3/double.h"
16#include "ns3/enum.h"
17#include "ns3/log.h"
18#include "ns3/mobility-building-info.h"
19#include "ns3/simulator.h"
20#include "ns3/string.h"
21
22using namespace ns3;
23
24NS_LOG_COMPONENT_DEFINE("BuildingsPathlossTest");
25
26/*
27 * Test 1.1 BuildingsPathlossModel Pathloss compound test
28 *
29 * This TestSuite tests the BuildingPathlossModel by reproducing
30 * several communication scenarios
31 */
33 : TestSuite("buildings-pathloss-test", Type::SYSTEM)
34{
35 LogComponentEnable("BuildingsPathlossTest", LOG_LEVEL_ALL);
36
37 double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101
38
40 1,
41 2,
44 137.93,
45 "OH Urban Large city"),
47
49 1,
50 2,
53 137.88,
54 "OH Urban small city"),
56
58 1,
59 2,
62 128.03,
63 "loss OH SubUrban"),
65
67 1,
68 2,
71 109.66,
72 "loss OH OpenAreas"),
74
75 // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
76
77 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
78
80 1,
81 2,
84 148.55,
85 "COST231 Urban Large city"),
87
89 1,
90 2,
93 150.64,
94 "COST231 Urban small city and suburban"),
96
97 // Test #3 2.6 GHz model (Macro<->UE)
98
99 freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101
100
102 1,
103 2,
105 SmallCity,
106 121.83,
107 "2.6GHz model"),
109
110 // Test #4 ITU1411 LOS model (Macro<->UE)
111
112 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
114 1,
115 3,
117 LargeCity,
118 81.00,
119 "ITU1411 LOS"),
121
122 // Test #5 ITU1411 NLOS model (Macro<->UE)
123
124 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
125
127 1,
128 4,
130 LargeCity,
131 143.69,
132 "ITU1411 NLOS"),
134
135 // Test #6 ITUP1238 (HeNB <-> UE)
136
137 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
139 new BuildingsPathlossTestCase(freq, 5, 6, UrbanEnvironment, LargeCity, 88.3855, "ITUP1238"),
141
142 // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
143
144 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
145 // The loss is as in test #2 (large city) plus the building penetration loss
146 // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
148 1,
149 7,
151 LargeCity,
152 155.55,
153 "Okumura Hata Outdoor -> Indoor"),
155
156 // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
157 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
158 // The loss is as in test #4 plus the building penetration loss
159 // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
161 1,
162 8,
164 LargeCity,
165 88.000,
166 "ITU1411 LOS Outdoor -> Indoor"),
168
169 // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
170
171 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
172 // The loss is similar of test #4 plus the building penetration loss
173 // which for ConcreteWithWindows is equal to 7 dB and the height gain
174 // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
176 9,
177 10,
179 LargeCity,
180 84.838,
181 "ITU1411 LOS Indoor -> Outdoor"),
183
184 // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
185
186 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
187 // The loss is similar as in test #4 plus the building penetration loss
188 // which for ConcreteWithWindows is equal to 7 dB and the height gain
189 // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
191 9,
192 11,
194 LargeCity,
195 183.90,
196 "ITU1411 NLOS Indoor -> Outdoor"),
198}
199
200/// Static variable for test initialization
202
203/*
204 * TestCase
205 */
206
208 uint16_t m1,
209 uint16_t m2,
210 EnvironmentType env,
211 CitySize city,
212 double refValue,
213 std::string name)
214 : TestCase("LOSS calculation: " + name),
215 m_freq(freq),
218 m_env(env),
219 m_city(city),
220 m_lossRef(refValue)
221{
222}
223
227
228void
230{
231 NS_LOG_FUNCTION(this);
232
233 // the building basically occupies the negative x plane, so any node
234 // in this area will fall in the building
236 building1->SetBoundaries(Box(-3000, -1, -4000, 4000.0, 0.0, 12));
237 building1->SetBuildingType(Building::Residential);
238 building1->SetExtWallsType(Building::ConcreteWithWindows);
239 building1->SetNFloors(3);
240
243
244 Ptr<HybridBuildingsPropagationLossModel> propagationLossModel =
246 propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
247 propagationLossModel->SetAttribute("Environment", EnumValue(m_env));
248 propagationLossModel->SetAttribute("CitySize", EnumValue(m_city));
249 // cancel shadowing effect
250 propagationLossModel->SetAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
251 propagationLossModel->SetAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
252 propagationLossModel->SetAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
253
254 double loss = propagationLossModel->GetLoss(mma, mmb);
255
256 NS_LOG_INFO("Calculated loss: " << loss);
257 NS_LOG_INFO("Theoretical loss: " << m_lossRef);
258
259 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss !");
261}
262
265{
266 /*
267 * The purpose of this method is to defer the creation of the
268 * MobilityModel instances to when DoRun() is called. In a previous
269 * version, MobilityModel instances where created directly in the
270 * constructor of the test suite, which caused subtle bugs due to
271 * "static initialization order fiasco". An example of such a subtle
272 * bug is that logging via NS_LOG failed for some modules.
273 *
274 */
275
276 double hm = 1;
277 double hb = 30;
278 double henbHeight = 10.0;
279
281
282 switch (index)
283 {
284 case 1:
286 mm->SetPosition(Vector(0.0, 0.0, hb));
287 break;
288
289 case 2:
291 mm->SetPosition(Vector(2000, 0.0, hm));
292 break;
293
294 case 3:
296 mm->SetPosition(Vector(100, 0.0, hm));
297 break;
298
299 case 4:
301 mm->SetPosition(Vector(900, 0.0, hm));
302 break;
303
304 case 5:
306 mm->SetPosition(Vector(-5, 0.0, hm));
307 break;
308
309 case 6:
311 mm->SetPosition(Vector(-5, 30, henbHeight));
312 break;
313
314 case 7:
316 mm->SetPosition(Vector(-2000, 0.0, hm));
317 break;
318
319 case 8:
321 mm->SetPosition(Vector(-100, 0.0, hm));
322 break;
323
324 case 9:
326 mm->SetPosition(Vector(0, 0.0, hm));
327 break;
328
329 case 10:
331 mm->SetPosition(Vector(-100, 0.0, henbHeight));
332 break;
333
334 case 11:
336 mm->SetPosition(Vector(-500, 0.0, henbHeight));
337 break;
338
339 default:
340 mm = nullptr;
341 break;
342 }
344 mm->AggregateObject(buildingInfo); // operation usually done by BuildingsHelper::Install
345 buildingInfo->MakeConsistent(mm);
346 return mm;
347}
static BuildingsPathlossTestSuite buildingsPathlossTestSuite
Static variable for test initialization.
Test 1.1 BuildingsPathlossModel Pathloss test.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a mobility model based on its index.
uint16_t m_mobilityModelIndex2
Second MobilityModel Index.
double m_lossRef
Theoretical loss.
double m_freq
Communication frequency.
EnvironmentType m_env
Environment type.
uint16_t m_mobilityModelIndex1
First MobilityModel Index.
BuildingsPathlossTestCase(double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
Constructor.
Test 1.1 BuildingsPathlossModel Pathloss compound test.
a 3d box
Definition box.h:24
@ ConcreteWithWindows
Definition building.h:58
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
@ QUICK
Fast test.
Definition test.h:1055
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1274
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:490
static constexpr auto SYSTEM
Definition test.h:1293
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
EnvironmentType
The type of propagation environment.
CitySize
The size of the city in which propagation takes place.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition test.h:327
const double m1
First component modulus, 232 - 209.
Definition rng-stream.cc:49
const double m2
Second component modulus, 232 - 22853.
Definition rng-stream.cc:52
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105