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 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("HybridBuildingsPropagationLossModel");
43 
44 NS_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 
61 TypeId
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 
110 void
112 {
113  m_okumuraHata->SetAttribute ("Environment", EnumValue (env));
114  m_ituR1411NlosOverRooftop->SetAttribute ("Environment", EnumValue (env));
115 }
116 
117 void
119 {
120  m_okumuraHata->SetAttribute ("CitySize", EnumValue (size));
121  m_ituR1411NlosOverRooftop->SetAttribute ("CitySize", EnumValue (size));
122 }
123 
124 void
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 
134 void
136 {
137  m_rooftopHeight = rooftopHeight;
138  m_ituR1411NlosOverRooftop->SetAttribute ("RooftopLevel", DoubleValue (rooftopHeight));
139 }
140 
141 
142 double
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 != 0) && (b1 != 0), "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 
262 double
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 
275 double
277 {
279  {
280  return (m_ituR1411Los->GetLoss (a, b));
281  }
282  else
283  {
284  return (m_ituR1411NlosOverRooftop->GetLoss (a, b));
285  }
286 }
287 
288 double
290 {
291  return m_ituR1238->GetLoss (a,b);
292 }
293 
294 
295 } // namespace ns3
ns3::SubUrbanEnvironment
@ SubUrbanEnvironment
Definition: propagation-environment.h:38
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::HybridBuildingsPropagationLossModel::SetEnvironment
void SetEnvironment(EnvironmentType env)
set the environment type
Definition: hybrid-buildings-propagation-loss-model.cc:111
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeEnumChecker
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:161
ns3::SmallCity
@ SmallCity
Definition: propagation-environment.h:50
ns3::LargeCity
@ LargeCity
Definition: propagation-environment.h:50
ns3::UrbanEnvironment
@ UrbanEnvironment
Definition: propagation-environment.h:38
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
ns3::MobilityModel::GetDistanceFrom
double GetDistanceFrom(Ptr< const MobilityModel > position) const
Definition: mobility-model.cc:94
ns3::HybridBuildingsPropagationLossModel::SetRooftopHeight
void SetRooftopHeight(double rooftopHeight)
set the rooftop height
Definition: hybrid-buildings-propagation-loss-model.cc:135
ns3::HybridBuildingsPropagationLossModel::GetTypeId
static TypeId GetTypeId(void)
Definition: hybrid-buildings-propagation-loss-model.cc:62
ns3::HybridBuildingsPropagationLossModel::HybridBuildingsPropagationLossModel
HybridBuildingsPropagationLossModel()
Definition: hybrid-buildings-propagation-loss-model.cc:48
ns3::MediumCity
@ MediumCity
Definition: propagation-environment.h:50
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::EnumValue
Hold variables of type enum.
Definition: enum.h:55
ns3::HybridBuildingsPropagationLossModel::OkumuraHata
double OkumuraHata(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition: hybrid-buildings-propagation-loss-model.cc:263
ns3::BuildingsPropagationLossModel::ExternalWallLoss
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Definition: buildings-propagation-loss-model.cc:104
ns3::BuildingsPropagationLossModel::HeightLoss
double HeightLoss(Ptr< MobilityBuildingInfo > n) const
Definition: buildings-propagation-loss-model.cc:128
ns3::BuildingsPropagationLossModel
This model provides means for simulating the following propagation phenomena in the presence of build...
Definition: buildings-propagation-loss-model.h:58
ns3::Ptr< MobilityModel >
ns3::OpenAreasEnvironment
@ OpenAreasEnvironment
Definition: propagation-environment.h:38
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition: mobility-building-info.h:49
max
#define max(a, b)
Definition: 80211b.c:43
ns3::CitySize
CitySize
The size of the city in which propagation takes place.
Definition: propagation-environment.h:49
ns3::HybridBuildingsPropagationLossModel::m_ituR1411NlosOverRooftop
Ptr< ItuR1411NlosOverRooftopPropagationLossModel > m_ituR1411NlosOverRooftop
Definition: hybrid-buildings-propagation-loss-model.h:109
ns3::HybridBuildingsPropagationLossModel::m_ituR1238
Ptr< ItuR1238PropagationLossModel > m_ituR1238
Definition: hybrid-buildings-propagation-loss-model.h:110
ns3::HybridBuildingsPropagationLossModel::SetFrequency
void SetFrequency(double freq)
set the propagation frequency
Definition: hybrid-buildings-propagation-loss-model.cc:125
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::HybridBuildingsPropagationLossModel::m_kun2600Mhz
Ptr< Kun2600MhzPropagationLossModel > m_kun2600Mhz
Definition: hybrid-buildings-propagation-loss-model.h:111
ns3::HybridBuildingsPropagationLossModel::m_frequency
double m_frequency
Definition: hybrid-buildings-propagation-loss-model.h:115
NS_ASSERT_MSG
#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
ns3::EnvironmentType
EnvironmentType
The type of propagation environment.
Definition: propagation-environment.h:37
ns3::HybridBuildingsPropagationLossModel::SetCitySize
void SetCitySize(CitySize size)
set the size of the city
Definition: hybrid-buildings-propagation-loss-model.cc:118
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: double.h:42
ns3::HybridBuildingsPropagationLossModel::m_rooftopHeight
double m_rooftopHeight
Definition: hybrid-buildings-propagation-loss-model.h:114
ns3::MakeEnumAccessor
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: enum.h:203
ns3::HybridBuildingsPropagationLossModel::~HybridBuildingsPropagationLossModel
~HybridBuildingsPropagationLossModel()
Definition: hybrid-buildings-propagation-loss-model.cc:57
ns3::BuildingsPropagationLossModel::InternalWallsLoss
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Definition: buildings-propagation-loss-model.cc:138
ns3::HybridBuildingsPropagationLossModel::m_ituR1411Los
Ptr< ItuR1411LosPropagationLossModel > m_ituR1411Los
Definition: hybrid-buildings-propagation-loss-model.h:108
ns3::HybridBuildingsPropagationLossModel::ItuR1238
double ItuR1238(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition: hybrid-buildings-propagation-loss-model.cc:289
ns3::HybridBuildingsPropagationLossModel::ItuR1411
double ItuR1411(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition: hybrid-buildings-propagation-loss-model.cc:276
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition: mobility-model.cc:64
hybrid-buildings-propagation-loss-model.h
ns3::HybridBuildingsPropagationLossModel::GetLoss
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition: hybrid-buildings-propagation-loss-model.cc:143
ns3::HybridBuildingsPropagationLossModel::m_okumuraHata
Ptr< OkumuraHataPropagationLossModel > m_okumuraHata
Definition: hybrid-buildings-propagation-loss-model.h:107
ns3::HybridBuildingsPropagationLossModel::m_itu1411NlosThreshold
double m_itu1411NlosThreshold
in meters (switch Los -> NLoS)
Definition: hybrid-buildings-propagation-loss-model.h:113