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
hybrid-buildings-propagation-loss-model.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
23
#include <cmath>
24
25
#include "ns3/log.h"
26
#include "ns3/mobility-model.h"
27
#include "ns3/double.h"
28
#include "ns3/pointer.h"
29
#include "ns3/okumura-hata-propagation-loss-model.h"
30
#include "ns3/itu-r-1411-los-propagation-loss-model.h"
31
#include "ns3/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h"
32
#include "ns3/itu-r-1238-propagation-loss-model.h"
33
#include "ns3/kun-2600-mhz-propagation-loss-model.h"
34
#include "ns3/buildings-mobility-model.h"
35
#include "ns3/enum.h"
36
37
#include "
hybrid-buildings-propagation-loss-model.h
"
38
39
40
NS_LOG_COMPONENT_DEFINE
(
"HybridBuildingsPropagationLossModel"
);
41
42
namespace
ns3 {
43
44
NS_OBJECT_ENSURE_REGISTERED
(HybridBuildingsPropagationLossModel);
45
46
47
48
HybridBuildingsPropagationLossModel::HybridBuildingsPropagationLossModel
()
49
{
50
m_okumuraHata
= CreateObject<OkumuraHataPropagationLossModel> ();
51
m_ituR1411Los
= CreateObject<ItuR1411LosPropagationLossModel> ();
52
m_ituR1411NlosOverRooftop
= CreateObject<ItuR1411NlosOverRooftopPropagationLossModel> ();
53
m_ituR1238
= CreateObject<ItuR1238PropagationLossModel> ();
54
m_kun2600Mhz
= CreateObject<Kun2600MhzPropagationLossModel> ();
55
}
56
57
HybridBuildingsPropagationLossModel::~HybridBuildingsPropagationLossModel
()
58
{
59
}
60
61
TypeId
62
HybridBuildingsPropagationLossModel::GetTypeId
(
void
)
63
{
64
static
TypeId
tid =
TypeId
(
"ns3::HybridBuildingsPropagationLossModel"
)
65
66
.
SetParent
<
BuildingsPropagationLossModel
> ()
67
68
.AddConstructor<HybridBuildingsPropagationLossModel> ()
69
70
.AddAttribute (
"Frequency"
,
71
"The Frequency (default is 2.106 GHz)."
,
72
DoubleValue
(2160e6),
73
MakeDoubleAccessor (&
HybridBuildingsPropagationLossModel::SetFrequency
),
74
MakeDoubleChecker<double> ())
75
76
.AddAttribute (
"Los2NlosThr"
,
77
" Threshold from LoS to NLoS in ITU 1411 [m]."
,
78
DoubleValue
(200.0),
79
MakeDoubleAccessor (&
HybridBuildingsPropagationLossModel::m_itu1411NlosThreshold
),
80
MakeDoubleChecker<double> ())
81
82
.AddAttribute (
"Environment"
,
83
"Environment Scenario"
,
84
EnumValue
(
UrbanEnvironment
),
85
MakeEnumAccessor
(&
HybridBuildingsPropagationLossModel::SetEnvironment
),
86
MakeEnumChecker
(
UrbanEnvironment
,
"Urban"
,
87
SubUrbanEnvironment
,
"SubUrban"
,
88
OpenAreasEnvironment
,
"OpenAreas"
))
89
90
.AddAttribute (
"CitySize"
,
91
"Dimension of the city"
,
92
EnumValue
(
LargeCity
),
93
MakeEnumAccessor
(&
HybridBuildingsPropagationLossModel::SetCitySize
),
94
MakeEnumChecker
(
SmallCity
,
"Small"
,
95
MediumCity
,
"Medium"
,
96
LargeCity
,
"Large"
))
97
98
.AddAttribute (
"RooftopLevel"
,
99
"The height of the rooftop level in meters"
,
100
DoubleValue
(20.0),
101
MakeDoubleAccessor (&
HybridBuildingsPropagationLossModel::SetRooftopHeight
),
102
MakeDoubleChecker<double> (0.0, 90.0))
103
104
;
105
106
return
tid;
107
}
108
109
void
110
HybridBuildingsPropagationLossModel::SetEnvironment
(
EnvironmentType
env)
111
{
112
m_okumuraHata
->
SetAttribute
(
"Environment"
,
EnumValue
(env));
113
m_ituR1411NlosOverRooftop
->
SetAttribute
(
"Environment"
,
EnumValue
(env));
114
}
115
116
void
117
HybridBuildingsPropagationLossModel::SetCitySize
(
CitySize
size)
118
{
119
m_okumuraHata
->
SetAttribute
(
"CitySize"
,
EnumValue
(size));
120
m_ituR1411NlosOverRooftop
->
SetAttribute
(
"CitySize"
,
EnumValue
(size));
121
}
122
123
void
124
HybridBuildingsPropagationLossModel::SetFrequency
(
double
freq)
125
{
126
m_okumuraHata
->
SetAttribute
(
"Frequency"
,
DoubleValue
(freq));
127
m_ituR1411Los
->
SetAttribute
(
"Frequency"
,
DoubleValue
(freq));
128
m_ituR1411NlosOverRooftop
->
SetAttribute
(
"Frequency"
,
DoubleValue
(freq));
129
m_ituR1238
->
SetAttribute
(
"Frequency"
,
DoubleValue
(freq));
130
m_frequency
= freq;
131
}
132
133
void
134
HybridBuildingsPropagationLossModel::SetRooftopHeight
(
double
rooftopHeight)
135
{
136
m_rooftopHeight
= rooftopHeight;
137
m_ituR1411NlosOverRooftop
->
SetAttribute
(
"RooftopLevel"
,
DoubleValue
(rooftopHeight));
138
}
139
140
141
double
142
HybridBuildingsPropagationLossModel::GetLoss
(
Ptr<MobilityModel>
a,
Ptr<MobilityModel>
b)
const
143
{
144
NS_ASSERT_MSG
((a->
GetPosition
().
z
>= 0) && (b->
GetPosition
().
z
>= 0),
"HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)"
);
145
146
147
double
distance = a->
GetDistanceFrom
(b);
148
149
// get the BuildingsMobilityModel pointers
150
Ptr<BuildingsMobilityModel>
a1 = DynamicCast<BuildingsMobilityModel> (a);
151
Ptr<BuildingsMobilityModel>
b1 = DynamicCast<BuildingsMobilityModel> (b);
152
NS_ASSERT_MSG
((a1 != 0) && (b1 != 0),
"HybridBuildingsPropagationLossModel only works with BuildingsMobilityModel"
);
153
154
double
loss = 0.0;
155
156
if
(a1->
IsOutdoor
())
157
{
158
if
(b1->IsOutdoor ())
159
{
160
if
(distance > 1000)
161
{
162
NS_LOG_INFO
(
this
<< a1->
GetPosition
().
z
<< b1->GetPosition ().z <<
m_rooftopHeight
);
163
if
((a1->
GetPosition
().
z
<
m_rooftopHeight
)
164
&& (b1->GetPosition ().z <
m_rooftopHeight
))
165
{
166
loss =
ItuR1411
(a1, b1);
167
NS_LOG_INFO
(
this
<<
" 0-0 (>1000): below rooftop -> ITUR1411 : "
<< loss);
168
}
169
else
170
{
171
// Over the rooftop tranmission -> Okumura Hata
172
loss =
OkumuraHata
(a1, b1);
173
NS_LOG_INFO
(
this
<<
" O-O (>1000): above rooftop -> OH : "
<< loss);
174
}
175
}
176
else
177
{
178
// short range outdoor communication
179
loss =
ItuR1411
(a1, b1);
180
NS_LOG_INFO
(
this
<<
" 0-0 (<1000) Street canyon -> ITUR1411 : "
<< loss);
181
}
182
}
183
else
184
{
185
// b indoor
186
if
(distance > 1000)
187
{
188
if
((a1->
GetPosition
().
z
<
m_rooftopHeight
)
189
&& (b1->GetPosition ().z <
m_rooftopHeight
))
190
{
191
loss =
ItuR1411
(a1, b1) +
ExternalWallLoss
(b1) +
HeightLoss
(a1);
192
NS_LOG_INFO
(
this
<<
" 0-I (>1000): below rooftop -> ITUR1411 : "
<< loss);
193
}
194
else
195
{
196
loss =
OkumuraHata
(a1, b1) +
ExternalWallLoss
(b1);
197
NS_LOG_INFO
(
this
<<
" O-I (>1000): above the rooftop -> OH : "
<< loss);
198
}
199
}
200
else
201
{
202
loss =
ItuR1411
(a1, b1) +
ExternalWallLoss
(b1) +
HeightLoss
(b1);
203
NS_LOG_INFO
(
this
<<
" 0-I (<1000) ITUR1411 + BEL : "
<< loss);
204
}
205
}
// end b1->isIndoor ()
206
}
207
else
208
{
209
// a is indoor
210
if
(b1->IsIndoor ())
211
{
212
if
(a1->
GetBuilding
() == b1->GetBuilding ())
213
{
214
// nodes are in same building -> indoor communication ITU-R P.1238
215
loss =
ItuR1238
(a1, b1) +
InternalWallsLoss
(a1, b1);;
216
NS_LOG_INFO
(
this
<<
" I-I (same building) ITUR1238 : "
<< loss);
217
218
}
219
else
220
{
221
// nodes are in different buildings
222
loss =
ItuR1411
(a1, b1) +
ExternalWallLoss
(a1) +
ExternalWallLoss
(b1);
223
NS_LOG_INFO
(
this
<<
" I-I (different) ITUR1238 + 2*BEL : "
<< loss);
224
}
225
}
226
else
227
{
228
// b is outdoor
229
if
(distance > 1000)
230
{
231
if
((a1->
GetPosition
().
z
<
m_rooftopHeight
)
232
&& (b1->GetPosition ().z <
m_rooftopHeight
))
233
{
234
loss =
ItuR1411
(a1, b1) +
ExternalWallLoss
(a1) +
HeightLoss
(a1);
235
NS_LOG_INFO
(
this
<<
" I-O (>1000): down rooftop -> ITUR1411 : "
<< loss);
236
}
237
else
238
{
239
// above rooftop -> OH
240
loss =
OkumuraHata
(a1, b1) +
ExternalWallLoss
(a1) +
HeightLoss
(a1);
241
NS_LOG_INFO
(
this
<<
" =I-O (>1000) over rooftop OH + BEL + HG: "
<< loss);
242
}
243
}
244
else
245
{
246
loss =
ItuR1411
(a1, b1) +
ExternalWallLoss
(a1) +
HeightLoss
(a1);
247
NS_LOG_INFO
(
this
<<
" I-O (<1000) ITUR1411 + BEL + HG: "
<< loss);
248
}
249
}
// end b1->IsIndoor ()
250
}
// end a1->IsOutdoor ()
251
252
loss = std::max (loss, 0.0);
253
254
return
loss;
255
}
256
257
258
double
259
HybridBuildingsPropagationLossModel::OkumuraHata
(
Ptr<BuildingsMobilityModel>
a,
Ptr<BuildingsMobilityModel>
b)
const
260
{
261
if
(
m_frequency
<= 2.3e9)
262
{
263
return
m_okumuraHata
->
GetLoss
(a, b);
264
}
265
else
266
{
267
return
m_kun2600Mhz
->
GetLoss
(a, b);
268
}
269
}
270
271
double
272
HybridBuildingsPropagationLossModel::ItuR1411
(
Ptr<BuildingsMobilityModel>
a,
Ptr<BuildingsMobilityModel>
b)
const
273
{
274
if
(a->
GetDistanceFrom
(b) <
m_itu1411NlosThreshold
)
275
{
276
return
(
m_ituR1411Los
->
GetLoss
(a, b));
277
}
278
else
279
{
280
return
(
m_ituR1411NlosOverRooftop
->
GetLoss
(a, b));
281
}
282
}
283
284
double
285
HybridBuildingsPropagationLossModel::ItuR1238
(
Ptr<BuildingsMobilityModel>
a,
Ptr<BuildingsMobilityModel>
b)
const
286
{
287
return
m_ituR1238
->
GetLoss
(a,b);
288
}
289
290
291
}
// namespace ns3
src
buildings
model
hybrid-buildings-propagation-loss-model.cc
Generated on Tue May 14 2013 11:08:16 for ns-3 by
1.8.1.2