A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
9
10#include "ns3/enum.h"
11#include "ns3/log.h"
12#include "ns3/mobility-model.h"
13#include "ns3/string.h"
14
15namespace ns3
16{
17
18NS_LOG_COMPONENT_DEFINE("ProbabilisticV2vChannelConditionModel");
19
20NS_OBJECT_ENSURE_REGISTERED(ProbabilisticV2vUrbanChannelConditionModel);
21
22TypeId
24{
25 static TypeId tid =
26 TypeId("ns3::ProbabilisticV2vUrbanChannelConditionModel")
28 .SetGroupName("Propagation")
30 .AddAttribute("Density",
31 "Specifies the density of the vehicles in the scenario."
32 "It can be set to Low, Medium or High.",
37 "Low",
39 "Medium",
41 "High"));
42 return tid;
43}
44
49
53
54double
57{
58 // compute the 2D distance between a and b
59 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
60
61 double pLos = 0.0;
62 switch (m_densityUrban)
63 {
65 pLos = std::min(1.0, std::max(0.0, 0.8548 * exp(-0.0064 * distance2D)));
66 break;
68 pLos = std::min(1.0, std::max(0.0, 0.8372 * exp(-0.0114 * distance2D)));
69 break;
71 pLos = std::min(1.0, std::max(0.0, 0.8962 * exp(-0.017 * distance2D)));
72 break;
73 default:
74 NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
75 }
76
77 return pLos;
78}
79
80double
83{
84 // compute the 2D distance between a and b
85 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
86
87 // compute the NLOSv probability
88 double pNlosv = 0.0;
89 switch (m_densityUrban)
90 {
92 pNlosv = std::min(
93 1.0,
94 std::max(0.0,
95 1 / (0.0396 * distance2D) *
96 exp(-(log(distance2D) - 5.2718) * (log(distance2D) - 5.2718) / 3.4827)));
97 break;
99 pNlosv = std::min(
100 1.0,
101 std::max(0.0,
102 1 / (0.0312 * distance2D) *
103 exp(-(log(distance2D) - 5.0063) * (log(distance2D) - 5.0063) / 2.4544)));
104 break;
106 pNlosv = std::min(
107 1.0,
108 std::max(0.0,
109 1 / (0.0242 * distance2D) *
110 exp(-(log(distance2D) - 5.0115) * (log(distance2D) - 5.0115) / 2.2092)));
111 break;
112 default:
113 NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
114 }
115
116 // derive the NLOS probability
117 double pNlos = 1 - ComputePlos(a, b) - pNlosv;
118 return pNlos;
119}
120
121// ------------------------------------------------------------------------- //
122
124
125TypeId
127{
128 static TypeId tid =
129 TypeId("ns3::ProbabilisticV2vHighwayChannelConditionModel")
131 .SetGroupName("Propagation")
133 .AddAttribute("Density",
134 "Specifies the density of the vehicles in the scenario."
135 "It can be set to Low, Medium or High.",
140 "Low",
142 "Medium",
144 "High"));
145 return tid;
146}
147
152
156
157double
160{
161 // compute the 2D distance between a and b
162 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
163
164 double aLos = 0.0;
165 double bLos = 0.0;
166 double cLos = 0.0;
167 switch (m_densityHighway)
168 {
170 aLos = 1.5e-6;
171 bLos = -0.0015;
172 cLos = 1.0;
173 break;
175 aLos = 2.7e-6;
176 bLos = -0.0025;
177 cLos = 1.0;
178 break;
180 aLos = 3.2e-6;
181 bLos = -0.003;
182 cLos = 1.0;
183 break;
184 default:
185 NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
186 }
187
188 double pLos =
189 std::min(1.0, std::max(0.0, aLos * distance2D * distance2D + bLos * distance2D + cLos));
190
191 return pLos;
192}
193
194double
197{
198 // compute the 2D distance between a and b
199 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
200
201 double aNlos = 0.0;
202 double bNlos = 0.0;
203 double cNlos = 0.0;
204 switch (m_densityHighway)
205 {
207 aNlos = -2.9e-7;
208 bNlos = 0.00059;
209 cNlos = 0.0017;
210 break;
212 aNlos = -3.7e-7;
213 bNlos = 0.00061;
214 cNlos = 0.015;
215 break;
217 aNlos = -4.1e-7;
218 bNlos = 0.00067;
219 cNlos = 0.0;
220 break;
221 default:
222 NS_FATAL_ERROR("Undefined density, choose between Low, Medium and High");
223 }
224
225 double pNlos =
226 std::min(1.0, std::max(0.0, aNlos * pow(distance2D, 2) + bNlos * distance2D + cNlos));
227
228 return pNlos;
229}
230
231} // end namespace ns3
Hold variables of type enum.
Definition enum.h:52
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.
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: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_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 > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:179
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221