A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
buildings-pathloss-test.cc
Go to the documentation of this file.
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
* Nicola Baldo <nbaldo@cttc.es>
20
*/
21
22
#include <ns3/simulator.h>
23
24
#include <ns3/log.h>
25
26
#include <ns3/buildings-helper.h>
27
#include <ns3/string.h>
28
#include <ns3/double.h>
29
#include <ns3/building.h>
30
#include <ns3/enum.h>
31
#include <ns3/constant-position-mobility-model.h>
32
#include <ns3/mobility-building-info.h>
33
#include "
buildings-pathloss-test.h
"
34
35
36
37
NS_LOG_COMPONENT_DEFINE
(
"BuildingsPathlossTest"
);
38
39
namespace
ns3 {
40
41
52
BuildingsPathlossTestSuite::BuildingsPathlossTestSuite
()
53
:
TestSuite
(
"buildings-pathloss-test"
, SYSTEM)
54
{
55
56
LogComponentEnable
(
"BuildingsPathlossTest"
,
LOG_LEVEL_ALL
);
57
58
double
freq = 869e6;
// E_UTRA BAND #5 see table 5.5-1 of 36.101
59
60
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
UrbanEnvironment
,
LargeCity
, 137.93,
"OH Urban Large city"
),
TestCase::QUICK
);
61
62
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
UrbanEnvironment
,
SmallCity
, 137.88,
"OH Urban small city"
),
TestCase::QUICK
);
63
64
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
SubUrbanEnvironment
,
LargeCity
, 128.03,
"loss OH SubUrban"
),
TestCase::QUICK
);
65
66
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
OpenAreasEnvironment
,
LargeCity
, 110.21,
"loss OH OpenAreas"
),
TestCase::QUICK
);
67
68
// Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
69
70
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
71
72
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
UrbanEnvironment
,
LargeCity
, 148.55,
"COST231 Urban Large city"
),
TestCase::QUICK
);
73
74
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
UrbanEnvironment
,
SmallCity
, 150.64,
"COST231 Urban small city and suburban"
),
TestCase::QUICK
);
75
76
// Test #3 2.6 GHz model (Macro<->UE)
77
78
freq = 2.620e9;
// E_UTRA BAND #7 see table 5.5-1 of 36.101
79
80
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 2,
UrbanEnvironment
,
SmallCity
, 121.83,
"2.6GHz model"
),
TestCase::QUICK
);
81
82
// Test #4 ITU1411 LOS model (Macro<->UE)
83
84
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
85
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 3,
UrbanEnvironment
,
LargeCity
, 81.00,
"ITU1411 LOS"
),
TestCase::QUICK
);
86
87
// Test #5 ITU1411 NLOS model (Macro<->UE)
88
89
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
90
91
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 4,
UrbanEnvironment
,
LargeCity
, 143.69,
"ITU1411 NLOS"
),
TestCase::QUICK
);
92
93
// Test #6 ITUP1238 (HeNB <-> UE)
94
95
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
96
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 5, 6,
UrbanEnvironment
,
LargeCity
, 88.3855,
"ITUP1238"
),
TestCase::QUICK
);
97
98
// Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
99
100
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
101
// The loss is as in test #2 (large city) plus the building penetration loss
102
// which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
103
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 7,
UrbanEnvironment
,
LargeCity
, 155.55,
"Okumura Hata Outdoor -> Indoor"
),
TestCase::QUICK
);
104
105
// Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
106
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
107
// The loss is as in test #4 plus the building penetration loss
108
// which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
109
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 1, 8,
UrbanEnvironment
,
LargeCity
, 88.000,
"ITU1411 LOS Outdoor -> Indoor"
),
TestCase::QUICK
);
110
111
// Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
112
113
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
114
// The loss is similar of test #4 plus the building penetration loss
115
// which for ConcreteWithWindows is equal to 7 dB and the height gain
116
// (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
117
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 9, 10,
UrbanEnvironment
,
LargeCity
, 84.838,
"ITU1411 LOS Indoor -> Outdoor"
),
TestCase::QUICK
);
118
119
// Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
120
121
freq = 2.1140e9;
// E_UTRA BAND #1 see table 5.5-1 of 36.101
122
// The loss is similar as in test #4 plus the building penetration loss
123
// which for ConcreteWithWindows is equal to 7 dB and the height gain
124
// (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
125
AddTestCase
(
new
BuildingsPathlossTestCase
(freq, 9, 11,
UrbanEnvironment
,
LargeCity
, 183.90,
"ITU1411 NLOS Indoor -> Outdoor"
),
TestCase::QUICK
);
126
127
128
}
129
130
131
132
static
BuildingsPathlossTestSuite
buildingsPathlossTestSuite
;
133
134
139
BuildingsPathlossTestCase::BuildingsPathlossTestCase
(
double
freq, uint16_t
m1
, uint16_t
m2
,
EnvironmentType
env,
CitySize
city,
double
refValue, std::string name)
140
:
TestCase
(
"LOSS calculation: "
+ name),
141
m_freq (freq),
142
m_mobilityModelIndex1 (m1),
143
m_mobilityModelIndex2 (m2),
144
m_env (env),
145
m_city (city),
146
m_lossRef (refValue)
147
{
148
}
149
150
BuildingsPathlossTestCase::~BuildingsPathlossTestCase
()
151
{
152
}
153
154
void
155
BuildingsPathlossTestCase::DoRun
(
void
)
156
{
157
NS_LOG_FUNCTION
(
this
);
158
159
// the building basically occupies the negative x plane, so any node
160
// in this area will fall in the building
161
Ptr<Building>
building1 = CreateObject<Building> ();
162
building1->
SetBoundaries
(
Box
(-3000, -1, -4000, 4000.0, 0.0, 12));
163
building1->
SetBuildingType
(
Building::Residential
);
164
building1->
SetExtWallsType
(
Building::ConcreteWithWindows
);
165
building1->
SetNFloors
(3);
166
167
Ptr<MobilityModel>
mma =
CreateMobilityModel
(
m_mobilityModelIndex1
);
168
Ptr<MobilityModel>
mmb =
CreateMobilityModel
(
m_mobilityModelIndex2
);
169
170
Ptr<HybridBuildingsPropagationLossModel>
propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
171
propagationLossModel->SetAttribute (
"Frequency"
,
DoubleValue
(
m_freq
));
172
propagationLossModel->SetAttribute (
"Environment"
,
EnumValue
(
m_env
));
173
propagationLossModel->SetAttribute (
"CitySize"
,
EnumValue
(
m_city
));
174
// cancel shadowing effect
175
propagationLossModel->SetAttribute (
"ShadowSigmaOutdoor"
,
DoubleValue
(0.0));
176
propagationLossModel->SetAttribute (
"ShadowSigmaIndoor"
,
DoubleValue
(0.0));
177
propagationLossModel->SetAttribute (
"ShadowSigmaExtWalls"
,
DoubleValue
(0.0));
178
179
double
loss = propagationLossModel->GetLoss (mma, mmb);
180
181
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
182
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
183
184
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss !"
);
185
Simulator::Destroy
();
186
}
187
188
Ptr<MobilityModel>
189
BuildingsPathlossTestCase::CreateMobilityModel
(uint16_t index)
190
{
191
192
/*
193
* The purpose of this method is to defer the creation of the
194
* MobilityModel instances to when DoRun() is called. In a previous
195
* version, MobilityModel instances where created directly in the
196
* constructor of the test suite, which caused subtle bugs due to
197
* "static initialization order fiasco". An example of such a subtle
198
* bug is that logging via NS_LOG failed for some modules.
199
*
200
*/
201
202
double
hm = 1;
203
double
hb = 30;
204
double
henbHeight = 10.0;
205
206
Ptr<MobilityModel>
mm;
207
208
switch
(index)
209
{
210
case
1:
211
mm = CreateObject<ConstantPositionMobilityModel> ();
212
mm->
SetPosition
(
Vector
(0.0, 0.0, hb));
213
break
;
214
215
case
2:
216
mm = CreateObject<ConstantPositionMobilityModel> ();
217
mm->
SetPosition
(
Vector
(2000, 0.0, hm));
218
break
;
219
220
case
3:
221
mm = CreateObject<ConstantPositionMobilityModel> ();
222
mm->
SetPosition
(
Vector
(100, 0.0, hm));
223
break
;
224
225
case
4:
226
mm = CreateObject<ConstantPositionMobilityModel> ();
227
mm->
SetPosition
(
Vector
(900, 0.0, hm));
228
break
;
229
230
case
5:
231
mm = CreateObject<ConstantPositionMobilityModel> ();
232
mm->
SetPosition
(
Vector
(-5, 0.0, hm));
233
break
;
234
235
case
6:
236
mm = CreateObject<ConstantPositionMobilityModel> ();
237
mm->
SetPosition
(
Vector
(-5, 30, henbHeight));
238
break
;
239
240
case
7:
241
mm = CreateObject<ConstantPositionMobilityModel> ();
242
mm->
SetPosition
(
Vector
(-2000, 0.0, hm));
243
break
;
244
245
case
8:
246
mm = CreateObject<ConstantPositionMobilityModel> ();
247
mm->
SetPosition
(
Vector
(-100, 0.0, hm));
248
break
;
249
250
case
9:
251
mm = CreateObject<ConstantPositionMobilityModel> ();
252
mm->
SetPosition
(
Vector
(0, 0.0, hm));
253
break
;
254
255
case
10:
256
mm = CreateObject<ConstantPositionMobilityModel> ();
257
mm->
SetPosition
(
Vector
(-100, 0.0, henbHeight));
258
break
;
259
260
case
11:
261
mm = CreateObject<ConstantPositionMobilityModel> ();
262
mm->
SetPosition
(
Vector
(-500, 0.0, henbHeight));
263
break
;
264
265
default
:
266
mm = 0;
267
break
;
268
}
269
Ptr<MobilityBuildingInfo>
buildingInfo = CreateObject<MobilityBuildingInfo> ();
270
mm->
AggregateObject
(buildingInfo);
// operation usually done by BuildingsHelper::Install
271
BuildingsHelper::MakeConsistent
(mm);
272
return
mm;
273
}
274
275
276
277
}
// namespace ns3
src
buildings
test
buildings-pathloss-test.cc
Generated on Fri Aug 30 2013 01:42:45 for ns-3 by
1.8.1.2