A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
itu-r-1411-nlos-over-rooftop-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, 2012 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 #include "ns3/log.h"
23 #include "ns3/double.h"
24 #include "ns3/enum.h"
25 #include "ns3/mobility-model.h"
26 #include <cmath>
27 
29 
30 NS_LOG_COMPONENT_DEFINE ("ItuR1411NlosOverRooftopPropagationLossModel");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (ItuR1411NlosOverRooftopPropagationLossModel)
35  ;
36 
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::ItuR1411NlosOverRooftopPropagationLossModel")
42 
44 
45  .AddAttribute ("Frequency",
46  "The Frequency (default is 2.106 GHz).",
47  DoubleValue (2160e6),
49  MakeDoubleChecker<double> ())
50 
51 
52  .AddAttribute ("Environment",
53  "Environment Scenario",
57  SubUrbanEnvironment, "SubUrban",
58  OpenAreasEnvironment, "OpenAreas"))
59 
60  .AddAttribute ("CitySize",
61  "Dimension of the city",
64  MakeEnumChecker (SmallCity, "Small",
65  MediumCity, "Medium",
66  LargeCity, "Large"))
67 
68  .AddAttribute ("RooftopLevel",
69  "The height of the rooftop level in meters",
70  DoubleValue (20.0),
72  MakeDoubleChecker<double> (0.0, 90.0))
73 
74  .AddAttribute ("StreetsOrientation",
75  "The orientation of streets in degrees [0,90] with respect to the direction of propagation",
76  DoubleValue (45.0),
78  MakeDoubleChecker<double> (0.0, 90.0))
79 
80  .AddAttribute ("StreetsWidth",
81  "The width of streets",
82  DoubleValue (20.0),
84  MakeDoubleChecker<double> (0.0, 1000.0))
85 
86  .AddAttribute ("BuildingsExtend",
87  "The distance over which the buildings extend",
88  DoubleValue (80.0),
90  MakeDoubleChecker<double> ())
91 
92  .AddAttribute ("BuildingSeparation",
93  "The separation between buildings",
94  DoubleValue (50.0),
96  MakeDoubleChecker<double> ());
97 
98  return tid;
99 }
100 
101 
102 double
104 {
105  NS_LOG_FUNCTION (this << a << b);
106  double Lori = 0.0;
107  double fmhz = m_frequency / 1e6;
108 
110  " Street Orientation must be in [0,90]");
111  if (m_streetsOrientation < 35)
112  {
113  Lori = -10.0 + 0.354 * m_streetsOrientation;
114  }
115  else if ((m_streetsOrientation >= 35)&&(m_streetsOrientation < 55))
116  {
117  Lori = 2.5 + 0.075 * (m_streetsOrientation - 35);
118  }
119  else // m_streetsOrientation >= 55
120  {
121  Lori = 2.5 + 0.075 * (m_streetsOrientation - 55);
122  }
123 
124  double distance = a->GetDistanceFrom (b);
125  double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
126  double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
127  NS_ASSERT_MSG (hm > 0 && hb > 0, "nodes' height must be greater then 0");
128  double Dhb = hb - m_rooftopHeight;
129  double ds = (m_lambda * distance * distance) / (Dhb * Dhb);
130  double Lmsd = 0.0;
131  NS_LOG_LOGIC (this << " build " << m_buildingsExtend << " ds " << ds << " roof " << m_rooftopHeight << " hb " << hb << " lambda " << m_lambda);
132  if (ds < m_buildingsExtend)
133  {
134  double Lbsh = 0.0;
135  double ka = 0.0;
136  double kd = 0.0;
137  double kf = 0.0;
138  if (hb > m_rooftopHeight)
139  {
140  Lbsh = -18 * std::log10 (1 + Dhb);
141  ka = (fmhz > 2000 ? 71.4 : 54.0);
142  kd = 18.0;
143  }
144  else
145  {
146  Lbsh = 0;
147  kd = 18.0 - 15 * Dhb / a->GetPosition ().z;
148  if (distance < 500)
149  {
150  ka = 54.0 - 1.6 * Dhb * distance / 1000;
151  }
152  else
153  {
154  ka = 54.0 - 0.8 * Dhb;
155  }
156  }
157  if (fmhz > 2000)
158  {
159  kf = -8;
160  }
162  {
163  kf = -4 + 0.7 * (fmhz / 925.0 - 1);
164  }
165  else
166  {
167  kf = -4 + 1.5 * (fmhz / 925.0 - 1);
168  }
169 
170  Lmsd = Lbsh + ka + kd * std::log10 (distance / 1000.0) + kf * std::log10 (fmhz) - 9.0 * std::log10 (m_buildingSeparation);
171  }
172  else
173  {
174  double theta = std::atan (Dhb / m_buildingSeparation);
175  double rho = std::sqrt (Dhb * Dhb + m_buildingSeparation * m_buildingSeparation);
176  double Qm = 0.0;
177  if ((hb > m_rooftopHeight - 1.0) && (hb < m_rooftopHeight + 1.0))
178  {
179  Qm = m_buildingSeparation / distance;
180  }
181  else if (hb > m_rooftopHeight)
182  {
183  Qm = 2.35 * pow (Dhb / distance * std::sqrt (m_buildingSeparation / m_lambda), 0.9);
184  }
185  else
186  {
187  Qm = m_buildingSeparation / (2 * M_PI * distance) * std::sqrt (m_lambda / rho) * (1 / theta - (1 / (2 * M_PI + theta)));
188  }
189  Lmsd = -10 * std::log10 (Qm * Qm);
190  }
191  double Lbf = 32.4 + 20 * std::log10 (distance / 1000) + 20 * std::log10 (fmhz);
192  double Dhm = m_rooftopHeight - hm;
193  double Lrts = -8.2 - 10 * std::log10 (m_streetsWidth) + 10 * std::log10 (fmhz) + 20 * std::log10 (Dhm) + Lori;
194  NS_LOG_LOGIC (this << " Lbf " << Lbf << " Lrts " << Lrts << " Dhm" << Dhm << " Lmsd " << Lmsd);
195  double loss = 0.0;
196  if (Lrts + Lmsd > 0)
197  {
198  loss = Lbf + Lrts + Lmsd;
199  }
200  else
201  {
202  loss = Lbf;
203  }
204  return loss;
205 }
206 
207 
208 void
210 {
211  m_frequency = freq;
212  m_lambda = 299792458.0 / freq;
213 }
214 
215 
216 double
219  Ptr<MobilityModel> b) const
220 {
221  return (txPowerDbm - GetLoss (a, b));
222 }
223 
224 int64_t
226 {
227  return 0;
228 }
229 
230 
231 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Definition: enum.cc:178
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
double GetDistanceFrom(Ptr< const MobilityModel > position) const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Vector GetPosition(void) const
hold variables of type 'enum'
Definition: enum.h:37
NS_LOG_COMPONENT_DEFINE("ItuR1411NlosOverRooftopPropagationLossModel")
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero. ...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Modelize the propagation loss through a transmission medium.
Hold a floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
double z
z coordinate of vector
Definition: vector.h:57