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 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
9
10#include "ns3/double.h"
11#include "ns3/log.h"
12#include "ns3/string.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("ThreeGppV2vPropagationLossModel");
18
19// ------------------------------------------------------------------------- //
20
21NS_OBJECT_ENSURE_REGISTERED(ThreeGppV2vUrbanPropagationLossModel);
22
23TypeId
25{
26 static TypeId tid =
27 TypeId("ns3::ThreeGppV2vUrbanPropagationLossModel")
29 .SetGroupName("Propagation")
31 .AddAttribute(
32 "PercType3Vehicles",
33 "The percentage of vehicles of type 3 (i.e., trucks) in the scenario",
34 DoubleValue(0.0),
36 MakeDoubleChecker<double>(0.0, 100.0));
37 return tid;
38}
39
42{
43 NS_LOG_FUNCTION(this);
46
47 // set a default channel condition model
48 // TODO the default ccm needs buildings, how to do this?
49 // m_channelConditionModel = CreateObject<ThreeGppRmaChannelConditionModel> ();
50}
51
56
57double
59{
60 NS_LOG_FUNCTION(this);
61
62 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
63
64 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
65 double loss = 38.77 + 16.7 * log10(distance3D) + 18.2 * log10(m_frequency / 1e9);
66
67 return loss;
68}
69
70double
72{
73 // TODO O2I car penetration loss (TR 38.901 7.4.3.2) not considered
74 NS_LOG_WARN("O2I car penetration loss not yet implemented");
75 return 0;
76}
77
78double
80{
81 NS_LOG_FUNCTION(this);
82
83 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
84 double loss = GetLossLos(a, b) + GetAdditionalNlosvLoss(a, b);
85
86 return loss;
87}
88
89double
91 Ptr<MobilityModel> b) const
92{
93 NS_LOG_FUNCTION(this);
94 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
95 double hBs = std::max(a->GetPosition().z, b->GetPosition().z);
96 double hUt = std::min(a->GetPosition().z, b->GetPosition().z);
97
98 // From TR 37.885 v15.2.0
99 // When a V2V link is in NLOSv, additional vehicle blockage loss is
100 // added as follows:
101 // 1. The blocker height is the vehicle height which is randomly selected
102 // out of the three vehicle types according to the portion of the vehicle
103 // types in the simulated scenario.
104 double additionalLoss = 0;
105 double blockerHeight = 0;
106 double mu_a = 0;
107 double sigma_a = 0;
108 double randomValue = m_uniformVar->GetValue() * 100.0;
109 if (randomValue < m_percType3Vehicles)
110 {
111 // vehicles of type 3 have height 3 meters
112 blockerHeight = 3.0;
113 }
114 else
115 {
116 // vehicles of type 1 and 2 have height 1.6 meters
117 blockerHeight = 1.6;
118 }
119
120 // The additional blockage loss is max {0 dB, a log-normal random variable}
121 if (std::min(hUt, hBs) > blockerHeight)
122 {
123 // Case 1: Minimum antenna height value of TX and RX > Blocker height
124 additionalLoss = 0;
125 }
126 else if (std::max(hUt, hBs) < blockerHeight)
127 {
128 // Case 2: Maximum antenna height value of TX and RX < Blocker height
129 mu_a = 9.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
130 sigma_a = 4.5;
131 m_logNorVar->SetAttribute(
132 "Mu",
133 DoubleValue(log(pow(mu_a, 2) / sqrt(pow(sigma_a, 2) + pow(mu_a, 2)))));
134 m_logNorVar->SetAttribute("Sigma",
135 DoubleValue(sqrt(log(pow(sigma_a, 2) / pow(mu_a, 2) + 1))));
136 additionalLoss = std::max(0.0, m_logNorVar->GetValue());
137 }
138 else
139 {
140 // Case 3: Otherwise
141 mu_a = 5.0 + std::max(0.0, 15 * log10(distance3D) - 41.0);
142 sigma_a = 4.0;
143
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
152 return additionalLoss;
153}
154
155double
157{
158 NS_LOG_FUNCTION(this);
159
160 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
161
162 double loss = 36.85 + 30 * log10(distance3D) + 18.9 * log10(m_frequency / 1e9);
163
164 return loss;
165}
166
167double
169 Ptr<MobilityModel> /* a */,
170 Ptr<MobilityModel> /* b */,
172{
173 NS_LOG_FUNCTION(this);
174 double shadowingStd;
175
178 {
179 shadowingStd = 3.0;
180 }
182 {
183 shadowingStd = 4.0;
184 }
185 else
186 {
187 NS_FATAL_ERROR("Unknown channel condition");
188 }
189
190 return shadowingStd;
191}
192
193double
196{
197 NS_LOG_FUNCTION(this);
198 double correlationDistance;
199
200 // See 3GPP TR 37.885, Table 6.2.3-1
202 {
203 correlationDistance = 10;
204 }
207 {
208 correlationDistance = 13;
209 }
210 else
211 {
212 NS_FATAL_ERROR("Unknown channel condition");
213 }
214
215 return correlationDistance;
216}
217
218int64_t
220{
221 NS_LOG_FUNCTION(this);
222
223 m_normRandomVariable->SetStream(stream);
224 m_uniformVar->SetStream(stream + 1);
225 m_logNorVar->SetStream(stream + 2);
226 return 3;
227}
228
229// ------------------------------------------------------------------------- //
230
232
233TypeId
235{
236 static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayPropagationLossModel")
238 .SetGroupName("Propagation")
240 return tid;
241}
242
248
253
254double
256{
257 NS_LOG_FUNCTION(this);
258
259 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
260
261 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
262 double loss = 32.4 + 20 * log10(distance3D) + 20 * log10(m_frequency / 1e9);
263
264 return loss;
265}
266
267} // 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:31
Smart pointer class similar to boost::intrusive_ptr.
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:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:250
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition vector.cc:98
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32