A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
hybrid-buildings-propagation-loss-model.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 */
21
23
26
27#include "ns3/double.h"
28#include "ns3/enum.h"
29#include "ns3/itu-r-1411-los-propagation-loss-model.h"
30#include "ns3/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h"
31#include "ns3/kun-2600-mhz-propagation-loss-model.h"
32#include "ns3/log.h"
33#include "ns3/mobility-model.h"
34#include "ns3/okumura-hata-propagation-loss-model.h"
35#include "ns3/pointer.h"
36
37#include <cmath>
38
39namespace ns3
40{
41
42NS_LOG_COMPONENT_DEFINE("HybridBuildingsPropagationLossModel");
43
44NS_OBJECT_ENSURE_REGISTERED(HybridBuildingsPropagationLossModel);
45
47{
48 m_okumuraHata = CreateObject<OkumuraHataPropagationLossModel>();
49 m_ituR1411Los = CreateObject<ItuR1411LosPropagationLossModel>();
50 m_ituR1411NlosOverRooftop = CreateObject<ItuR1411NlosOverRooftopPropagationLossModel>();
51 m_ituR1238 = CreateObject<ItuR1238PropagationLossModel>();
52 m_kun2600Mhz = CreateObject<Kun2600MhzPropagationLossModel>();
53}
54
56{
57}
58
61{
62 static TypeId tid =
63 TypeId("ns3::HybridBuildingsPropagationLossModel")
64
66
67 .AddConstructor<HybridBuildingsPropagationLossModel>()
68 .SetGroupName("Buildings")
69
70 .AddAttribute("Frequency",
71 "The Frequency (default is 2.106 GHz).",
72 DoubleValue(2160e6),
74 MakeDoubleChecker<double>())
75
76 .AddAttribute(
77 "Los2NlosThr",
78 " Threshold from LoS to NLoS in ITU 1411 [m].",
79 DoubleValue(200.0),
81 MakeDoubleChecker<double>())
82
83 .AddAttribute("Environment",
84 "Environment Scenario",
88 "Urban",
90 "SubUrban",
92 "OpenAreas"))
93
94 .AddAttribute(
95 "CitySize",
96 "Dimension of the city",
99 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"))
100
101 .AddAttribute(
102 "RooftopLevel",
103 "The height of the rooftop level in meters",
104 DoubleValue(20.0),
106 MakeDoubleChecker<double>(0.0, 90.0))
107
108 ;
109
110 return tid;
111}
112
113void
115{
116 m_okumuraHata->SetAttribute("Environment", EnumValue(env));
117 m_ituR1411NlosOverRooftop->SetAttribute("Environment", EnumValue(env));
118}
119
120void
122{
123 m_okumuraHata->SetAttribute("CitySize", EnumValue(size));
124 m_ituR1411NlosOverRooftop->SetAttribute("CitySize", EnumValue(size));
125}
126
127void
129{
130 m_okumuraHata->SetAttribute("Frequency", DoubleValue(freq));
131 m_ituR1411Los->SetAttribute("Frequency", DoubleValue(freq));
132 m_ituR1411NlosOverRooftop->SetAttribute("Frequency", DoubleValue(freq));
133 m_ituR1238->SetAttribute("Frequency", DoubleValue(freq));
134 m_frequency = freq;
135}
136
137void
139{
140 m_rooftopHeight = rooftopHeight;
141 m_ituR1411NlosOverRooftop->SetAttribute("RooftopLevel", DoubleValue(rooftopHeight));
142}
143
144double
146{
148 (a->GetPosition().z >= 0) && (b->GetPosition().z >= 0),
149 "HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)");
150
151 double distance = a->GetDistanceFrom(b);
152
153 // get the MobilityBuildingInfo pointers
156 NS_ASSERT_MSG(a1 && b1,
157 "HybridBuildingsPropagationLossModel only works with MobilityBuildingInfo");
158
159 double loss = 0.0;
160 bool isAIndoor = a1->IsIndoor();
161 bool isBIndoor = b1->IsIndoor();
162
163 if (!isAIndoor) // a is outdoor
164 {
165 if (!isBIndoor) // b is outdoor
166 {
167 if (distance > 1000)
168 {
169 NS_LOG_INFO(this << a->GetPosition().z << b->GetPosition().z << m_rooftopHeight);
170 if ((a->GetPosition().z < m_rooftopHeight) &&
171 (b->GetPosition().z < m_rooftopHeight))
172 {
173 loss = ItuR1411(a, b);
174 NS_LOG_INFO(this << " 0-0 (>1000): below rooftop -> ITUR1411 : " << loss);
175 }
176 else
177 {
178 // Over the rooftop transmission -> Okumura Hata
179 loss = OkumuraHata(a, b);
180 NS_LOG_INFO(this << " O-O (>1000): above rooftop -> OH : " << loss);
181 }
182 }
183 else
184 {
185 // short range outdoor communication
186 loss = ItuR1411(a, b);
187 NS_LOG_INFO(this << " 0-0 (<1000) Street canyon -> ITUR1411 : " << loss);
188 }
189 }
190 else
191 {
192 // b indoor
193 if (distance > 1000)
194 {
195 if ((a->GetPosition().z < m_rooftopHeight) &&
196 (b->GetPosition().z < m_rooftopHeight))
197 {
198 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
199 NS_LOG_INFO(this << " 0-I (>1000): below rooftop -> ITUR1411 : " << loss);
200 }
201 else
202 {
203 loss = OkumuraHata(a, b) + ExternalWallLoss(b1);
204 NS_LOG_INFO(this << " O-I (>1000): above the rooftop -> OH : " << loss);
205 }
206 }
207 else
208 {
209 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
210 NS_LOG_INFO(this << " 0-I (<1000) ITUR1411 + BEL : " << loss);
211 }
212 } // end b1->isIndoor ()
213 }
214 else
215 {
216 // a is indoor
217 if (isBIndoor) // b is indoor
218 {
219 if (a1->GetBuilding() == b1->GetBuilding())
220 {
221 // nodes are in same building -> indoor communication ITU-R P.1238
222 loss = ItuR1238(a, b) + InternalWallsLoss(a1, b1);
223 NS_LOG_INFO(this << " I-I (same building) ITUR1238 : " << loss);
224 }
225 else
226 {
227 // nodes are in different buildings
228 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + ExternalWallLoss(b1);
229 NS_LOG_INFO(this << " I-I (different) ITUR1238 + 2*BEL : " << loss);
230 }
231 }
232 else
233 {
234 // b is outdoor
235 if (distance > 1000)
236 {
237 if ((a->GetPosition().z < m_rooftopHeight) &&
238 (b->GetPosition().z < m_rooftopHeight))
239 {
240 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
241 NS_LOG_INFO(this << " I-O (>1000): down rooftop -> ITUR1411 : " << loss);
242 }
243 else
244 {
245 // above rooftop -> OH
246 loss = OkumuraHata(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
247 NS_LOG_INFO(this << " =I-O (>1000) over rooftop OH + BEL + HG: " << loss);
248 }
249 }
250 else
251 {
252 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
253 NS_LOG_INFO(this << " I-O (<1000) ITUR1411 + BEL + HG: " << loss);
254 }
255 } // end if (isBIndoor)
256 } // end if (!isAIndoor)
257
258 loss = std::max(loss, 0.0);
259
260 return loss;
261}
262
263double
265{
266 if (m_frequency <= 2.3e9)
267 {
268 return m_okumuraHata->GetLoss(a, b);
269 }
270 else
271 {
272 return m_kun2600Mhz->GetLoss(a, b);
273 }
274}
275
276double
278{
279 if (a->GetDistanceFrom(b) < m_itu1411NlosThreshold)
280 {
281 return (m_ituR1411Los->GetLoss(a, b));
282 }
283 else
284 {
285 return (m_ituR1411NlosOverRooftop->GetLoss(a, b));
286 }
287}
288
289double
291{
292 return m_ituR1238->GetLoss(a, b);
293}
294
295} // namespace ns3
This model provides means for simulating the following propagation phenomena in the presence of build...
double HeightLoss(Ptr< MobilityBuildingInfo > n) const
Calculate the height loss.
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Calculate the external wall loss.
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Calculate the internal wall loss.
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:56
void SetCitySize(CitySize size)
set the size of the city
double OkumuraHata(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Compute the path loss using either OkumuraHataPropagationLossModel or Kun2600MhzPropagationLossModel.
Ptr< ItuR1411NlosOverRooftopPropagationLossModel > m_ituR1411NlosOverRooftop
ItuR1411NlosOverRooftopPropagationLossModel.
void SetFrequency(double freq)
set the propagation frequency
void SetRooftopHeight(double rooftopHeight)
set the rooftop height
Ptr< ItuR1411LosPropagationLossModel > m_ituR1411Los
ItuR1411LosPropagationLossModel.
double ItuR1411(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Compute the path loss using either ItuR1411LosPropagationLossModel or ItuR1411NlosOverRooftopPropagat...
Ptr< Kun2600MhzPropagationLossModel > m_kun2600Mhz
Kun2600MhzPropagationLossModel.
double ItuR1238(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Compute the path loss using ItuR1238PropagationLossModel.
Ptr< OkumuraHataPropagationLossModel > m_okumuraHata
OkumuraHataPropagationLossModel.
void SetEnvironment(EnvironmentType env)
set the environment type
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Compute the path loss according to the nodes position using the appropriate model.
Ptr< ItuR1238PropagationLossModel > m_ituR1238
ItuR1238PropagationLossModel.
mobility buildings information (to be used by mobility models)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
EnvironmentType
The type of propagation environment.
CitySize
The size of the city in which propagation takes place.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:163