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 * 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
22#include "building-list.h"
23
24#include "ns3/log.h"
25#include "ns3/mobility-model.h"
26
27namespace ns3
28{
29
30NS_LOG_COMPONENT_DEFINE("ThreeGppV2vChannelConditionModel");
31
32NS_OBJECT_ENSURE_REGISTERED(ThreeGppV2vUrbanChannelConditionModel);
33
34TypeId
36{
37 static TypeId tid = TypeId("ns3::ThreeGppV2vUrbanChannelConditionModel")
39 .SetGroupName("Buildings")
41 return tid;
42}
43
46{
47 m_buildingsCcm = CreateObject<BuildingsChannelConditionModel>();
48}
49
51{
52}
53
54double
57{
58 NS_LOG_FUNCTION(this);
59
60 // determine if there is a building in between the tx and rx
61 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
62 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
63
64 double pLos = 0.0;
65 if (cond->IsLos())
66 {
67 // compute the 2D distance between a and b
68 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
69
70 // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
71 pLos = std::min(1.0, 1.05 * exp(-0.0114 * distance2D));
72 }
73
74 return pLos;
75}
76
77double
80{
81 NS_LOG_FUNCTION(this);
82
83 // determine the NLOS due to buildings
84 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
85 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
86
87 double pNlos = 0.0;
88 if (cond->IsNlos())
89 {
90 pNlos = 1.0;
91 }
92
93 return pNlos;
94}
95
96// ------------------------------------------------------------------------- //
97
99
100TypeId
102{
103 static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayChannelConditionModel")
105 .SetGroupName("Buildings")
107 return tid;
108}
109
112{
113 m_buildingsCcm = CreateObject<BuildingsChannelConditionModel>();
115 this,
116 std::placeholders::_1,
117 std::placeholders::_2);
118}
119
121{
122}
123
124double
127{
128 NS_LOG_FUNCTION(this);
129
130 // determine if there is a building in between the tx and rx
132 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
133
134 double pLos = 0.0;
135 if (cond->IsLos())
136 {
137 // compute the 2D distance between a and b
138 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
139
140 // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
141 if (distance2D <= 475.0)
142 {
143 pLos = std::min(1.0, 2.1013e-6 * distance2D * distance2D - 0.002 * distance2D + 1.0193);
144 }
145 else
146 {
147 pLos = std::max(0.0, 0.54 - 0.001 * (distance2D - 475.0));
148 }
149 }
150
151 return pLos;
152}
153
154double
157{
158 NS_LOG_FUNCTION(this);
159
160 // determine the NLOS due to buildings
162 NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
163
164 double pNlos = 0;
165 if (cond->IsNlos())
166 {
167 pNlos = 1.0;
168 }
169
170 return pNlos;
171}
172
176{
179 {
181 this,
182 std::placeholders::_1,
183 std::placeholders::_2);
184 cond = GetChCondWithBuildings(a, b);
185 }
186 else
187 {
190 this,
191 std::placeholders::_1,
192 std::placeholders::_2);
193 cond = GetChCondWithNoBuildings(a, b);
194 }
195 return cond;
196}
197
201{
202 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
203 return cond;
204}
205
209{
210 Ptr<ChannelCondition> cond = CreateObject<ChannelCondition>();
211 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2O);
212 cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS);
213 return cond;
214}
215
216} // end namespace ns3
static Iterator End()
static Iterator Begin()
@ O2O
Outdoor to Outdoor.
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.
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:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.