A Discrete-Event Network Simulator
API
probabilistic-v2v-channel-condition-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/enum.h"
22 #include "ns3/log.h"
23 #include "ns3/mobility-model.h"
24 #include "ns3/string.h"
25 
26 namespace ns3
27 {
28 
29 NS_LOG_COMPONENT_DEFINE("ProbabilisticV2vChannelConditionModel");
30 
31 NS_OBJECT_ENSURE_REGISTERED(ProbabilisticV2vUrbanChannelConditionModel);
32 
33 TypeId
35 {
36  static TypeId tid =
37  TypeId("ns3::ProbabilisticV2vUrbanChannelConditionModel")
39  .SetGroupName("Propagation")
41  .AddAttribute("Density",
42  "Specifies the density of the vehicles in the scenario."
43  "It can be set to Low, Medium or High.",
45  MakeEnumAccessor<VehicleDensity>(
48  "Low",
49  VehicleDensity::MEDIUM,
50  "Medium",
52  "High"));
53  return tid;
54 }
55 
58 {
59 }
60 
62 {
63 }
64 
65 double
68 {
69  // compute the 2D distance between a and b
70  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
71 
72  double pLos = 0.0;
73  switch (m_densityUrban)
74  {
76  pLos = std::min(1.0, std::max(0.0, 0.8548 * exp(-0.0064 * distance2D)));
77  break;
78  case VehicleDensity::MEDIUM:
79  pLos = std::min(1.0, std::max(0.0, 0.8372 * exp(-0.0114 * distance2D)));
80  break;
82  pLos = std::min(1.0, std::max(0.0, 0.8962 * exp(-0.017 * distance2D)));
83  break;
84  default:
85  NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
86  }
87 
88  return pLos;
89 }
90 
91 double
94 {
95  // compute the 2D distance between a and b
96  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
97 
98  // compute the NLOSv probability
99  double pNlosv = 0.0;
100  switch (m_densityUrban)
101  {
102  case VehicleDensity::LOW:
103  pNlosv = std::min(
104  1.0,
105  std::max(0.0,
106  1 / (0.0396 * distance2D) *
107  exp(-(log(distance2D) - 5.2718) * (log(distance2D) - 5.2718) / 3.4827)));
108  break;
109  case VehicleDensity::MEDIUM:
110  pNlosv = std::min(
111  1.0,
112  std::max(0.0,
113  1 / (0.0312 * distance2D) *
114  exp(-(log(distance2D) - 5.0063) * (log(distance2D) - 5.0063) / 2.4544)));
115  break;
117  pNlosv = std::min(
118  1.0,
119  std::max(0.0,
120  1 / (0.0242 * distance2D) *
121  exp(-(log(distance2D) - 5.0115) * (log(distance2D) - 5.0115) / 2.2092)));
122  break;
123  default:
124  NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
125  }
126 
127  // derive the NLOS probability
128  double pNlos = 1 - ComputePlos(a, b) - pNlosv;
129  return pNlos;
130 }
131 
132 // ------------------------------------------------------------------------- //
133 
135 
136 TypeId
138 {
139  static TypeId tid =
140  TypeId("ns3::ProbabilisticV2vHighwayChannelConditionModel")
142  .SetGroupName("Propagation")
144  .AddAttribute("Density",
145  "Specifies the density of the vehicles in the scenario."
146  "It can be set to Low, Medium or High.",
148  MakeEnumAccessor<VehicleDensity>(
151  "Low",
152  VehicleDensity::MEDIUM,
153  "Medium",
155  "High"));
156  return tid;
157 }
158 
161 {
162 }
163 
165 {
166 }
167 
168 double
170  Ptr<const MobilityModel> b) const
171 {
172  // compute the 2D distance between a and b
173  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
174 
175  double aLos = 0.0;
176  double bLos = 0.0;
177  double cLos = 0.0;
178  switch (m_densityHighway)
179  {
180  case VehicleDensity::LOW:
181  aLos = 1.5e-6;
182  bLos = -0.0015;
183  cLos = 1.0;
184  break;
185  case VehicleDensity::MEDIUM:
186  aLos = 2.7e-6;
187  bLos = -0.0025;
188  cLos = 1.0;
189  break;
191  aLos = 3.2e-6;
192  bLos = -0.003;
193  cLos = 1.0;
194  break;
195  default:
196  NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
197  }
198 
199  double pLos =
200  std::min(1.0, std::max(0.0, aLos * distance2D * distance2D + bLos * distance2D + cLos));
201 
202  return pLos;
203 }
204 
205 double
207  Ptr<const MobilityModel> b) const
208 {
209  // compute the 2D distance between a and b
210  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
211 
212  double aNlos = 0.0;
213  double bNlos = 0.0;
214  double cNlos = 0.0;
215  switch (m_densityHighway)
216  {
217  case VehicleDensity::LOW:
218  aNlos = -2.9e-7;
219  bNlos = 0.00059;
220  cNlos = 0.0017;
221  break;
222  case VehicleDensity::MEDIUM:
223  aNlos = -3.7e-7;
224  bNlos = 0.00061;
225  cNlos = 0.015;
226  break;
228  aNlos = -4.1e-7;
229  bNlos = 0.00067;
230  cNlos = 0.0;
231  break;
232  default:
233  NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
234  }
235 
236  double pNlos =
237  std::min(1.0, std::max(0.0, aNlos * pow(distance2D, 2) + bNlos * distance2D + cNlos));
238 
239  return pNlos;
240 }
241 
242 } // end namespace ns3
#define min(a, b)
Definition: 80211b.c:41
#define max(a, b)
Definition: 80211b.c:42
Hold variables of type enum.
Definition: enum.h:62
Computes the channel condition for the V2V Highway scenario.
double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
~ProbabilisticV2vHighwayChannelConditionModel() override
Destructor for the ProbabilisticV2vHighwayChannelConditionModel class.
ProbabilisticV2vHighwayChannelConditionModel()
Constructor for the ProbabilisticV2vHighwayChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
Computes the channel condition for the V2V Urban scenario.
double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
~ProbabilisticV2vUrbanChannelConditionModel() override
Destructor for the ProbabilisticV2vUrbanChannelConditionModel class.
ProbabilisticV2vUrbanChannelConditionModel()
Constructor for the ProbabilisticV2vUrbanChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Base class for the 3GPP channel condition models.
static double Calculate2dDistance(const Vector &a, const Vector &b)
Computes the 2D distance between two 3D vectors.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#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_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.
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:194