A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-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 * Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 */
8
10
11#include "building-list.h"
12
13#include "ns3/log.h"
14#include "ns3/mobility-model.h"
15
16namespace ns3
17{
18
19NS_LOG_COMPONENT_DEFINE("ThreeGppV2vChannelConditionModel");
20
21NS_OBJECT_ENSURE_REGISTERED(ThreeGppV2vUrbanChannelConditionModel);
22
23TypeId
25{
26 static TypeId tid = TypeId("ns3::ThreeGppV2vUrbanChannelConditionModel")
28 .SetGroupName("Buildings")
30 return tid;
31}
32
38
42
43double
46{
47 NS_LOG_FUNCTION(this);
48
49 // determine if there is a building in between the tx and rx
50 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
51 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
52
53 double pLos = 0.0;
54 if (cond->IsLos())
55 {
56 // compute the 2D distance between a and b
57 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
58
59 // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
60 pLos = std::min(1.0, 1.05 * exp(-0.0114 * distance2D));
61 }
62
63 return pLos;
64}
65
66double
69{
70 NS_LOG_FUNCTION(this);
71
72 // determine the NLOS due to buildings
73 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
74 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
75
76 double pNlos = 0.0;
77 if (cond->IsNlos())
78 {
79 pNlos = 1.0;
80 }
81
82 return pNlos;
83}
84
85// ------------------------------------------------------------------------- //
86
88
91{
92 static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayChannelConditionModel")
94 .SetGroupName("Buildings")
96 return tid;
97}
98
108
112
113double
116{
117 NS_LOG_FUNCTION(this);
118
119 // determine if there is a building in between the tx and rx
121 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
122
123 double pLos = 0.0;
124 if (cond->IsLos())
125 {
126 // compute the 2D distance between a and b
127 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
128
129 // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
130 if (distance2D <= 475.0)
131 {
132 pLos = std::min(1.0, 2.1013e-6 * distance2D * distance2D - 0.002 * distance2D + 1.0193);
133 }
134 else
135 {
136 pLos = std::max(0.0, 0.54 - 0.001 * (distance2D - 475.0));
137 }
138 }
139
140 return pLos;
141}
142
143double
146{
147 NS_LOG_FUNCTION(this);
148
149 // determine the NLOS due to buildings
151 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
152
153 double pNlos = 0;
154 if (cond->IsNlos())
155 {
156 pNlos = 1.0;
157 }
158
159 return pNlos;
160}
161
165{
168 {
170 this,
171 std::placeholders::_1,
172 std::placeholders::_2);
173 cond = GetChCondWithBuildings(a, b);
174 }
175 else
176 {
179 this,
180 std::placeholders::_1,
181 std::placeholders::_2);
182 cond = GetChCondWithNoBuildings(a, b);
183 }
184 return cond;
185}
186
194
204
205} // end namespace ns3
static Iterator End()
static Iterator Begin()
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.
Computes the channel condition for the V2V Highway scenario.
Ptr< ChannelCondition > GetChCondWithNoBuildings(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Get the channel condition between a and b.
Ptr< ChannelCondition > GetChCondWithBuildings(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Get the channel condition between a and b using BuildingsChannelConditionModel.
Ptr< BuildingsChannelConditionModel > m_buildingsCcm
used to determine the obstructions due to buildings
std::function< Ptr< ChannelCondition >(Ptr< const MobilityModel >, Ptr< const MobilityModel >)> ComputeChCond
The callback which is hooked to a method to compute channel condition.
double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
ThreeGppV2vHighwayChannelConditionModel()
Constructor for the ThreeGppV2vHighwayChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table Table 6.2-1 of 3GPP TR 37.885 for the V2V Highway s...
Ptr< ChannelCondition > GetChCondAndFixCallback(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b)
Get the channel condition and redirect the callback ComputeChCond to GetChCondWithBuildings or to Get...
~ThreeGppV2vHighwayChannelConditionModel() override
Destructor for the ThreeGppV2vHighwayChannelConditionModel class.
Computes the channel condition for the V2V Urban scenario.
Ptr< BuildingsChannelConditionModel > m_buildingsCcm
used to determine the obstructions due to buildings
double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
ThreeGppV2vUrbanChannelConditionModel()
Constructor for the ThreeGppV2vUrbanChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table Table 6.2-1 of 3GPP TR 37.885 for the V2V Urban sce...
~ThreeGppV2vUrbanChannelConditionModel() override
Destructor for the ThreeGppV2vUrbanChannelConditionModel class.
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_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#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 ",...
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.