A Discrete-Event Network Simulator
API
three-gpp-v2v-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) 2020 SIGNET Lab, Department of Information Engineering,
4 * University of Padova
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
21#include "ns3/double.h"
22#include "ns3/log.h"
23#include "ns3/string.h"
24
25namespace ns3 {
26
27NS_LOG_COMPONENT_DEFINE ("ThreeGppV2vPropagationLossModel");
28
29// ------------------------------------------------------------------------- //
30
31NS_OBJECT_ENSURE_REGISTERED (ThreeGppV2vUrbanPropagationLossModel);
32
33TypeId
35{
36 static TypeId tid = TypeId ("ns3::ThreeGppV2vUrbanPropagationLossModel")
38 .SetGroupName ("Propagation")
39 .AddConstructor<ThreeGppV2vUrbanPropagationLossModel> ()
40 .AddAttribute ("PercType3Vehicles",
41 "The percentage of vehicles of type 3 (i.e., trucks) in the scenario",
42 DoubleValue (0.0),
44 MakeDoubleChecker<double> (0.0, 100.0))
45 ;
46 return tid;
47}
48
51{
52 NS_LOG_FUNCTION (this);
53 m_uniformVar = CreateObject<UniformRandomVariable> ();
54 m_logNorVar = CreateObject<LogNormalRandomVariable> ();
55
56 // set a default channel condition model
57 // TODO the default ccm needs buildings, how to do this?
58 // m_channelConditionModel = CreateObject<ThreeGppRmaChannelConditionModel> ();
59}
60
62{
63 NS_LOG_FUNCTION (this);
64}
65
66double
67ThreeGppV2vUrbanPropagationLossModel::GetLossLos (double /* distance2D */, double distance3D, double /* hUt */, double /* hBs */) const
68{
69 NS_LOG_FUNCTION (this);
70
71 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
72 double loss = 38.77 + 16.7 * log10 (distance3D) + 18.2 * log10 (m_frequency / 1e9);
73
74 return loss;
75}
76
77double
78ThreeGppV2vUrbanPropagationLossModel::GetLossNlosv (double distance2D, double distance3D, double hUt, double hBs) const
79{
80 NS_LOG_FUNCTION (this);
81
82 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
83 double loss = GetLossLos (distance2D, distance3D, hUt, hBs) + GetAdditionalNlosvLoss (distance3D, hUt, hBs);
84
85 return loss;
86}
87
88double
89ThreeGppV2vUrbanPropagationLossModel::GetAdditionalNlosvLoss (double distance3D, double hUt, double hBs) const
90{
91 NS_LOG_FUNCTION (this);
92 // From TR 37.885 v15.2.0
93 // When a V2V link is in NLOSv, additional vehicle blockage loss is
94 // added as follows:
95 // 1. The blocker height is the vehicle height which is randomly selected
96 // out of the three vehicle types according to the portion of the vehicle
97 // types in the simulated scenario.
98 double additionalLoss = 0;
99 double blockerHeight = 0;
100 double mu_a = 0;
101 double sigma_a = 0;
102 double randomValue = m_uniformVar->GetValue () * 100.0;
103 if (randomValue < m_percType3Vehicles)
104 {
105 // vehicles of type 3 have height 3 meters
106 blockerHeight = 3.0;
107 }
108 else
109 {
110 // vehicles of type 1 and 2 have height 1.6 meters
111 blockerHeight = 1.6;
112 }
113
114 // The additional blockage loss is max {0 dB, a log-normal random variable}
115 if (std::min (hUt, hBs) > blockerHeight)
116 {
117 // Case 1: Minimum antenna height value of TX and RX > Blocker height
118 additionalLoss = 0;
119 }
120 else if (std::max (hUt, hBs) < blockerHeight)
121 {
122 // Case 2: Maximum antenna height value of TX and RX < Blocker height
123 mu_a = 9.0 + std::max (0.0, 15 * log10 (distance3D) - 41.0);
124 sigma_a = 4.5;
125 m_logNorVar->SetAttribute ("Mu", DoubleValue (log (pow (mu_a, 2) / sqrt (pow (sigma_a, 2) + pow (mu_a, 2)))));
126 m_logNorVar->SetAttribute ("Sigma", DoubleValue (sqrt (log (pow (sigma_a, 2) / pow (mu_a, 2) + 1))));
127 additionalLoss = std::max (0.0, m_logNorVar->GetValue ());
128 }
129 else
130 {
131 // Case 3: Otherwise
132 mu_a = 5.0 + std::max (0.0, 15 * log10 (distance3D) - 41.0);
133 sigma_a = 4.0;
134
135 m_logNorVar->SetAttribute ("Mu", DoubleValue (log (pow (mu_a,2) / sqrt (pow (sigma_a, 2) + pow (mu_a, 2)))));
136 m_logNorVar->SetAttribute ("Sigma", DoubleValue (sqrt (log (pow (sigma_a,2) / pow (mu_a, 2) + 1))));
137 additionalLoss = std::max (0.0, m_logNorVar->GetValue ());
138 }
139
140 return additionalLoss;
141}
142
143double
144ThreeGppV2vUrbanPropagationLossModel::GetLossNlos (double /* distance2D */, double distance3D, double /* hUt */, double /* hBs */) const
145{
146 NS_LOG_FUNCTION (this);
147
148 double loss = 36.85 + 30 * log10 (distance3D) + 18.9 * log10 (m_frequency / 1e9);
149
150 return loss;
151}
152
153double
155{
156 NS_LOG_FUNCTION (this);
157 double shadowingStd;
158
159 if (cond == ChannelCondition::LosConditionValue::LOS || cond == ChannelCondition::LosConditionValue::NLOSv)
160 {
161 shadowingStd = 3.0;
162 }
163 else if (cond == ChannelCondition::LosConditionValue::NLOS)
164 {
165 shadowingStd = 4.0;
166 }
167 else
168 {
169 NS_FATAL_ERROR ("Unknown channel condition");
170 }
171
172 return shadowingStd;
173}
174
175double
177{
178 NS_LOG_FUNCTION (this);
179 double correlationDistance;
180
181 // See 3GPP TR 37.885, Table 6.2.3-1
182 if (cond == ChannelCondition::LosConditionValue::LOS)
183 {
184 correlationDistance = 10;
185 }
186 else if (cond == ChannelCondition::LosConditionValue::NLOSv || cond == ChannelCondition::LosConditionValue::NLOS)
187 {
188 correlationDistance = 13;
189 }
190 else
191 {
192 NS_FATAL_ERROR ("Unknown channel condition");
193 }
194
195 return correlationDistance;
196}
197
198// ------------------------------------------------------------------------- //
199
201
202TypeId
204{
205 static TypeId tid = TypeId ("ns3::ThreeGppV2vHighwayPropagationLossModel")
207 .SetGroupName ("Propagation")
209 ;
210 return tid;
211}
212
215{
216 NS_LOG_FUNCTION (this);
217}
218
220{
221 NS_LOG_FUNCTION (this);
222}
223
224double
225ThreeGppV2vHighwayPropagationLossModel::GetLossLos (double /* distance2D */, double distance3D, double /* hUt */, double /* hBs */) const
226{
227 NS_LOG_FUNCTION (this);
228
229 // compute the pathloss (see 3GPP TR 37.885, Table 6.2.1-1)
230 double loss = 32.4 + 20 * log10 (distance3D) + 20 * log10 (m_frequency / 1e9);
231
232 return loss;
233}
234
235} // namespace ns3
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
LosConditionValue
Possible values for Line-of-Sight condition.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
Base class for the 3GPP propagation models.
Implements the pathloss model defined in 3GPP TR 37.885, Table 6.2.1-1 for the Highway scenario.
virtual 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.
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
virtual 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.
virtual 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.
virtual 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
virtual 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.
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:922
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.