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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 *
9 */
10
12
15
16#include "ns3/double.h"
17#include "ns3/enum.h"
18#include "ns3/itu-r-1411-los-propagation-loss-model.h"
19#include "ns3/itu-r-1411-nlos-over-rooftop-propagation-loss-model.h"
20#include "ns3/kun-2600-mhz-propagation-loss-model.h"
21#include "ns3/log.h"
22#include "ns3/mobility-model.h"
23#include "ns3/okumura-hata-propagation-loss-model.h"
24#include "ns3/pointer.h"
25
26#include <cmath>
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("HybridBuildingsPropagationLossModel");
32
33NS_OBJECT_ENSURE_REGISTERED(HybridBuildingsPropagationLossModel);
34
43
47
50{
51 static TypeId tid =
52 TypeId("ns3::HybridBuildingsPropagationLossModel")
53
55
56 .AddConstructor<HybridBuildingsPropagationLossModel>()
57 .SetGroupName("Buildings")
58
59 .AddAttribute("Frequency",
60 "The Frequency (default is 2.106 GHz).",
61 DoubleValue(2160e6),
64
65 .AddAttribute(
66 "Los2NlosThr",
67 " Threshold from LoS to NLoS in ITU 1411 [m].",
68 DoubleValue(200.0),
71
72 .AddAttribute("Environment",
73 "Environment Scenario",
78 "Urban",
80 "SubUrban",
82 "OpenAreas"))
83
84 .AddAttribute(
85 "CitySize",
86 "Dimension of the city",
89 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"))
90
91 .AddAttribute(
92 "RooftopLevel",
93 "The height of the rooftop level in meters",
94 DoubleValue(20.0),
97
98 ;
99
100 return tid;
101}
102
103void
105{
106 m_okumuraHata->SetAttribute("Environment", EnumValue(env));
107 m_ituR1411NlosOverRooftop->SetAttribute("Environment", EnumValue(env));
108}
109
110void
112{
113 m_okumuraHata->SetAttribute("CitySize", EnumValue(size));
114 m_ituR1411NlosOverRooftop->SetAttribute("CitySize", EnumValue(size));
115}
116
117void
119{
120 m_okumuraHata->SetAttribute("Frequency", DoubleValue(freq));
121 m_ituR1411Los->SetAttribute("Frequency", DoubleValue(freq));
122 m_ituR1411NlosOverRooftop->SetAttribute("Frequency", DoubleValue(freq));
123 m_ituR1238->SetAttribute("Frequency", DoubleValue(freq));
124 m_frequency = freq;
125}
126
127void
129{
130 m_rooftopHeight = rooftopHeight;
131 m_ituR1411NlosOverRooftop->SetAttribute("RooftopLevel", DoubleValue(rooftopHeight));
132}
133
134double
136{
138 (a->GetPosition().z >= 0) && (b->GetPosition().z >= 0),
139 "HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)");
140
141 double distance = a->GetDistanceFrom(b);
142
143 // get the MobilityBuildingInfo pointers
146 NS_ASSERT_MSG(a1 && b1,
147 "HybridBuildingsPropagationLossModel only works with MobilityBuildingInfo");
148
149 double loss = 0.0;
150 bool isAIndoor = a1->IsIndoor();
151 bool isBIndoor = b1->IsIndoor();
152
153 if (!isAIndoor) // a is outdoor
154 {
155 if (!isBIndoor) // b is outdoor
156 {
157 if (distance > 1000)
158 {
159 NS_LOG_INFO(this << a->GetPosition().z << b->GetPosition().z << m_rooftopHeight);
160 if ((a->GetPosition().z < m_rooftopHeight) &&
161 (b->GetPosition().z < m_rooftopHeight))
162 {
163 loss = ItuR1411(a, b);
164 NS_LOG_INFO(this << " 0-0 (>1000): below rooftop -> ITUR1411 : " << loss);
165 }
166 else
167 {
168 // Over the rooftop transmission -> Okumura Hata
169 loss = OkumuraHata(a, b);
170 NS_LOG_INFO(this << " O-O (>1000): above rooftop -> OH : " << loss);
171 }
172 }
173 else
174 {
175 // short range outdoor communication
176 loss = ItuR1411(a, b);
177 NS_LOG_INFO(this << " 0-0 (<1000) Street canyon -> ITUR1411 : " << loss);
178 }
179 }
180 else
181 {
182 // b indoor
183 if (distance > 1000)
184 {
185 if ((a->GetPosition().z < m_rooftopHeight) &&
186 (b->GetPosition().z < m_rooftopHeight))
187 {
188 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
189 NS_LOG_INFO(this << " 0-I (>1000): below rooftop -> ITUR1411 : " << loss);
190 }
191 else
192 {
193 loss = OkumuraHata(a, b) + ExternalWallLoss(b1);
194 NS_LOG_INFO(this << " O-I (>1000): above the rooftop -> OH : " << loss);
195 }
196 }
197 else
198 {
199 loss = ItuR1411(a, b) + ExternalWallLoss(b1) + HeightLoss(b1);
200 NS_LOG_INFO(this << " 0-I (<1000) ITUR1411 + BEL : " << loss);
201 }
202 } // end b1->isIndoor ()
203 }
204 else
205 {
206 // a is indoor
207 if (isBIndoor) // b is indoor
208 {
209 if (a1->GetBuilding() == b1->GetBuilding())
210 {
211 // nodes are in same building -> indoor communication ITU-R P.1238
212 loss = ItuR1238(a, b) + InternalWallsLoss(a1, b1);
213 NS_LOG_INFO(this << " I-I (same building) ITUR1238 : " << loss);
214 }
215 else
216 {
217 // nodes are in different buildings
218 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + ExternalWallLoss(b1);
219 NS_LOG_INFO(this << " I-I (different) ITUR1238 + 2*BEL : " << loss);
220 }
221 }
222 else
223 {
224 // b is outdoor
225 if (distance > 1000)
226 {
227 if ((a->GetPosition().z < m_rooftopHeight) &&
228 (b->GetPosition().z < m_rooftopHeight))
229 {
230 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
231 NS_LOG_INFO(this << " I-O (>1000): down rooftop -> ITUR1411 : " << loss);
232 }
233 else
234 {
235 // above rooftop -> OH
236 loss = OkumuraHata(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
237 NS_LOG_INFO(this << " =I-O (>1000) over rooftop OH + BEL + HG: " << loss);
238 }
239 }
240 else
241 {
242 loss = ItuR1411(a, b) + ExternalWallLoss(a1) + HeightLoss(a1);
243 NS_LOG_INFO(this << " I-O (<1000) ITUR1411 + BEL + HG: " << loss);
244 }
245 } // end if (isBIndoor)
246 } // end if (!isAIndoor)
247
248 loss = std::max(loss, 0.0);
249
250 return loss;
251}
252
253double
255{
256 if (m_frequency <= 2.3e9)
257 {
258 return m_okumuraHata->GetLoss(a, b);
259 }
260 else
261 {
262 return m_kun2600Mhz->GetLoss(a, b);
263 }
264}
265
266double
268{
269 if (a->GetDistanceFrom(b) < m_itu1411NlosThreshold)
270 {
271 return m_ituR1411Los->GetLoss(a, b);
272 }
273 else
274 {
275 return m_ituR1411NlosOverRooftop->GetLoss(a, b);
276 }
277}
278
279double
284
285} // 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:31
Hold variables of type enum.
Definition enum.h:52
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.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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 > MakeDoubleChecker()
Definition double.h:82
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:179
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221