A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
7 * Nicola Baldo <nbaldo@cttc.es>
8 *
9 */
10
12
14
15#include "ns3/double.h"
16#include "ns3/enum.h"
17#include "ns3/log.h"
18#include "ns3/mobility-model.h"
19#include "ns3/pointer.h"
20#include "ns3/propagation-loss-model.h"
21
22#include <cmath>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("BuildingsPropagationLossModel");
28
29NS_OBJECT_ENSURE_REGISTERED(BuildingsPropagationLossModel);
30
34
36 Ptr<MobilityModel> receiver)
37 : m_shadowingValue(shadowingValue),
38 m_receiver(receiver)
39{
40 NS_LOG_INFO(this << " New Shadowing value " << m_shadowingValue);
41}
42
43double
45{
46 return m_shadowingValue;
47}
48
54
57{
58 static TypeId tid =
59 TypeId("ns3::BuildingsPropagationLossModel")
60
62 .SetGroupName("Buildings")
63
64 .AddAttribute(
65 "ShadowSigmaOutdoor",
66 "Standard deviation of the normal distribution used to calculate the shadowing for "
67 "outdoor nodes",
68 DoubleValue(7.0),
71
72 .AddAttribute(
73 "ShadowSigmaIndoor",
74 "Standard deviation of the normal distribution used to calculate the shadowing for "
75 "indoor nodes",
76 DoubleValue(8.0),
79 .AddAttribute(
80 "ShadowSigmaExtWalls",
81 "Standard deviation of the normal distribution used to calculate the shadowing due "
82 "to ext walls",
83 DoubleValue(5.0),
86
87 .AddAttribute("InternalWallLoss",
88 "Additional loss for each internal wall [dB]",
89 DoubleValue(5.0),
92
93 return tid;
94}
95
100
101double
103{
104 double loss = 0.0;
105 Ptr<Building> aBuilding = a->GetBuilding();
106 if (aBuilding->GetExtWallsType() == Building::Wood)
107 {
108 loss = 4;
109 }
110 else if (aBuilding->GetExtWallsType() == Building::ConcreteWithWindows)
111 {
112 loss = 7;
113 }
114 else if (aBuilding->GetExtWallsType() == Building::ConcreteWithoutWindows)
115 {
116 loss = 15; // 10 ~ 20 dB
117 }
118 else if (aBuilding->GetExtWallsType() == Building::StoneBlocks)
119 {
120 loss = 12;
121 }
122 return loss;
123}
124
125double
127{
128 double loss = 0.0;
129
130 int nfloors = node->GetFloorNumber() - 1;
131 loss = -2 * (nfloors);
132 return loss;
133}
134
135double
138{
139 // approximate the number of internal walls with the Manhattan distance in "rooms" units
140 double dx = std::abs(a->GetRoomNumberX() - b->GetRoomNumberX());
141 double dy = std::abs(a->GetRoomNumberY() - b->GetRoomNumberY());
142 return m_lossInternalWall * (dx + dy);
143}
144
145double
147{
150 NS_ASSERT_MSG(a1 && b1, "BuildingsPropagationLossModel only works with MobilityBuildingInfo");
151
152 auto ait = m_shadowingLossMap.find(a);
153 if (ait != m_shadowingLossMap.end())
154 {
155 auto bit = ait->second.find(b);
156 if (bit != ait->second.end())
157 {
158 return bit->second.GetLoss();
159 }
160 else
161 {
162 double sigma = EvaluateSigma(a1, b1);
163 // side effect: will create new entry
164 // sigma is standard deviation, not variance
165 double shadowingValue = m_randVariable->GetValue(0.0, (sigma * sigma));
166 ait->second[b] = ShadowingLoss(shadowingValue, b);
167 return ait->second[b].GetLoss();
168 }
169 }
170 else
171 {
172 double sigma = EvaluateSigma(a1, b1);
173 // side effect: will create new entries in both maps
174 // sigma is standard deviation, not variance
175 double shadowingValue = m_randVariable->GetValue(0.0, (sigma * sigma));
176 m_shadowingLossMap[a][b] = ShadowingLoss(shadowingValue, b);
177 return m_shadowingLossMap[a][b].GetLoss();
178 }
179}
180
181double
184{
185 bool isAIndoor = a->IsIndoor();
186 bool isBIndoor = b->IsIndoor();
187
188 if (!isAIndoor) // a is outdoor
189 {
190 if (!isBIndoor) // b is outdoor
191 {
193 }
194 else
195 {
196 double sigma = std::sqrt((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) +
198 return sigma;
199 }
200 }
201 else if (isBIndoor) // b is indoor
202 {
204 }
205 else
206 {
207 double sigma = std::sqrt((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) +
209 return sigma;
210 }
211}
212
213double
216 Ptr<MobilityModel> b) const
217{
218 return txPowerDbm - GetLoss(a, b) - GetShadowing(a, b);
219}
220
221int64_t
223{
224 m_randVariable->SetStream(stream);
225 return 1;
226}
227
228} // namespace ns3
@ ConcreteWithWindows
Definition building.h:58
@ ConcreteWithoutWindows
Definition building.h:59
This model allows the computation of shadowing loss.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
std::map< Ptr< MobilityModel >, std::map< Ptr< MobilityModel >, ShadowingLoss > > m_shadowingLossMap
Map of the shadowng loss.
double GetShadowing(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Calculate the shadowing loss.
double HeightLoss(Ptr< MobilityBuildingInfo > n) const
Calculate the height loss.
double m_shadowingSigmaOutdoor
Standard deviation of the normal distribution used to calculate the shadowing for outdoor nodes.
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
double m_shadowingSigmaExtWalls
Standard deviation of the normal distribution used to calculate the shadowing due to ext walls.
double m_shadowingSigmaIndoor
Standard deviation of the normal distribution used to calculate the shadowing for indoor nodes.
double ExternalWallLoss(Ptr< MobilityBuildingInfo > a) const
Calculate the external wall loss.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double m_lossInternalWall
loss from internal walls (in dBm)
double EvaluateSigma(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Calculate the Standard deviation of the normal distribution used to calculate the shadowing.
Ptr< NormalRandomVariable > m_randVariable
Random variable.
double InternalWallsLoss(Ptr< MobilityBuildingInfo > a, Ptr< MobilityBuildingInfo > b) const
Calculate the internal wall loss.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
mobility buildings information (to be used by mobility models)
Models the propagation loss through a transmission medium.
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_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
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.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32