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",
86 MakeEnumAccessor<EnvironmentType>(
89 "Urban",
91 "SubUrban",
93 "OpenAreas"))
94
95 .AddAttribute(
96 "CitySize",
97 "Dimension of the city",
99 MakeEnumAccessor<CitySize>(&HybridBuildingsPropagationLossModel::SetCitySize),
100 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"))
101
102 .AddAttribute(
103 "RooftopLevel",
104 "The height of the rooftop level in meters",
105 DoubleValue(20.0),
107 MakeDoubleChecker<double>(0.0, 90.0))
108
109 ;
110
111 return tid;
112}
113
114void
116{
117 m_okumuraHata->SetAttribute("Environment", EnumValue(env));
118 m_ituR1411NlosOverRooftop->SetAttribute("Environment", EnumValue(env));
119}
120
121void
123{
124 m_okumuraHata->SetAttribute("CitySize", EnumValue(size));
125 m_ituR1411NlosOverRooftop->SetAttribute("CitySize", EnumValue(size));
126}
127
128void
130{
131 m_okumuraHata->SetAttribute("Frequency", DoubleValue(freq));
132 m_ituR1411Los->SetAttribute("Frequency", DoubleValue(freq));
133 m_ituR1411NlosOverRooftop->SetAttribute("Frequency", DoubleValue(freq));
134 m_ituR1238->SetAttribute("Frequency", DoubleValue(freq));
135 m_frequency = freq;
136}
137
138void
140{
141 m_rooftopHeight = rooftopHeight;
142 m_ituR1411NlosOverRooftop->SetAttribute("RooftopLevel", DoubleValue(rooftopHeight));
143}
144
145double
147{
149 (a->GetPosition().z >= 0) && (b->GetPosition().z >= 0),
150 "HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)");
151
152 double distance = a->GetDistanceFrom(b);
153
154 // get the MobilityBuildingInfo pointers
157 NS_ASSERT_MSG(a1 && b1,
158 "HybridBuildingsPropagationLossModel only works with MobilityBuildingInfo");
159
160 double loss = 0.0;
161 bool isAIndoor = a1->IsIndoor();
162 bool isBIndoor = b1->IsIndoor();
163
164 if (!isAIndoor) // a is outdoor
165 {
166 if (!isBIndoor) // b is outdoor
167 {
168 if (distance > 1000)
169 {
170 NS_LOG_INFO(this << a->GetPosition().z << b->GetPosition().z << m_rooftopHeight);
171 if ((a->GetPosition().z < m_rooftopHeight) &&
172 (b->GetPosition().z < m_rooftopHeight))
173 {
174 loss = ItuR1411(a, b);
175 NS_LOG_INFO(this << " 0-0 (>1000): below rooftop -> ITUR1411 : " << loss);
176 }
177 else
178 {
179 // Over the rooftop transmission -> Okumura Hata
180 loss = OkumuraHata(a, b);
181 NS_LOG_INFO(this << " O-O (>1000): above rooftop -> OH : " << loss);
182 }
183 }
184 else
185 {
186 // short range outdoor communication
187 loss = ItuR1411(a, b);
188 NS_LOG_INFO(this << " 0-0 (<1000) Street canyon -> ITUR1411 : " << loss);
189 }
190 }
191 else
192 {
193 // b indoor
194 if (distance > 1000)
195 {
196 if ((a->GetPosition().z < m_rooftopHeight) &&
197 (b->GetPosition().z < m_rooftopHeight))
198 {
199 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
200 NS_LOG_INFO(this << " 0-I (>1000): below rooftop -> ITUR1411 : " << loss);
201 }
202 else
203 {
204 loss = OkumuraHata(a, b) + ExternalWallLoss(b1);
205 NS_LOG_INFO(this << " O-I (>1000): above the rooftop -> OH : " << loss);
206 }
207 }
208 else
209 {
210 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
211 NS_LOG_INFO(this << " 0-I (<1000) ITUR1411 + BEL : " << loss);
212 }
213 } // end b1->isIndoor ()
214 }
215 else
216 {
217 // a is indoor
218 if (isBIndoor) // b is indoor
219 {
220 if (a1->GetBuilding() == b1->GetBuilding())
221 {
222 // nodes are in same building -> indoor communication ITU-R P.1238
223 loss = ItuR1238(a, b) + InternalWallsLoss(a1, b1);
224 NS_LOG_INFO(this << " I-I (same building) ITUR1238 : " << loss);
225 }
226 else
227 {
228 // nodes are in different buildings
229 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + ExternalWallLoss(b1);
230 NS_LOG_INFO(this << " I-I (different) ITUR1238 + 2*BEL : " << loss);
231 }
232 }
233 else
234 {
235 // b is outdoor
236 if (distance > 1000)
237 {
238 if ((a->GetPosition().z < m_rooftopHeight) &&
239 (b->GetPosition().z < m_rooftopHeight))
240 {
241 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
242 NS_LOG_INFO(this << " I-O (>1000): down rooftop -> ITUR1411 : " << loss);
243 }
244 else
245 {
246 // above rooftop -> OH
247 loss = OkumuraHata(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
248 NS_LOG_INFO(this << " =I-O (>1000) over rooftop OH + BEL + HG: " << loss);
249 }
250 }
251 else
252 {
253 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
254 NS_LOG_INFO(this << " I-O (<1000) ITUR1411 + BEL + HG: " << loss);
255 }
256 } // end if (isBIndoor)
257 } // end if (!isAIndoor)
258
259 loss = std::max(loss, 0.0);
260
261 return loss;
262}
263
264double
266{
267 if (m_frequency <= 2.3e9)
268 {
269 return m_okumuraHata->GetLoss(a, b);
270 }
271 else
272 {
273 return m_kun2600Mhz->GetLoss(a, b);
274 }
275}
276
277double
279{
280 if (a->GetDistanceFrom(b) < m_itu1411NlosThreshold)
281 {
282 return m_ituR1411Los->GetLoss(a, b);
283 }
284 else
285 {
286 return m_ituR1411NlosOverRooftop->GetLoss(a, b);
287 }
288}
289
290double
292{
293 return m_ituR1238->GetLoss(a, b);
294}
295
296} // 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:62
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:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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
#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(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:189