A Discrete-Event Network Simulator
API
probabilistic-v2v-channel-condition-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/log.h"
22 #include "ns3/string.h"
23 #include "ns3/mobility-model.h"
24 #include "ns3/enum.h"
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("ProbabilisticV2vChannelConditionModel");
29 
30 NS_OBJECT_ENSURE_REGISTERED (ProbabilisticV2vUrbanChannelConditionModel);
31 
32 TypeId
34 {
35  static TypeId tid = TypeId ("ns3::ProbabilisticV2vUrbanChannelConditionModel")
37  .SetGroupName ("Propagation")
39  .AddAttribute ("Density", "Specifies the density of the vehicles in the scenario."
40  "It can be set to Low, Medium or High.",
41  EnumValue (VehicleDensity::LOW),
42  MakeEnumAccessor (&ProbabilisticV2vUrbanChannelConditionModel::m_densityUrban),
43  MakeEnumChecker (VehicleDensity::LOW, "Low",
44  VehicleDensity::MEDIUM, "Medium",
45  VehicleDensity::HIGH, "High"))
46  ;
47  return tid;
48 }
49 
52 {}
53 
55 {}
56 
57 double
60 {
61  // compute the 2D distance between a and b
62  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
63 
64  double pLos = 0.0;
65  switch (m_densityUrban)
66  {
67  case VehicleDensity::LOW:
68  pLos = std::min (1.0, std::max (0.0, 0.8548 * exp (-0.0064 * distance2D)));
69  break;
70  case VehicleDensity::MEDIUM:
71  pLos = std::min (1.0, std::max (0.0, 0.8372 * exp (-0.0114 * distance2D)));
72  break;
73  case VehicleDensity::HIGH:
74  pLos = std::min (1.0, std::max (0.0, 0.8962 * exp (-0.017 * distance2D)));
75  break;
76  default:
77  NS_FATAL_ERROR ("Undefined density, choose between Low, Medium and High");
78  }
79 
80  return pLos;
81 }
82 
83 double
86 {
87  // compute the 2D distance between a and b
88  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
89 
90  // compute the NLOSv probability
91  double pNlosv = 0.0;
92  switch (m_densityUrban)
93  {
94  case VehicleDensity::LOW:
95  pNlosv = std::min (1.0, std::max (0.0, 1 / (0.0396 * distance2D) * exp (-(log (distance2D) - 5.2718) * (log (distance2D) - 5.2718) / 3.4827)));
96  break;
97  case VehicleDensity::MEDIUM:
98  pNlosv = std::min (1.0, std::max (0.0, 1 / (0.0312 * distance2D) * exp (-(log (distance2D) - 5.0063) * (log (distance2D) - 5.0063) / 2.4544)));
99  break;
100  case VehicleDensity::HIGH:
101  pNlosv = std::min (1.0, std::max (0.0, 1 / (0.0242 * distance2D) * exp (-(log (distance2D) - 5.0115) * (log (distance2D) - 5.0115) / 2.2092)));
102  break;
103  default:
104  NS_FATAL_ERROR ("Undefined density, choose between Low, Medium and High");
105  }
106 
107  // derive the NLOS probability
108  double pNlos = 1 - ComputePlos (a, b) - pNlosv;
109  return pNlos;
110 }
111 
112 // ------------------------------------------------------------------------- //
113 
115 
116 TypeId
118 {
119  static TypeId tid = TypeId ("ns3::ProbabilisticV2vHighwayChannelConditionModel")
121  .SetGroupName ("Propagation")
123  .AddAttribute ("Density", "Specifies the density of the vehicles in the scenario."
124  "It can be set to Low, Medium or High.",
125  EnumValue (VehicleDensity::LOW),
126  MakeEnumAccessor (&ProbabilisticV2vHighwayChannelConditionModel::m_densityHighway),
127  MakeEnumChecker (VehicleDensity::LOW, "Low",
128  VehicleDensity::MEDIUM, "Medium",
129  VehicleDensity::HIGH, "High"))
130  ;
131  return tid;
132 }
133 
136 {}
137 
139 {}
140 
141 double
143  Ptr<const MobilityModel> b) const
144 {
145  // compute the 2D distance between a and b
146  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
147 
148  double aLos = 0.0;
149  double bLos = 0.0;
150  double cLos = 0.0;
151  switch (m_densityHighway)
152  {
153  case VehicleDensity::LOW:
154  aLos = 1.5e-6;
155  bLos = -0.0015;
156  cLos = 1.0;
157  break;
158  case VehicleDensity::MEDIUM:
159  aLos = 2.7e-6;
160  bLos = -0.0025;
161  cLos = 1.0;
162  break;
163  case VehicleDensity::HIGH:
164  aLos = 3.2e-6;
165  bLos = -0.003;
166  cLos = 1.0;
167  break;
168  default:
169  NS_FATAL_ERROR ("Undefined density, choose between Low, Medium and High");
170  }
171 
172  double pLos = std::min (1.0, std::max (0.0, aLos * distance2D * distance2D + bLos * distance2D + cLos));
173 
174  return pLos;
175 }
176 
177 double
179  Ptr<const MobilityModel> b) const
180 {
181  // compute the 2D distance between a and b
182  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
183 
184  double aNlos = 0.0;
185  double bNlos = 0.0;
186  double cNlos = 0.0;
187  switch (m_densityHighway)
188  {
189  case VehicleDensity::LOW:
190  aNlos = -2.9e-7;
191  bNlos = 0.00059;
192  cNlos = 0.0017;
193  break;
194  case VehicleDensity::MEDIUM:
195  aNlos = -3.7e-7;
196  bNlos = 0.00061;
197  cNlos = 0.015;
198  break;
199  case VehicleDensity::HIGH:
200  aNlos = -4.1e-7;
201  bNlos = 0.00067;
202  cNlos = 0.0;
203  break;
204  default:
205  NS_FATAL_ERROR ("Undefined density, choose between Low, Medium and High");
206  }
207 
208  double pNlos = std::min (1.0, std::max (0.0, aNlos * pow (distance2D, 2) + bNlos * distance2D + cNlos));
209 
210  return pNlos;
211 }
212 
213 } // end namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define min(a, b)
Definition: 80211b.c:42
virtual double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static double Calculate2dDistance(const Vector &a, const Vector &b)
Computes the 2D distance between two 3D vectors.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
Hold variables of type enum.
Definition: enum.h:54
#define max(a, b)
Definition: 80211b.c:43
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:203
Base class for the 3GPP channel condition models.
virtual double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ProbabilisticV2vUrbanChannelConditionModel()
Constructor for the ProbabilisticV2vUrbanChannelConditionModel class.
virtual ~ProbabilisticV2vHighwayChannelConditionModel() override
Destructor for the ProbabilisticV2vHighwayChannelConditionModel class.
Computes the channel condition for the V2V Urban scenario.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:161
virtual ~ProbabilisticV2vUrbanChannelConditionModel() override
Destructor for the ProbabilisticV2vUrbanChannelConditionModel class.
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Computes the channel condition for the V2V Highway scenario.
ProbabilisticV2vHighwayChannelConditionModel()
Constructor for the ProbabilisticV2vHighwayChannelConditionModel class.
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.