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
26namespace ns3 {
27
28NS_LOG_COMPONENT_DEFINE ("ThreeGppV2vChannelConditionModel");
29
30NS_OBJECT_ENSURE_REGISTERED (ThreeGppV2vUrbanChannelConditionModel);
31
32TypeId
34{
35 static TypeId tid = TypeId ("ns3::ThreeGppV2vUrbanChannelConditionModel")
37 .SetGroupName ("Buildings")
39 ;
40 return tid;
41}
42
45{
46 m_buildingsCcm = CreateObject<BuildingsChannelConditionModel> ();
47}
48
50{}
51
52double
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
75double
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
100{
101 static TypeId tid = TypeId ("ns3::ThreeGppV2vHighwayChannelConditionModel")
103 .SetGroupName ("Buildings")
105 ;
106 return tid;
107}
108
111{
112 m_buildingsCcm = CreateObject<BuildingsChannelConditionModel> ();
114 std::placeholders::_1, std::placeholders::_2);
115}
116
118{}
119
120double
123{
124 NS_LOG_FUNCTION (this);
125
126 // determine if there is a building in between the tx and rx
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
150double
153{
154 NS_LOG_FUNCTION (this);
155
156 // determine the NLOS due to buildings
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
192{
193 Ptr<ChannelCondition> cond = m_buildingsCcm->GetChannelCondition (a, b);
194 return cond;
195}
196
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
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
static Iterator End(void)
static Iterator Begin(void)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
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.
std::function< Ptr< ChannelCondition >(Ptr< const MobilityModel >, Ptr< const MobilityModel >) > ComputeChCond
The callback which is hooked to a method to compute channel condition.
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
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
ThreeGppV2vHighwayChannelConditionModel()
Constructor for the ThreeGppV2vHighwayChannelConditionModel class.
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...
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...
virtual ~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
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the NLOS probability.
ThreeGppV2vUrbanChannelConditionModel()
Constructor for the ThreeGppV2vUrbanChannelConditionModel class.
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...
virtual ~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:922
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.