A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
itu-r-1411-nlos-over-rooftop-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2012 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 */
11
12#include "ns3/double.h"
13#include "ns3/enum.h"
14#include "ns3/log.h"
15#include "ns3/mobility-model.h"
16
17#include <cmath>
18
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("ItuR1411NlosOverRooftopPropagationLossModel");
23
24NS_OBJECT_ENSURE_REGISTERED(ItuR1411NlosOverRooftopPropagationLossModel);
25
26TypeId
28{
29 static TypeId tid =
30 TypeId("ns3::ItuR1411NlosOverRooftopPropagationLossModel")
32 .SetGroupName("Propagation")
34 .AddAttribute(
35 "Frequency",
36 "The Frequency (default is 2.106 GHz).",
37 DoubleValue(2160e6),
40 .AddAttribute("Environment",
41 "Environment Scenario",
46 "Urban",
48 "SubUrban",
50 "OpenAreas"))
51 .AddAttribute(
52 "CitySize",
53 "Dimension of the city",
57 MakeEnumChecker(SmallCity, "Small", MediumCity, "Medium", LargeCity, "Large"))
58 .AddAttribute(
59 "RooftopLevel",
60 "The height of the rooftop level in meters",
61 DoubleValue(20.0),
64 .AddAttribute("StreetsOrientation",
65 "The orientation of streets in degrees [0,90] with respect to the "
66 "direction of propagation",
67 DoubleValue(45.0),
71 .AddAttribute(
72 "StreetsWidth",
73 "The width of streets",
74 DoubleValue(20.0),
76 MakeDoubleChecker<double>(0.0, 1000.0))
77 .AddAttribute(
78 "BuildingsExtend",
79 "The distance over which the buildings extend",
80 DoubleValue(80.0),
83 .AddAttribute("BuildingSeparation",
84 "The separation between buildings",
85 DoubleValue(50.0),
89
90 return tid;
91}
92
97
101
102double
104 Ptr<MobilityModel> b) const
105{
106 NS_LOG_FUNCTION(this << a << b);
107 double Lori = 0.0;
108 double fmhz = m_frequency / 1e6;
109
111 " Street Orientation must be in [0,90]");
112 if (m_streetsOrientation < 35)
113 {
114 Lori = -10.0 + 0.354 * m_streetsOrientation;
115 }
116 else if ((m_streetsOrientation >= 35) && (m_streetsOrientation < 55))
117 {
118 Lori = 2.5 + 0.075 * (m_streetsOrientation - 35);
119 }
120 else // m_streetsOrientation >= 55
121 {
122 Lori = 2.5 + 0.075 * (m_streetsOrientation - 55);
123 }
124
125 double distance = a->GetDistanceFrom(b);
126 double hb = (a->GetPosition().z > b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z);
127 double hm = (a->GetPosition().z < b->GetPosition().z ? a->GetPosition().z : b->GetPosition().z);
128 NS_ASSERT_MSG(hm > 0 && hb > 0, "nodes' height must be greater then 0");
129 double Dhb = hb - m_rooftopHeight;
130 double ds = (m_lambda * distance * distance) / (Dhb * Dhb);
131 double Lmsd = 0.0;
132 NS_LOG_LOGIC(this << " build " << m_buildingsExtend << " ds " << ds << " roof "
133 << m_rooftopHeight << " hb " << hb << " lambda " << m_lambda);
134 if (ds < m_buildingsExtend)
135 {
136 double Lbsh = 0.0;
137 double ka = 0.0;
138 double kd = 0.0;
139 double kf = 0.0;
140 if (hb > m_rooftopHeight)
141 {
142 Lbsh = -18 * std::log10(1 + Dhb);
143 ka = (fmhz > 2000 ? 71.4 : 54.0);
144 kd = 18.0;
145 }
146 else
147 {
148 Lbsh = 0;
149 kd = 18.0 - 15 * Dhb / a->GetPosition().z;
150 if (distance < 500)
151 {
152 ka = 54.0 - 1.6 * Dhb * distance / 1000;
153 }
154 else
155 {
156 ka = 54.0 - 0.8 * Dhb;
157 }
158 }
159 if (fmhz > 2000)
160 {
161 kf = -8;
162 }
164 {
165 kf = -4 + 0.7 * (fmhz / 925.0 - 1);
166 }
167 else
168 {
169 kf = -4 + 1.5 * (fmhz / 925.0 - 1);
170 }
171
172 Lmsd = Lbsh + ka + kd * std::log10(distance / 1000.0) + kf * std::log10(fmhz) -
173 9.0 * std::log10(m_buildingSeparation);
174 }
175 else
176 {
177 double theta = std::atan(Dhb / m_buildingSeparation);
178 double rho = std::sqrt(Dhb * Dhb + m_buildingSeparation * m_buildingSeparation);
179 double Qm = 0.0;
180 if ((hb > m_rooftopHeight - 1.0) && (hb < m_rooftopHeight + 1.0))
181 {
182 Qm = m_buildingSeparation / distance;
183 }
184 else if (hb > m_rooftopHeight)
185 {
186 Qm = 2.35 * pow(Dhb / distance * std::sqrt(m_buildingSeparation / m_lambda), 0.9);
187 }
188 else
189 {
190 Qm = m_buildingSeparation / (2 * M_PI * distance) * std::sqrt(m_lambda / rho) *
191 (1 / theta - (1 / (2 * M_PI + theta)));
192 }
193 Lmsd = -10 * std::log10(Qm * Qm);
194 }
195 double Lbf = 32.4 + 20 * std::log10(distance / 1000) + 20 * std::log10(fmhz);
196 double Dhm = m_rooftopHeight - hm;
197 double Lrts = -8.2 - 10 * std::log10(m_streetsWidth) + 10 * std::log10(fmhz) +
198 20 * std::log10(Dhm) + Lori;
199 NS_LOG_LOGIC(this << " Lbf " << Lbf << " Lrts " << Lrts << " Dhm" << Dhm << " Lmsd " << Lmsd);
200 double loss = 0.0;
201 if (Lrts + Lmsd > 0)
202 {
203 loss = Lbf + Lrts + Lmsd;
204 }
205 else
206 {
207 loss = Lbf;
208 }
209 return loss;
210}
211
212void
214{
215 m_frequency = freq;
216 m_lambda = 299792458.0 / freq;
217}
218
219double
222 Ptr<MobilityModel> b) const
223{
224 return (txPowerDbm - GetLoss(a, b));
225}
226
227int64_t
232
233} // namespace ns3
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
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Models the propagation loss through a transmission medium.
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_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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