A Discrete-Event Network Simulator
API
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/mobility-building-info.h>
35#include "ns3/enum.h"
36
38
39
40namespace ns3 {
41
42NS_LOG_COMPONENT_DEFINE ("HybridBuildingsPropagationLossModel");
43
44NS_OBJECT_ENSURE_REGISTERED (HybridBuildingsPropagationLossModel);
45
46
47
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
58{
59}
60
63{
64 static TypeId tid = TypeId ("ns3::HybridBuildingsPropagationLossModel")
65
67
68 .AddConstructor<HybridBuildingsPropagationLossModel> ()
69 .SetGroupName ("Buildings")
70
71 .AddAttribute ("Frequency",
72 "The Frequency (default is 2.106 GHz).",
73 DoubleValue (2160e6),
75 MakeDoubleChecker<double> ())
76
77 .AddAttribute ("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 SubUrbanEnvironment, "SubUrban",
89 OpenAreasEnvironment, "OpenAreas"))
90
91 .AddAttribute ("CitySize",
92 "Dimension of the city",
95 MakeEnumChecker (SmallCity, "Small",
96 MediumCity, "Medium",
97 LargeCity, "Large"))
98
99 .AddAttribute ("RooftopLevel",
100 "The height of the rooftop level in meters",
101 DoubleValue (20.0),
103 MakeDoubleChecker<double> (0.0, 90.0))
104
105 ;
106
107 return tid;
108}
109
110void
112{
113 m_okumuraHata->SetAttribute ("Environment", EnumValue (env));
114 m_ituR1411NlosOverRooftop->SetAttribute ("Environment", EnumValue (env));
115}
116
117void
119{
120 m_okumuraHata->SetAttribute ("CitySize", EnumValue (size));
121 m_ituR1411NlosOverRooftop->SetAttribute ("CitySize", EnumValue (size));
122}
123
124void
126{
127 m_okumuraHata->SetAttribute ("Frequency", DoubleValue (freq));
128 m_ituR1411Los->SetAttribute ("Frequency", DoubleValue (freq));
129 m_ituR1411NlosOverRooftop->SetAttribute ("Frequency", DoubleValue (freq));
130 m_ituR1238->SetAttribute ("Frequency", DoubleValue (freq));
131 m_frequency = freq;
132}
133
134void
136{
137 m_rooftopHeight = rooftopHeight;
138 m_ituR1411NlosOverRooftop->SetAttribute ("RooftopLevel", DoubleValue (rooftopHeight));
139}
140
141
142double
144{
145 NS_ASSERT_MSG ((a->GetPosition ().z >= 0) && (b->GetPosition ().z >= 0), "HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)");
146
147
148 double distance = a->GetDistanceFrom (b);
149
150 // get the MobilityBuildingInfo pointers
153 NS_ASSERT_MSG (a1 && b1 , "HybridBuildingsPropagationLossModel only works with MobilityBuildingInfo");
154
155 double loss = 0.0;
156 bool isAIndoor = a1->IsIndoor ();
157 bool isBIndoor = b1->IsIndoor ();
158
159
160 if (!isAIndoor) // a is outdoor
161 {
162 if (!isBIndoor) // b is outdoor
163 {
164 if (distance > 1000)
165 {
166 NS_LOG_INFO (this << a->GetPosition ().z << b->GetPosition ().z << m_rooftopHeight);
167 if ((a->GetPosition ().z < m_rooftopHeight)
168 && (b->GetPosition ().z < m_rooftopHeight))
169 {
170 loss = ItuR1411 (a, b);
171 NS_LOG_INFO (this << " 0-0 (>1000): below rooftop -> ITUR1411 : " << loss);
172 }
173 else
174 {
175 // Over the rooftop tranmission -> Okumura Hata
176 loss = OkumuraHata (a, b);
177 NS_LOG_INFO (this << " O-O (>1000): above rooftop -> OH : " << loss);
178 }
179 }
180 else
181 {
182 // short range outdoor communication
183 loss = ItuR1411 (a, b);
184 NS_LOG_INFO (this << " 0-0 (<1000) Street canyon -> ITUR1411 : " << loss);
185 }
186 }
187 else
188 {
189 // b indoor
190 if (distance > 1000)
191 {
192 if ((a->GetPosition ().z < m_rooftopHeight)
193 && (b->GetPosition ().z < m_rooftopHeight))
194 {
195 loss = ItuR1411 (a, b) + ExternalWallLoss (b1) + HeightLoss (b1);
196 NS_LOG_INFO (this << " 0-I (>1000): below rooftop -> ITUR1411 : " << loss);
197 }
198 else
199 {
200 loss = OkumuraHata (a, b) + ExternalWallLoss (b1);
201 NS_LOG_INFO (this << " O-I (>1000): above the rooftop -> OH : " << loss);
202 }
203 }
204 else
205 {
206 loss = ItuR1411 (a, b) + ExternalWallLoss (b1) + HeightLoss (b1);
207 NS_LOG_INFO (this << " 0-I (<1000) ITUR1411 + BEL : " << loss);
208 }
209 } // end b1->isIndoor ()
210 }
211 else
212 {
213 // a is indoor
214 if (isBIndoor) // b is indoor
215 {
216 if (a1->GetBuilding () == b1->GetBuilding ())
217 {
218 // nodes are in same building -> indoor communication ITU-R P.1238
219 loss = ItuR1238 (a, b) + InternalWallsLoss (a1, b1);
220 NS_LOG_INFO (this << " I-I (same building) ITUR1238 : " << loss);
221
222 }
223 else
224 {
225 // nodes are in different buildings
226 loss = ItuR1411 (a, b) + ExternalWallLoss (a1) + ExternalWallLoss (b1);
227 NS_LOG_INFO (this << " I-I (different) ITUR1238 + 2*BEL : " << loss);
228 }
229 }
230 else
231 {
232 // b is outdoor
233 if (distance > 1000)
234 {
235 if ((a->GetPosition ().z < m_rooftopHeight)
236 && (b->GetPosition ().z < m_rooftopHeight))
237 {
238 loss = ItuR1411 (a, b) + ExternalWallLoss (a1) + HeightLoss (a1);
239 NS_LOG_INFO (this << " I-O (>1000): down rooftop -> ITUR1411 : " << loss);
240 }
241 else
242 {
243 // above rooftop -> OH
244 loss = OkumuraHata (a, b) + ExternalWallLoss (a1) + HeightLoss (a1);
245 NS_LOG_INFO (this << " =I-O (>1000) over rooftop OH + BEL + HG: " << loss);
246 }
247 }
248 else
249 {
250 loss = ItuR1411 (a, b) + ExternalWallLoss (a1) + HeightLoss (a1);
251 NS_LOG_INFO (this << " I-O (<1000) ITUR1411 + BEL + HG: " << loss);
252 }
253 } // end if (isBIndoor)
254 } // end if (!isAIndoor)
255
256 loss = std::max (loss, 0.0);
257
258 return loss;
259}
260
261
262double
264{
265 if (m_frequency <= 2.3e9)
266 {
267 return m_okumuraHata->GetLoss (a, b);
268 }
269 else
270 {
271 return m_kun2600Mhz->GetLoss (a, b);
272 }
273}
274
275double
277{
279 {
280 return (m_ituR1411Los->GetLoss (a, b));
281 }
282 else
283 {
284 return (m_ituR1411NlosOverRooftop->GetLoss (a, b));
285 }
286}
287
288double
290{
291 return m_ituR1238->GetLoss (a,b);
292}
293
294
295} // namespace ns3
#define max(a, b)
Definition: 80211b.c:43
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:41
Hold variables of type enum.
Definition: enum.h:55
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.
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Compute the path loss according to the nodes position using the appropriate model.
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
Ptr< ItuR1238PropagationLossModel > m_ituR1238
ItuR1238PropagationLossModel.
mobility buildings information (to be used by mobility models)
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Vector GetPosition(void) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#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:88
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
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:206
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:282
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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:162