A Discrete-Event Network Simulator
API
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 "ns3/log.h"
23 #include "ns3/mobility-model.h"
24 #include <ns3/building-list.h>
25 
26 namespace ns3
27 {
28 
29 NS_LOG_COMPONENT_DEFINE("ThreeGppV2vChannelConditionModel");
30 
31 NS_OBJECT_ENSURE_REGISTERED(ThreeGppV2vUrbanChannelConditionModel);
32 
33 TypeId
35 {
36  static TypeId tid = TypeId("ns3::ThreeGppV2vUrbanChannelConditionModel")
38  .SetGroupName("Buildings")
39  .AddConstructor<ThreeGppV2vUrbanChannelConditionModel>();
40  return tid;
41 }
42 
45 {
46  m_buildingsCcm = CreateObject<BuildingsChannelConditionModel>();
47 }
48 
50 {
51 }
52 
53 double
56 {
57  NS_LOG_FUNCTION(this);
58 
59  // determine if there is a building in between the tx and rx
60  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
61  NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
62 
63  double pLos = 0.0;
64  if (cond->IsLos())
65  {
66  // compute the 2D distance between a and b
67  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
68 
69  // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
70  pLos = std::min(1.0, 1.05 * exp(-0.0114 * distance2D));
71  }
72 
73  return pLos;
74 }
75 
76 double
79 {
80  NS_LOG_FUNCTION(this);
81 
82  // determine the NLOS due to buildings
83  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
84  NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
85 
86  double pNlos = 0.0;
87  if (cond->IsNlos())
88  {
89  pNlos = 1.0;
90  }
91 
92  return pNlos;
93 }
94 
95 // ------------------------------------------------------------------------- //
96 
98 
99 TypeId
101 {
102  static TypeId tid = TypeId("ns3::ThreeGppV2vHighwayChannelConditionModel")
104  .SetGroupName("Buildings")
105  .AddConstructor<ThreeGppV2vHighwayChannelConditionModel>();
106  return tid;
107 }
108 
111 {
112  m_buildingsCcm = CreateObject<BuildingsChannelConditionModel>();
114  this,
115  std::placeholders::_1,
116  std::placeholders::_2);
117 }
118 
120 {
121 }
122 
123 double
125  Ptr<const MobilityModel> b) const
126 {
127  NS_LOG_FUNCTION(this);
128 
129  // determine if there is a building in between the tx and rx
131  NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
132 
133  double pLos = 0.0;
134  if (cond->IsLos())
135  {
136  // compute the 2D distance between a and b
137  double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
138 
139  // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
140  if (distance2D <= 475.0)
141  {
142  pLos = std::min(1.0, 2.1013e-6 * distance2D * distance2D - 0.002 * distance2D + 1.0193);
143  }
144  else
145  {
146  pLos = std::max(0.0, 0.54 - 0.001 * (distance2D - 475.0));
147  }
148  }
149 
150  return pLos;
151 }
152 
153 double
155  Ptr<const MobilityModel> b) const
156 {
157  NS_LOG_FUNCTION(this);
158 
159  // determine the NLOS due to buildings
161  NS_ASSERT_MSG(cond->IsO2o(), "The nodes should be outdoor");
162 
163  double pNlos = 0;
164  if (cond->IsNlos())
165  {
166  pNlos = 1.0;
167  }
168 
169  return pNlos;
170 }
171 
175 {
178  {
180  this,
181  std::placeholders::_1,
182  std::placeholders::_2);
183  cond = GetChCondWithBuildings(a, b);
184  }
185  else
186  {
187  ComputeChCond =
189  this,
190  std::placeholders::_1,
191  std::placeholders::_2);
192  cond = GetChCondWithNoBuildings(a, b);
193  }
194  return cond;
195 }
196 
199  Ptr<const MobilityModel> b) const
200 {
201  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition(a, b);
202  return cond;
203 }
204 
207  Ptr<const MobilityModel> b) const
208 {
209  Ptr<ChannelCondition> cond = CreateObject<ChannelCondition>();
210  cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2O);
211  cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS);
212  return cond;
213 }
214 
215 } // end namespace ns3
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
static Iterator End()
static Iterator Begin()
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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
double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
ThreeGppV2vHighwayChannelConditionModel()
Constructor for the ThreeGppV2vHighwayChannelConditionModel class.
std::function< Ptr< ChannelCondition >Ptr< const MobilityModel >, Ptr< const MobilityModel >)> ComputeChCond
The callback which is hooked to a method to compute channel condition.
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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#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.