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 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::ItuR1411NlosOverRooftopPropagationLossModel")
41 
43  .AddConstructor<ItuR1411NlosOverRooftopPropagationLossModel> ()
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 
103 {
104 }
105 
107 {
108 }
109 
110 double
112 {
113  NS_LOG_FUNCTION (this << a << b);
114  double Lori = 0.0;
115  double fmhz = m_frequency / 1e6;
116 
118  " Street Orientation must be in [0,90]");
119  if (m_streetsOrientation < 35)
120  {
121  Lori = -10.0 + 0.354 * m_streetsOrientation;
122  }
123  else if ((m_streetsOrientation >= 35)&&(m_streetsOrientation < 55))
124  {
125  Lori = 2.5 + 0.075 * (m_streetsOrientation - 35);
126  }
127  else // m_streetsOrientation >= 55
128  {
129  Lori = 2.5 + 0.075 * (m_streetsOrientation - 55);
130  }
131 
132  double distance = a->GetDistanceFrom (b);
133  double hb = (a->GetPosition ().z > b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
134  double hm = (a->GetPosition ().z < b->GetPosition ().z ? a->GetPosition ().z : b->GetPosition ().z);
135  NS_ASSERT_MSG (hm > 0 && hb > 0, "nodes' height must be greater then 0");
136  double Dhb = hb - m_rooftopHeight;
137  double ds = (m_lambda * distance * distance) / (Dhb * Dhb);
138  double Lmsd = 0.0;
139  NS_LOG_LOGIC (this << " build " << m_buildingsExtend << " ds " << ds << " roof " << m_rooftopHeight << " hb " << hb << " lambda " << m_lambda);
140  if (ds < m_buildingsExtend)
141  {
142  double Lbsh = 0.0;
143  double ka = 0.0;
144  double kd = 0.0;
145  double kf = 0.0;
146  if (hb > m_rooftopHeight)
147  {
148  Lbsh = -18 * std::log10 (1 + Dhb);
149  ka = (fmhz > 2000 ? 71.4 : 54.0);
150  kd = 18.0;
151  }
152  else
153  {
154  Lbsh = 0;
155  kd = 18.0 - 15 * Dhb / a->GetPosition ().z;
156  if (distance < 500)
157  {
158  ka = 54.0 - 1.6 * Dhb * distance / 1000;
159  }
160  else
161  {
162  ka = 54.0 - 0.8 * Dhb;
163  }
164  }
165  if (fmhz > 2000)
166  {
167  kf = -8;
168  }
170  {
171  kf = -4 + 0.7 * (fmhz / 925.0 - 1);
172  }
173  else
174  {
175  kf = -4 + 1.5 * (fmhz / 925.0 - 1);
176  }
177 
178  Lmsd = Lbsh + ka + kd * std::log10 (distance / 1000.0) + kf * std::log10 (fmhz) - 9.0 * std::log10 (m_buildingSeparation);
179  }
180  else
181  {
182  double theta = std::atan (Dhb / m_buildingSeparation);
183  double rho = std::sqrt (Dhb * Dhb + m_buildingSeparation * m_buildingSeparation);
184  double Qm = 0.0;
185  if ((hb > m_rooftopHeight - 1.0) && (hb < m_rooftopHeight + 1.0))
186  {
187  Qm = m_buildingSeparation / distance;
188  }
189  else if (hb > m_rooftopHeight)
190  {
191  Qm = 2.35 * pow (Dhb / distance * std::sqrt (m_buildingSeparation / m_lambda), 0.9);
192  }
193  else
194  {
195  Qm = m_buildingSeparation / (2 * M_PI * distance) * std::sqrt (m_lambda / rho) * (1 / theta - (1 / (2 * M_PI + theta)));
196  }
197  Lmsd = -10 * std::log10 (Qm * Qm);
198  }
199  double Lbf = 32.4 + 20 * std::log10 (distance / 1000) + 20 * std::log10 (fmhz);
200  double Dhm = m_rooftopHeight - hm;
201  double Lrts = -8.2 - 10 * std::log10 (m_streetsWidth) + 10 * std::log10 (fmhz) + 20 * std::log10 (Dhm) + Lori;
202  NS_LOG_LOGIC (this << " Lbf " << Lbf << " Lrts " << Lrts << " Dhm" << Dhm << " Lmsd " << Lmsd);
203  double loss = 0.0;
204  if (Lrts + Lmsd > 0)
205  {
206  loss = Lbf + Lrts + Lmsd;
207  }
208  else
209  {
210  loss = Lbf;
211  }
212  return loss;
213 }
214 
215 
216 void
218 {
219  m_frequency = freq;
220  m_lambda = 299792458.0 / freq;
221 }
222 
223 
224 double
227  Ptr<MobilityModel> b) const
228 {
229  return (txPowerDbm - GetLoss (a, b));
230 }
231 
232 int64_t
234 {
235  return 0;
236 }
237 
238 
239 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
Vector GetPosition(void) const
hold variables of type 'enum'
Definition: enum.h:37
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
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:610
double z
z coordinate of vector
Definition: vector.h:57