A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-channel-condition-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, NYU WIRELESS, Tandon School of Engineering, New York
3 * University
4 * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering,
5 * University of Padova
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
21#include "ns3/buildings-channel-condition-model.h"
22
23#include "ns3/building-list.h"
24#include "ns3/log.h"
25#include "ns3/mobility-building-info.h"
26#include "ns3/mobility-model.h"
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("BuildingsChannelConditionModel");
32
33NS_OBJECT_ENSURE_REGISTERED(BuildingsChannelConditionModel);
34
35TypeId
37{
38 static TypeId tid = TypeId("ns3::BuildingsChannelConditionModel")
40 .SetGroupName("Buildings")
41 .AddConstructor<BuildingsChannelConditionModel>();
42 return tid;
43}
44
47{
48}
49
51{
52}
53
57{
58 NS_LOG_FUNCTION(this);
61 NS_ASSERT_MSG(a1 && b1, "BuildingsChannelConditionModel only works with MobilityBuildingInfo");
62
63 Ptr<ChannelCondition> cond = CreateObject<ChannelCondition>();
64
65 bool isAIndoor = a1->IsIndoor();
66 bool isBIndoor = b1->IsIndoor();
67
68 if (!isAIndoor && !isBIndoor) // a and b are outdoor
69 {
70 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2O);
71
72 // The outdoor case, determine LOS/NLOS
73 // The channel condition should be LOS if the line of sight is not blocked,
74 // otherwise NLOS
75 bool blocked = IsLineOfSightBlocked(a->GetPosition(), b->GetPosition());
76 NS_LOG_DEBUG("a and b are outdoor, blocked " << blocked);
77 if (!blocked)
78 {
79 NS_LOG_DEBUG("Set LOS");
80 cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS);
81 }
82 else
83 {
84 cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS);
85 }
86 }
87 else if (isAIndoor && isBIndoor) // a and b are indoor
88 {
89 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::I2I);
90
91 // Indoor case, determine is the two nodes are inside the same building
92 // or not
93 if (a1->GetBuilding() == b1->GetBuilding())
94 {
95 NS_LOG_DEBUG("a and b are indoor in the same building");
96 cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS);
97 }
98 else
99 {
100 NS_LOG_DEBUG("a and b are indoor in different buildings");
101 cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS);
102
103 ChannelCondition::O2iLowHighConditionValue lowHighLossConditionA1;
104 ChannelCondition::O2iLowHighConditionValue lowHighLossConditionB1;
105
106 // Low losses considered for Wood or ConcreteWithWindows, while
107 // high losses for ConcreteWithoutWindows and StoneBlocks
108 lowHighLossConditionA1 =
109 a1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
110 a1->GetBuilding()->GetExtWallsType() ==
114
115 lowHighLossConditionB1 =
116 b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
117 b1->GetBuilding()->GetExtWallsType() ==
121
122 if (lowHighLossConditionA1 == ChannelCondition::O2iLowHighConditionValue::HIGH ||
123 lowHighLossConditionB1 == ChannelCondition::O2iLowHighConditionValue::HIGH)
124 {
125 cond->SetO2iLowHighCondition(ChannelCondition::O2iLowHighConditionValue::HIGH);
126 }
127 else
128 {
129 cond->SetO2iLowHighCondition(ChannelCondition::O2iLowHighConditionValue::LOW);
130 }
131 }
132 }
133 else // outdoor to indoor case
134 {
135 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2I);
136
137 NS_LOG_DEBUG("a is indoor and b outdoor or vice-versa");
138 cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS);
139
141 if (isAIndoor)
142 {
143 // Low losses considered for Wood or ConcreteWithWindows, while
144 // high losses for ConcreteWithoutWindows and StoneBlocks
145 lowHighLossCondition =
146 a1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
147 a1->GetBuilding()->GetExtWallsType() ==
151
152 cond->SetO2iLowHighCondition(lowHighLossCondition);
153 }
154 else
155 {
156 lowHighLossCondition =
157 b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
158 b1->GetBuilding()->GetExtWallsType() ==
162 cond->SetO2iLowHighCondition(lowHighLossCondition);
163 }
164 }
165
166 return cond;
167}
168
169bool
171 const ns3::Vector& l2) const
172{
174 {
175 if ((*bit)->IsIntersect(l1, l2))
176 {
177 // The line of sight should be blocked if the line-segment between
178 // l1 and l2 intersects one of the buildings.
179 return true;
180 }
181 }
182
183 // The line of sight should not be blocked if the line-segment between
184 // l1 and l2 did not intersect any building.
185 return false;
186}
187
188int64_t
190{
191 return 0;
192}
193
194} // end namespace ns3
@ ConcreteWithWindows
Definition: building.h:63
std::vector< Ptr< Building > >::const_iterator Iterator
Const Iterator.
Definition: building-list.h:41
static Iterator End()
static Iterator Begin()
Determines the channel condition based on the buildings deployed in the scenario.
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the condition of the channel between a and b.
bool IsLineOfSightBlocked(const Vector &l1, const Vector &l2) const
Checks if the line of sight between position l1 and position l2 is blocked by a building.
BuildingsChannelConditionModel()
Constructor for the BuildingsChannelConditionModel class.
~BuildingsChannelConditionModel() override
Destructor for the BuildingsChannelConditionModel class.
@ O2O
Outdoor to Outdoor.
O2iLowHighConditionValue
Possible values for Low-High Penetration Loss condition.
@ LOW
Low Penetration Losses.
@ HIGH
High Penetration Losses.
Models the channel condition.
mobility buildings information (to be used by mobility models)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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.