A Discrete-Event Network Simulator
API
three-gpp-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  * Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation;
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
22 #include "ns3/mobility-model.h"
23 #include "ns3/log.h"
24 #include <ns3/building-list.h>
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("ThreeGppV2vChannelConditionModel");
29 
30 NS_OBJECT_ENSURE_REGISTERED (ThreeGppV2vUrbanChannelConditionModel);
31 
32 TypeId
34 {
35  static TypeId tid = TypeId ("ns3::ThreeGppV2vUrbanChannelConditionModel")
37  .SetGroupName ("Buildings")
38  .AddConstructor<ThreeGppV2vUrbanChannelConditionModel> ()
39  ;
40  return tid;
41 }
42 
45 {
46  m_buildingsCcm = CreateObject<BuildingsChannelConditionModel> ();
47 }
48 
50 {}
51 
52 double
55 {
56  NS_LOG_FUNCTION (this);
57 
58  // determine if there is a building in between the tx and rx
59  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition (a, b);
60  NS_ASSERT_MSG (cond->IsO2o (), "The nodes should be outdoor");
61 
62  double pLos = 0.0;
63  if (cond->IsLos ())
64  {
65  // compute the 2D distance between a and b
66  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
67 
68  // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
69  pLos = std::min (1.0, 1.05 * exp (-0.0114 * distance2D));
70  }
71 
72  return pLos;
73 }
74 
75 double
78 {
79  NS_LOG_FUNCTION (this);
80 
81  // determine the NLOS due to buildings
82  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition (a, b);
83  NS_ASSERT_MSG (cond->IsO2o (), "The nodes should be outdoor");
84 
85  double pNlos = 0.0;
86  if (cond->IsNlos ())
87  {
88  pNlos = 1.0;
89  }
90 
91  return pNlos;
92 }
93 
94 // ------------------------------------------------------------------------- //
95 
97 
98 TypeId
100 {
101  static TypeId tid = TypeId ("ns3::ThreeGppV2vHighwayChannelConditionModel")
103  .SetGroupName ("Buildings")
104  .AddConstructor<ThreeGppV2vHighwayChannelConditionModel> ()
105  ;
106  return tid;
107 }
108 
111 {
112  m_buildingsCcm = CreateObject<BuildingsChannelConditionModel> ();
114  std::placeholders::_1, std::placeholders::_2);
115 }
116 
118 {}
119 
120 double
122  Ptr<const MobilityModel> b) const
123 {
124  NS_LOG_FUNCTION (this);
125 
126  // determine if there is a building in between the tx and rx
127  Ptr<ChannelCondition> cond = ComputeChCond (a, b);
128  NS_ASSERT_MSG (cond->IsO2o (), "The nodes should be outdoor");
129 
130  double pLos = 0.0;
131  if (cond->IsLos ())
132  {
133  // compute the 2D distance between a and b
134  double distance2D = Calculate2dDistance (a->GetPosition (), b->GetPosition ());
135 
136  // compute the LOS probability (see 3GPP TR 37.885, Table 6.2-1)
137  if (distance2D <= 475.0)
138  {
139  pLos = std::min (1.0, 2.1013e-6 * distance2D * distance2D - 0.002 * distance2D + 1.0193);
140  }
141  else
142  {
143  pLos = std::max (0.0, 0.54 - 0.001 * (distance2D - 475.0));
144  }
145  }
146 
147  return pLos;
148 }
149 
150 double
152  Ptr<const MobilityModel> b) const
153 {
154  NS_LOG_FUNCTION (this);
155 
156  // determine the NLOS due to buildings
157  Ptr<ChannelCondition> cond = ComputeChCond (a, b);
158  NS_ASSERT_MSG (cond->IsO2o (), "The nodes should be outdoor");
159 
160  double pNlos = 0;
161  if (cond->IsNlos ())
162  {
163  pNlos = 1.0;
164  }
165 
166  return pNlos;
167 }
168 
172 {
175  {
177  std::placeholders::_1, std::placeholders::_2);
178  cond = GetChCondWithBuildings (a, b);
179  }
180  else
181  {
183  std::placeholders::_1, std::placeholders::_2);
184  cond = GetChCondWithNoBuildings (a, b);
185  }
186  return cond;
187 }
188 
191  Ptr<const MobilityModel> b) const
192 {
193  Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition (a, b);
194  return cond;
195 }
196 
199  Ptr<const MobilityModel> b) const
200 {
201  Ptr<ChannelCondition> cond = CreateObject<ChannelCondition> ();
202  cond->SetO2iCondition (ChannelCondition::O2iConditionValue::O2O);
203  cond->SetLosCondition (ChannelCondition::LosConditionValue::LOS);
204  return cond;
205 }
206 
207 } // end namespace ns3
virtual ~ThreeGppV2vHighwayChannelConditionModel() override
Destructor for the ThreeGppV2vHighwayChannelConditionModel class.
Ptr< ChannelCondition > GetChCondWithNoBuildings(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Get the channel condition between a and b.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual 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...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Ptr< BuildingsChannelConditionModel > m_buildingsCcm
used to determine the obstructions due to buildings
#define min(a, b)
Definition: 80211b.c:42
std::function< Ptr< ChannelCondition >Ptr< const MobilityModel >, Ptr< const MobilityModel >) > ComputeChCond
The callback which is hooked to a method to compute channel condition.
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS 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.
static Iterator End(void)
static Iterator Begin(void)
Ptr< ChannelCondition > GetChCondAndFixCallback(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b)
Get the channel condition and redirect the callback ComputeChCond to GetChaCondWithBuildings or to Ge...
#define max(a, b)
Definition: 80211b.c:43
Base class for the 3GPP channel condition models.
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
Ptr< ChannelCondition > GetChCondWithBuildings(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Get the channel condition between a and b using BuildingsChannelConditionModel.
virtual 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...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Computes the channel condition for the V2V Highway scenario.
ThreeGppV2vHighwayChannelConditionModel()
Constructor for the ThreeGppV2vHighwayChannelConditionModel class.
virtual ~ThreeGppV2vUrbanChannelConditionModel() override
Destructor for the ThreeGppV2vUrbanChannelConditionModel class.
#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:88
ThreeGppV2vUrbanChannelConditionModel()
Constructor for the ThreeGppV2vUrbanChannelConditionModel class.
Ptr< BuildingsChannelConditionModel > m_buildingsCcm
used to determine the obstructions due to buildings
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 Urban scenario.