A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-v2v-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
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
20
21#include "ns3/double.h"
22#include "ns3/log.h"
23#include "ns3/string.h"
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("ThreeGppV2vPropagationLossModel");
29
30// ------------------------------------------------------------------------- //
31
32NS_OBJECT_ENSURE_REGISTERED(ThreeGppV2vUrbanPropagationLossModel);
33
34TypeId
36{
37 static TypeId tid =
38 TypeId("ns3::ThreeGppV2vUrbanPropagationLossModel")
40 .SetGroupName("Propagation")
42 .AddAttribute(
43 "PercType3Vehicles",
44 "The percentage of vehicles of type 3 (i.e., trucks) in the scenario",
45 DoubleValue(0.0),
47 MakeDoubleChecker<double>(0.0, 100.0));
48 return tid;
49}
50
53{
54 NS_LOG_FUNCTION(this);
55 m_uniformVar = CreateObject<UniformRandomVariable>();
56 m_logNorVar = CreateObject<LogNormalRandomVariable>();
57
58 // set a default channel condition model
59 // TODO the default ccm needs buildings, how to do this?
60 // m_channelConditionModel = CreateObject<ThreeGppRmaChannelConditionModel> ();
61}
62
64{
65 NS_LOG_FUNCTION(this);
66}
67
68double
70 double distance3D,
71 double /* hUt */,
72 double /* hBs */) const
73{
74 NS_LOG_FUNCTION(this);
75
76 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
77 double loss = 38.77 + 16.7 * log10(distance3D) + 18.2 * log10(m_frequency / 1e9);
78
79 return loss;
80}
81
82double
84{
85 // TODO O2I car penetration loss (TR 38.901 7.4.3.2) not considered
86 NS_LOG_WARN("O2I car penetration loss not yet implemented");
87 return 0;
88}
89
90double
92 double distance3D,
93 double hUt,
94 double hBs) const
95{
96 NS_LOG_FUNCTION(this);
97
98 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
99 double loss =
100 GetLossLos(distance2D, distance3D, hUt, hBs) + GetAdditionalNlosvLoss(distance3D, hUt, hBs);
101
102 return loss;
103}
104
105double
107 double hUt,
108 double hBs) const
109{
110 NS_LOG_FUNCTION(this);
111 // From TR 37.885 v15.2.0
112 // When a V2V link is in NLOSv, additional vehicle blockage loss is
113 // added as follows:
114 // 1. The blocker height is the vehicle height which is randomly selected
115 // out of the three vehicle types according to the portion of the vehicle
116 // types in the simulated scenario.
117 double additionalLoss = 0;
118 double blockerHeight = 0;
119 double mu_a = 0;
120 double sigma_a = 0;
121 double randomValue = m_uniformVar->GetValue() * 100.0;
122 if (randomValue < m_percType3Vehicles)
123 {
124 // vehicles of type 3 have height 3 meters
125 blockerHeight = 3.0;
126 }
127 else
128 {
129 // vehicles of type 1 and 2 have height 1.6 meters
130 blockerHeight = 1.6;
131 }
132
133 // The additional blockage loss is max {0 dB, a log-normal random variable}
134 if (std::min(hUt, hBs) > blockerHeight)
135 {
136 // Case 1: Minimum antenna height value of TX and RX > Blocker height
137 additionalLoss = 0;
138 }
139 else if (std::max(hUt, hBs) < blockerHeight)
140 {
141 // Case 2: Maximum antenna height value of TX and RX < Blocker height
142 mu_a = 9.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
143 sigma_a = 4.5;
144 m_logNorVar->SetAttribute(
145 "Mu",
146 DoubleValue(log(pow(mu_a, 2) / sqrt(pow(sigma_a, 2) + pow(mu_a, 2)))));
147 m_logNorVar->SetAttribute("Sigma",
148 DoubleValue(sqrt(log(pow(sigma_a, 2) / pow(mu_a, 2) + 1))));
149 additionalLoss = std::max(0.0, m_logNorVar->GetValue());
150 }
151 else
152 {
153 // Case 3: Otherwise
154 mu_a = 5.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
155 sigma_a = 4.0;
156
157 m_logNorVar->SetAttribute(
158 "Mu",
159 DoubleValue(log(pow(mu_a, 2) / sqrt(pow(sigma_a, 2) + pow(mu_a, 2)))));
160 m_logNorVar->SetAttribute("Sigma",
161 DoubleValue(sqrt(log(pow(sigma_a, 2) / pow(mu_a, 2) + 1))));
162 additionalLoss = std::max(0.0, m_logNorVar->GetValue());
163 }
164
165 return additionalLoss;
166}
167
168double
170 double distance3D,
171 double /* hUt */,
172 double /* hBs */) const
173{
174 NS_LOG_FUNCTION(this);
175
176 double loss = 36.85 + 30 * log10(distance3D) + 18.9 * log10(m_frequency / 1e9);
177
178 return loss;
179}
180
181double
183 Ptr<MobilityModel> /* a */,
184 Ptr<MobilityModel> /* b */,
186{
187 NS_LOG_FUNCTION(this);
188 double shadowingStd;
189
192 {
193 shadowingStd = 3.0;
194 }
196 {
197 shadowingStd = 4.0;
198 }
199 else
200 {
201 NS_FATAL_ERROR("Unknown channel condition");
202 }
203
204 return shadowingStd;
205}
206
207double
210{
211 NS_LOG_FUNCTION(this);
212 double correlationDistance;
213
214 // See 3GPP TR 37.885, Table 6.2.3-1
216 {
217 correlationDistance = 10;
218 }
221 {
222 correlationDistance = 13;
223 }
224 else
225 {
226 NS_FATAL_ERROR("Unknown channel condition");
227 }
228
229 return correlationDistance;
230}
231
232int64_t
234{
235 NS_LOG_FUNCTION(this);
236
237 m_normRandomVariable->SetStream(stream);
238 m_uniformVar->SetStream(stream + 1);
239 m_logNorVar->SetStream(stream + 2);
240 return 3;
241}
242
243// ------------------------------------------------------------------------- //
244
246
247TypeId
249{
250 static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayPropagationLossModel")
252 .SetGroupName("Propagation")
254 return tid;
255}
256
259{
260 NS_LOG_FUNCTION(this);
261}
262
264{
265 NS_LOG_FUNCTION(this);
266}
267
268double
270 double distance3D,
271 double /* hUt */,
272 double /* hBs */) const
273{
274 NS_LOG_FUNCTION(this);
275
276 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
277 double loss = 32.4 + 20 * log10(distance3D) + 20 * log10(m_frequency / 1e9);
278
279 return loss;
280}
281
282} // namespace ns3
LosConditionValue
Possible values for Line-of-Sight condition.
@ NLOSv
Non Line of Sight due to a vehicle.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Base class for the 3GPP propagation models.
Ptr< NormalRandomVariable > m_normRandomVariable
normal random variable
Implements the pathloss model defined in 3GPP TR 37.885, Table 6.2.1-1 for the Highway scenario.
double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
Implements the pathloss model defined in 3GPP TR 37.885, Table 6.2.1-1 for the Urban scenario.
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
double GetLossNlosv(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is obstructed by a vehicle.
double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
double m_percType3Vehicles
percentage of Type 3 vehicles in the scenario (i.e., trucks)
Ptr< LogNormalRandomVariable > m_logNorVar
log normal random variable
double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is obstructed by a building.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double GetAdditionalNlosvLoss(double distance3D, double hUt, double hBs) const
Computes the additional loss due to an obstruction caused by a vehicle.
Ptr< UniformRandomVariable > m_uniformVar
uniform random variable
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.