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{
71 NS_LOG_FUNCTION(this);
72
73 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
74
75 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
76 double loss = 38.77 + 16.7 * log10(distance3D) + 18.2 * log10(m_frequency / 1e9);
77
78 return loss;
79}
80
81double
83{
84 // TODO O2I car penetration loss (TR 38.901 7.4.3.2) not considered
85 NS_LOG_WARN("O2I car penetration loss not yet implemented");
86 return 0;
87}
88
89double
91{
92 NS_LOG_FUNCTION(this);
93
94 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
95 double loss = GetLossLos(a, b) + GetAdditionalNlosvLoss(a, b);
96
97 return loss;
98}
99
100double
102 Ptr<MobilityModel> b) const
103{
104 NS_LOG_FUNCTION(this);
105 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
106 double hBs = std::max(a->GetPosition().z, b->GetPosition().z);
107 double hUt = std::min(a->GetPosition().z, b->GetPosition().z);
108
109 // From TR 37.885 v15.2.0
110 // When a V2V link is in NLOSv, additional vehicle blockage loss is
111 // added as follows:
112 // 1. The blocker height is the vehicle height which is randomly selected
113 // out of the three vehicle types according to the portion of the vehicle
114 // types in the simulated scenario.
115 double additionalLoss = 0;
116 double blockerHeight = 0;
117 double mu_a = 0;
118 double sigma_a = 0;
119 double randomValue = m_uniformVar->GetValue() * 100.0;
120 if (randomValue < m_percType3Vehicles)
121 {
122 // vehicles of type 3 have height 3 meters
123 blockerHeight = 3.0;
124 }
125 else
126 {
127 // vehicles of type 1 and 2 have height 1.6 meters
128 blockerHeight = 1.6;
129 }
130
131 // The additional blockage loss is max {0 dB, a log-normal random variable}
132 if (std::min(hUt, hBs) > blockerHeight)
133 {
134 // Case 1: Minimum antenna height value of TX and RX > Blocker height
135 additionalLoss = 0;
136 }
137 else if (std::max(hUt, hBs) < blockerHeight)
138 {
139 // Case 2: Maximum antenna height value of TX and RX < Blocker height
140 mu_a = 9.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
141 sigma_a = 4.5;
142 m_logNorVar->SetAttribute(
143 "Mu",
144 DoubleValue(log(pow(mu_a, 2) / sqrt(pow(sigma_a, 2) + pow(mu_a, 2)))));
145 m_logNorVar->SetAttribute("Sigma",
146 DoubleValue(sqrt(log(pow(sigma_a, 2) / pow(mu_a, 2) + 1))));
147 additionalLoss = std::max(0.0, m_logNorVar->GetValue());
148 }
149 else
150 {
151 // Case 3: Otherwise
152 mu_a = 5.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
153 sigma_a = 4.0;
154
155 m_logNorVar->SetAttribute(
156 "Mu",
157 DoubleValue(log(pow(mu_a, 2) / sqrt(pow(sigma_a, 2) + pow(mu_a, 2)))));
158 m_logNorVar->SetAttribute("Sigma",
159 DoubleValue(sqrt(log(pow(sigma_a, 2) / pow(mu_a, 2) + 1))));
160 additionalLoss = std::max(0.0, m_logNorVar->GetValue());
161 }
162
163 return additionalLoss;
164}
165
166double
168{
169 NS_LOG_FUNCTION(this);
170
171 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
172
173 double loss = 36.85 + 30 * log10(distance3D) + 18.9 * log10(m_frequency / 1e9);
174
175 return loss;
176}
177
178double
180 Ptr<MobilityModel> /* a */,
181 Ptr<MobilityModel> /* b */,
183{
184 NS_LOG_FUNCTION(this);
185 double shadowingStd;
186
189 {
190 shadowingStd = 3.0;
191 }
193 {
194 shadowingStd = 4.0;
195 }
196 else
197 {
198 NS_FATAL_ERROR("Unknown channel condition");
199 }
200
201 return shadowingStd;
202}
203
204double
207{
208 NS_LOG_FUNCTION(this);
209 double correlationDistance;
210
211 // See 3GPP TR 37.885, Table 6.2.3-1
213 {
214 correlationDistance = 10;
215 }
218 {
219 correlationDistance = 13;
220 }
221 else
222 {
223 NS_FATAL_ERROR("Unknown channel condition");
224 }
225
226 return correlationDistance;
227}
228
229int64_t
231{
232 NS_LOG_FUNCTION(this);
233
234 m_normRandomVariable->SetStream(stream);
235 m_uniformVar->SetStream(stream + 1);
236 m_logNorVar->SetStream(stream + 2);
237 return 3;
238}
239
240// ------------------------------------------------------------------------- //
241
243
244TypeId
246{
247 static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayPropagationLossModel")
249 .SetGroupName("Propagation")
251 return tid;
252}
253
256{
257 NS_LOG_FUNCTION(this);
258}
259
261{
262 NS_LOG_FUNCTION(this);
263}
264
265double
267{
268 NS_LOG_FUNCTION(this);
269
270 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
271
272 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
273 double loss = 32.4 + 20 * log10(distance3D) + 20 * log10(m_frequency / 1e9);
274
275 return loss;
276}
277
278} // 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(Ptr< MobilityModel > a, Ptr< MobilityModel > b) 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 GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed by a building.
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) 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 GetAdditionalNlosvLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Computes the additional loss due to an obstruction caused by a vehicle.
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
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< UniformRandomVariable > m_uniformVar
uniform random variable
double GetLossNlosv(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed by a vehicle.
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.
#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.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:109
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43