A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
* SPDX-License-Identifier: GPL-2.0-only
8
*/
9
10
#include "
buildings-channel-condition-model.h
"
11
12
#include "
building-list.h
"
13
#include "
mobility-building-info.h
"
14
15
#include "ns3/log.h"
16
#include "ns3/mobility-model.h"
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"BuildingsChannelConditionModel"
);
22
23
NS_OBJECT_ENSURE_REGISTERED
(BuildingsChannelConditionModel);
24
25
TypeId
26
BuildingsChannelConditionModel::GetTypeId
()
27
{
28
static
TypeId
tid =
TypeId
(
"ns3::BuildingsChannelConditionModel"
)
29
.
SetParent
<
ChannelConditionModel
>()
30
.SetGroupName(
"Buildings"
)
31
.AddConstructor<
BuildingsChannelConditionModel
>();
32
return
tid;
33
}
34
35
BuildingsChannelConditionModel::BuildingsChannelConditionModel
()
36
:
ChannelConditionModel
()
37
{
38
}
39
40
BuildingsChannelConditionModel::~BuildingsChannelConditionModel
()
41
{
42
}
43
44
Ptr<ChannelCondition>
45
BuildingsChannelConditionModel::GetChannelCondition
(
Ptr<const MobilityModel>
a,
46
Ptr<const MobilityModel>
b)
const
47
{
48
NS_LOG_FUNCTION
(
this
);
49
Ptr<MobilityBuildingInfo>
a1 = a->GetObject<
MobilityBuildingInfo
>();
50
Ptr<MobilityBuildingInfo>
b1 = b->GetObject<
MobilityBuildingInfo
>();
51
NS_ASSERT_MSG
(a1 && b1,
"BuildingsChannelConditionModel only works with MobilityBuildingInfo"
);
52
53
Ptr<ChannelCondition>
cond =
CreateObject<ChannelCondition>
();
54
55
bool
isAIndoor = a1->IsIndoor();
56
bool
isBIndoor = b1->IsIndoor();
57
58
if
(!isAIndoor && !isBIndoor)
// a and b are outdoor
59
{
60
cond->SetO2iCondition(
ChannelCondition::O2iConditionValue::O2O
);
61
62
// The outdoor case, determine LOS/NLOS
63
// The channel condition should be LOS if the line of sight is not blocked,
64
// otherwise NLOS
65
bool
blocked =
IsLineOfSightBlocked
(a->GetPosition(), b->GetPosition());
66
NS_LOG_DEBUG
(
"a and b are outdoor, blocked "
<< blocked);
67
if
(!blocked)
68
{
69
NS_LOG_DEBUG
(
"Set LOS"
);
70
cond->SetLosCondition(
ChannelCondition::LosConditionValue::LOS
);
71
}
72
else
73
{
74
cond->SetLosCondition(
ChannelCondition::LosConditionValue::NLOS
);
75
}
76
}
77
else
if
(isAIndoor && isBIndoor)
// a and b are indoor
78
{
79
cond->SetO2iCondition(
ChannelCondition::O2iConditionValue::I2I
);
80
81
// Indoor case, determine is the two nodes are inside the same building
82
// or not
83
if
(a1->GetBuilding() == b1->GetBuilding())
84
{
85
NS_LOG_DEBUG
(
"a and b are indoor in the same building"
);
86
cond->SetLosCondition(
ChannelCondition::LosConditionValue::LOS
);
87
}
88
else
89
{
90
NS_LOG_DEBUG
(
"a and b are indoor in different buildings"
);
91
cond->SetLosCondition(
ChannelCondition::LosConditionValue::NLOS
);
92
93
ChannelCondition::O2iLowHighConditionValue
lowHighLossConditionA1;
94
ChannelCondition::O2iLowHighConditionValue
lowHighLossConditionB1;
95
96
// Low losses considered for Wood or ConcreteWithWindows, while
97
// high losses for ConcreteWithoutWindows and StoneBlocks
98
lowHighLossConditionA1 =
99
a1->GetBuilding()->GetExtWallsType() ==
Building::ExtWallsType_t::Wood
||
100
a1->GetBuilding()->GetExtWallsType() ==
101
Building::ExtWallsType_t::ConcreteWithWindows
102
?
ChannelCondition::O2iLowHighConditionValue::LOW
103
:
ChannelCondition::O2iLowHighConditionValue::HIGH
;
104
105
lowHighLossConditionB1 =
106
b1->GetBuilding()->GetExtWallsType() ==
Building::ExtWallsType_t::Wood
||
107
b1->GetBuilding()->GetExtWallsType() ==
108
Building::ExtWallsType_t::ConcreteWithWindows
109
?
ChannelCondition::O2iLowHighConditionValue::LOW
110
:
ChannelCondition::O2iLowHighConditionValue::HIGH
;
111
112
if
(lowHighLossConditionA1 ==
ChannelCondition::O2iLowHighConditionValue::HIGH
||
113
lowHighLossConditionB1 ==
ChannelCondition::O2iLowHighConditionValue::HIGH
)
114
{
115
cond->SetO2iLowHighCondition(
ChannelCondition::O2iLowHighConditionValue::HIGH
);
116
}
117
else
118
{
119
cond->SetO2iLowHighCondition(
ChannelCondition::O2iLowHighConditionValue::LOW
);
120
}
121
}
122
}
123
else
// outdoor to indoor case
124
{
125
cond->SetO2iCondition(
ChannelCondition::O2iConditionValue::O2I
);
126
127
NS_LOG_DEBUG
(
"a is indoor and b outdoor or vice-versa"
);
128
cond->SetLosCondition(
ChannelCondition::LosConditionValue::NLOS
);
129
130
ChannelCondition::O2iLowHighConditionValue
lowHighLossCondition;
131
if
(isAIndoor)
132
{
133
// Low losses considered for Wood or ConcreteWithWindows, while
134
// high losses for ConcreteWithoutWindows and StoneBlocks
135
lowHighLossCondition =
136
a1->GetBuilding()->GetExtWallsType() ==
Building::ExtWallsType_t::Wood
||
137
a1->GetBuilding()->GetExtWallsType() ==
138
Building::ExtWallsType_t::ConcreteWithWindows
139
?
ChannelCondition::O2iLowHighConditionValue::LOW
140
:
ChannelCondition::O2iLowHighConditionValue::HIGH
;
141
142
cond->SetO2iLowHighCondition(lowHighLossCondition);
143
}
144
else
145
{
146
lowHighLossCondition =
147
b1->GetBuilding()->GetExtWallsType() ==
Building::ExtWallsType_t::Wood
||
148
b1->GetBuilding()->GetExtWallsType() ==
149
Building::ExtWallsType_t::ConcreteWithWindows
150
?
ChannelCondition::O2iLowHighConditionValue::LOW
151
:
ChannelCondition::O2iLowHighConditionValue::HIGH
;
152
cond->SetO2iLowHighCondition(lowHighLossCondition);
153
}
154
}
155
156
return
cond;
157
}
158
159
bool
160
BuildingsChannelConditionModel::IsLineOfSightBlocked
(
const
ns3::Vector& l1,
161
const
ns3::Vector& l2)
const
162
{
163
for
(
auto
bit =
BuildingList::Begin
(); bit !=
BuildingList::End
(); ++bit)
164
{
165
if
((*bit)->IsIntersect(l1, l2))
166
{
167
// The line of sight should be blocked if the line-segment between
168
// l1 and l2 intersects one of the buildings.
169
return
true
;
170
}
171
}
172
173
// The line of sight should not be blocked if the line-segment between
174
// l1 and l2 did not intersect any building.
175
return
false
;
176
}
177
178
int64_t
179
BuildingsChannelConditionModel::AssignStreams
(int64_t
/* stream */
)
180
{
181
return
0;
182
}
183
184
}
// end namespace ns3
building-list.h
buildings-channel-condition-model.h
ns3::Building::Wood
@ Wood
Definition
building.h:57
ns3::Building::ConcreteWithWindows
@ ConcreteWithWindows
Definition
building.h:58
ns3::BuildingList::End
static Iterator End()
Definition
building-list.cc:219
ns3::BuildingList::Begin
static Iterator Begin()
Definition
building-list.cc:213
ns3::BuildingsChannelConditionModel
Determines the channel condition based on the buildings deployed in the scenario.
Definition
buildings-channel-condition-model.h:30
ns3::BuildingsChannelConditionModel::AssignStreams
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
Definition
buildings-channel-condition-model.cc:179
ns3::BuildingsChannelConditionModel::GetChannelCondition
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the condition of the channel between a and b.
Definition
buildings-channel-condition-model.cc:45
ns3::BuildingsChannelConditionModel::IsLineOfSightBlocked
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.
Definition
buildings-channel-condition-model.cc:160
ns3::BuildingsChannelConditionModel::BuildingsChannelConditionModel
BuildingsChannelConditionModel()
Constructor for the BuildingsChannelConditionModel class.
Definition
buildings-channel-condition-model.cc:35
ns3::BuildingsChannelConditionModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
buildings-channel-condition-model.cc:26
ns3::BuildingsChannelConditionModel::~BuildingsChannelConditionModel
~BuildingsChannelConditionModel() override
Destructor for the BuildingsChannelConditionModel class.
Definition
buildings-channel-condition-model.cc:40
ns3::ChannelCondition::O2I
@ O2I
Outdoor to Indoor.
Definition
channel-condition-model.h:52
ns3::ChannelCondition::I2I
@ I2I
Indoor to Indoor.
Definition
channel-condition-model.h:53
ns3::ChannelCondition::O2O
@ O2O
Outdoor to Outdoor.
Definition
channel-condition-model.h:51
ns3::ChannelCondition::O2iLowHighConditionValue
O2iLowHighConditionValue
Possible values for Low-High Penetration Loss condition.
Definition
channel-condition-model.h:61
ns3::ChannelCondition::LOW
@ LOW
Low Penetration Losses.
Definition
channel-condition-model.h:62
ns3::ChannelCondition::HIGH
@ HIGH
High Penetration Losses.
Definition
channel-condition-model.h:63
ns3::ChannelCondition::NLOS
@ NLOS
Non Line of Sight.
Definition
channel-condition-model.h:41
ns3::ChannelCondition::LOS
@ LOS
Line of Sight.
Definition
channel-condition-model.h:40
ns3::ChannelConditionModel
Models the channel condition.
Definition
channel-condition-model.h:226
ns3::MobilityBuildingInfo
mobility buildings information (to be used by mobility models)
Definition
mobility-building-info.h:37
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
NS_ASSERT_MSG
#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:75
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
mobility-building-info.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
buildings
model
buildings-channel-condition-model.cc
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0