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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Marco Miozzo <marco.miozzo@cttc.es>
18 * Nicola Baldo <nbaldo@cttc.es>
19 */
20
22
23#include <ns3/building.h>
24#include <ns3/buildings-helper.h>
25#include <ns3/constant-position-mobility-model.h>
26#include <ns3/double.h>
27#include <ns3/enum.h>
28#include <ns3/log.h>
29#include <ns3/mobility-building-info.h>
30#include <ns3/simulator.h>
31#include <ns3/string.h>
32
33using namespace ns3;
34
35NS_LOG_COMPONENT_DEFINE("BuildingsPathlossTest");
36
37/*
38 * Test 1.1 BuildingsPathlossModel Pathloss compound test
39 *
40 * This TestSuite tests the BuildingPathlossModel by reproducing
41 * several communication scenarios
42 */
44 : TestSuite("buildings-pathloss-test", Type::SYSTEM)
45{
46 LogComponentEnable("BuildingsPathlossTest", LOG_LEVEL_ALL);
47
48 double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101
49
51 1,
52 2,
55 137.93,
56 "OH Urban Large city"),
57 TestCase::Duration::QUICK);
58
60 1,
61 2,
64 137.88,
65 "OH Urban small city"),
66 TestCase::Duration::QUICK);
67
69 1,
70 2,
73 128.03,
74 "loss OH SubUrban"),
75 TestCase::Duration::QUICK);
76
78 1,
79 2,
82 110.21,
83 "loss OH OpenAreas"),
84 TestCase::Duration::QUICK);
85
86 // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
87
88 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
89
91 1,
92 2,
95 148.55,
96 "COST231 Urban Large city"),
97 TestCase::Duration::QUICK);
98
100 1,
101 2,
103 SmallCity,
104 150.64,
105 "COST231 Urban small city and suburban"),
106 TestCase::Duration::QUICK);
107
108 // Test #3 2.6 GHz model (Macro<->UE)
109
110 freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101
111
113 1,
114 2,
116 SmallCity,
117 121.83,
118 "2.6GHz model"),
119 TestCase::Duration::QUICK);
120
121 // Test #4 ITU1411 LOS model (Macro<->UE)
122
123 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
125 1,
126 3,
128 LargeCity,
129 81.00,
130 "ITU1411 LOS"),
131 TestCase::Duration::QUICK);
132
133 // Test #5 ITU1411 NLOS model (Macro<->UE)
134
135 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
136
138 1,
139 4,
141 LargeCity,
142 143.69,
143 "ITU1411 NLOS"),
144 TestCase::Duration::QUICK);
145
146 // Test #6 ITUP1238 (HeNB <-> UE)
147
148 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
150 new BuildingsPathlossTestCase(freq, 5, 6, UrbanEnvironment, LargeCity, 88.3855, "ITUP1238"),
151 TestCase::Duration::QUICK);
152
153 // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
154
155 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
156 // The loss is as in test #2 (large city) plus the building penetration loss
157 // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
159 1,
160 7,
162 LargeCity,
163 155.55,
164 "Okumura Hata Outdoor -> Indoor"),
165 TestCase::Duration::QUICK);
166
167 // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
168 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
169 // The loss is as in test #4 plus the building penetration loss
170 // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
172 1,
173 8,
175 LargeCity,
176 88.000,
177 "ITU1411 LOS Outdoor -> Indoor"),
178 TestCase::Duration::QUICK);
179
180 // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
181
182 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
183 // The loss is similar of test #4 plus the building penetration loss
184 // which for ConcreteWithWindows is equal to 7 dB and the height gain
185 // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
187 9,
188 10,
190 LargeCity,
191 84.838,
192 "ITU1411 LOS Indoor -> Outdoor"),
193 TestCase::Duration::QUICK);
194
195 // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
196
197 freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
198 // The loss is similar as in test #4 plus the building penetration loss
199 // which for ConcreteWithWindows is equal to 7 dB and the height gain
200 // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
202 9,
203 11,
205 LargeCity,
206 183.90,
207 "ITU1411 NLOS Indoor -> Outdoor"),
208 TestCase::Duration::QUICK);
209}
210
211/// Static variable for test initialization
213
214/*
215 * TestCase
216 */
217
219 uint16_t m1,
220 uint16_t m2,
221 EnvironmentType env,
222 CitySize city,
223 double refValue,
224 std::string name)
225 : TestCase("LOSS calculation: " + name),
226 m_freq(freq),
227 m_mobilityModelIndex1(m1),
228 m_mobilityModelIndex2(m2),
229 m_env(env),
230 m_city(city),
231 m_lossRef(refValue)
232{
233}
234
236{
237}
238
239void
241{
242 NS_LOG_FUNCTION(this);
243
244 // the building basically occupies the negative x plane, so any node
245 // in this area will fall in the building
246 Ptr<Building> building1 = CreateObject<Building>();
247 building1->SetBoundaries(Box(-3000, -1, -4000, 4000.0, 0.0, 12));
248 building1->SetBuildingType(Building::Residential);
249 building1->SetExtWallsType(Building::ConcreteWithWindows);
250 building1->SetNFloors(3);
251
254
255 Ptr<HybridBuildingsPropagationLossModel> propagationLossModel =
256 CreateObject<HybridBuildingsPropagationLossModel>();
257 propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
258 propagationLossModel->SetAttribute("Environment", EnumValue(m_env));
259 propagationLossModel->SetAttribute("CitySize", EnumValue(m_city));
260 // cancel shadowing effect
261 propagationLossModel->SetAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
262 propagationLossModel->SetAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
263 propagationLossModel->SetAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
264
265 double loss = propagationLossModel->GetLoss(mma, mmb);
266
267 NS_LOG_INFO("Calculated loss: " << loss);
268 NS_LOG_INFO("Theoretical loss: " << m_lossRef);
269
270 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss !");
272}
273
276{
277 /*
278 * The purpose of this method is to defer the creation of the
279 * MobilityModel instances to when DoRun() is called. In a previous
280 * version, MobilityModel instances where created directly in the
281 * constructor of the test suite, which caused subtle bugs due to
282 * "static initialization order fiasco". An example of such a subtle
283 * bug is that logging via NS_LOG failed for some modules.
284 *
285 */
286
287 double hm = 1;
288 double hb = 30;
289 double henbHeight = 10.0;
290
292
293 switch (index)
294 {
295 case 1:
296 mm = CreateObject<ConstantPositionMobilityModel>();
297 mm->SetPosition(Vector(0.0, 0.0, hb));
298 break;
299
300 case 2:
301 mm = CreateObject<ConstantPositionMobilityModel>();
302 mm->SetPosition(Vector(2000, 0.0, hm));
303 break;
304
305 case 3:
306 mm = CreateObject<ConstantPositionMobilityModel>();
307 mm->SetPosition(Vector(100, 0.0, hm));
308 break;
309
310 case 4:
311 mm = CreateObject<ConstantPositionMobilityModel>();
312 mm->SetPosition(Vector(900, 0.0, hm));
313 break;
314
315 case 5:
316 mm = CreateObject<ConstantPositionMobilityModel>();
317 mm->SetPosition(Vector(-5, 0.0, hm));
318 break;
319
320 case 6:
321 mm = CreateObject<ConstantPositionMobilityModel>();
322 mm->SetPosition(Vector(-5, 30, henbHeight));
323 break;
324
325 case 7:
326 mm = CreateObject<ConstantPositionMobilityModel>();
327 mm->SetPosition(Vector(-2000, 0.0, hm));
328 break;
329
330 case 8:
331 mm = CreateObject<ConstantPositionMobilityModel>();
332 mm->SetPosition(Vector(-100, 0.0, hm));
333 break;
334
335 case 9:
336 mm = CreateObject<ConstantPositionMobilityModel>();
337 mm->SetPosition(Vector(0, 0.0, hm));
338 break;
339
340 case 10:
341 mm = CreateObject<ConstantPositionMobilityModel>();
342 mm->SetPosition(Vector(-100, 0.0, henbHeight));
343 break;
344
345 case 11:
346 mm = CreateObject<ConstantPositionMobilityModel>();
347 mm->SetPosition(Vector(-500, 0.0, henbHeight));
348 break;
349
350 default:
351 mm = nullptr;
352 break;
353 }
354 Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo>();
355 mm->AggregateObject(buildingInfo); // operation usually done by BuildingsHelper::Install
356 buildingInfo->MakeConsistent(mm);
357 return mm;
358}
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:35
@ ConcreteWithWindows
Definition: building.h:69
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:275
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:338
const double m1
First component modulus, 232 - 209.
Definition: rng-stream.cc:60
const double m2
Second component modulus, 232 - 22853.
Definition: rng-stream.cc:63
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:302
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116