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 * SPDX-License-Identifier: GPL-2.0-only
8 */
9
11
12#include "building-list.h"
14
15#include "ns3/log.h"
16#include "ns3/mobility-model.h"
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("BuildingsChannelConditionModel");
22
23NS_OBJECT_ENSURE_REGISTERED(BuildingsChannelConditionModel);
24
25TypeId
27{
28 static TypeId tid = TypeId("ns3::BuildingsChannelConditionModel")
30 .SetGroupName("Buildings")
31 .AddConstructor<BuildingsChannelConditionModel>();
32 return tid;
33}
34
39
43
47{
48 NS_LOG_FUNCTION(this);
51 NS_ASSERT_MSG(a1 && b1, "BuildingsChannelConditionModel only works with MobilityBuildingInfo");
52
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() ==
104
105 lowHighLossConditionB1 =
106 b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
107 b1->GetBuilding()->GetExtWallsType() ==
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
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() ==
141
142 cond->SetO2iLowHighCondition(lowHighLossCondition);
143 }
144 else
145 {
146 lowHighLossCondition =
147 b1->GetBuilding()->GetExtWallsType() == Building::ExtWallsType_t::Wood ||
148 b1->GetBuilding()->GetExtWallsType() ==
152 cond->SetO2iLowHighCondition(lowHighLossCondition);
153 }
154 }
155
156 return cond;
157}
158
159bool
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
178int64_t
180{
181 return 0;
182}
183
184} // end namespace ns3
@ ConcreteWithWindows
Definition building.h:58
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.
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.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.