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
correlated-shadowing-propagation-loss-model.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Author: Davide Magrin <magrinda@dei.unipd.it>
16
*/
17
18
#ifndef CORRELATED_SHADOWING_PROPAGATION_LOSS_MODEL_H
19
#define CORRELATED_SHADOWING_PROPAGATION_LOSS_MODEL_H
20
21
#include "ns3/mobility-model.h"
22
#include "ns3/propagation-loss-model.h"
23
#include "ns3/random-variable-stream.h"
24
#include "ns3/vector.h"
25
26
namespace
ns3
27
{
28
class
MobilityModel;
29
30
namespace
lorawan
31
{
32
33
/**
34
* \ingroup lorawan
35
*
36
* Propagation loss model for spatially correlated shadowing in a city
37
*/
38
class
CorrelatedShadowingPropagationLossModel
:
public
PropagationLossModel
39
{
40
public
:
41
/**
42
* Stores x,y values and overrides critical operators.
43
*/
44
class
Position
45
{
46
public
:
47
Position
();
//!< Default constructor
48
49
/**
50
* Construct a new Position object with values.
51
*
52
* \param x The x coordinate.
53
* \param y The y coordinate.
54
*/
55
Position
(
double
x
,
double
y
);
56
57
double
x
;
//!< Stores the x coordinate.
58
double
y
;
//!< Stores the y coordinate.
59
60
/**
61
* Equality comparison operator
62
*
63
* \param other Second Position to compare this instance to.
64
* \return True if the positions are equal.
65
*/
66
bool
operator==
(
const
Position
& other)
const
;
67
/**
68
* Less-then comparison operator
69
*
70
* \param other Second Position to compare this instance to.
71
* \return True if either the x or y coordinate of first Position is less than the
72
* respective one of the second Position
73
*/
74
bool
operator<
(
const
Position
& other)
const
;
75
};
76
77
/**
78
* \ingroup lorawan
79
*
80
* This initializes the shadowing map with a grid of independent
81
* shadowing values, one m_correlationDistance meters apart from the next
82
* one. The result is something like:
83
*
84
* o---o---o---o---o
85
* | | | | |
86
* o---o---o---o---o
87
* | | | | |
88
* o---o---o---o---o
89
* | | | | |
90
* o---o---o---o---o
91
*
92
* where at each o we have an independently generated shadowing value.
93
* We can then interpolate the 4 values surrounding any point in space
94
* in order to get a correlated shadowing value. After generating this
95
* value, we will add it to the map so that we don't have to compute it
96
* twice. Also, since interpolation is a deterministic operation, we are
97
* guaranteed that, as long as the grid doesn't change, also two values
98
* generated in the same square will be correlated.
99
*/
100
class
ShadowingMap
101
:
public
SimpleRefCount
<CorrelatedShadowingPropagationLossModel::ShadowingMap>
102
{
103
public
:
104
ShadowingMap
();
//!< Default constructor
105
~ShadowingMap
();
//!< Destructor
106
107
/**
108
* Get the loss for a certain position.
109
*
110
* If the position is not already in the map, add it by computing the
111
* interpolation of neighboring shadowing values belonging to the grid.
112
*
113
* \param position The Position instance.
114
* \return The loss as a double.
115
*/
116
double
GetLoss
(
CorrelatedShadowingPropagationLossModel::Position
position);
117
118
private
:
119
/**
120
* For each Position, this map gives a corresponding loss.
121
* The map contains a basic grid that is initialized at construction
122
* time, and then newly computed values are added as they are created.
123
*/
124
std::map<CorrelatedShadowingPropagationLossModel::Position, double>
m_shadowingMap
;
125
126
/**
127
* The distance after which two samples are to be considered almost
128
* uncorrelated
129
*/
130
double
m_correlationDistance
;
131
132
/**
133
* The normal random variable that is used to obtain shadowing values.
134
*/
135
Ptr<NormalRandomVariable>
m_shadowingValue
;
136
137
/**
138
* The inverted K matrix.
139
* This matrix is used to compute the coefficients to be used when
140
* interpolating the vertices of a grid square.
141
*/
142
static
const
double
m_kInv
[4][4];
143
};
144
145
/**
146
* Register this type.
147
* \return The object TypeId.
148
*/
149
static
TypeId
GetTypeId
();
150
151
CorrelatedShadowingPropagationLossModel
();
//!< Default constructor
152
153
private
:
154
double
DoCalcRxPower
(
double
txPowerDbm,
155
Ptr<MobilityModel>
a,
156
Ptr<MobilityModel>
b)
const override
;
157
158
int64_t
DoAssignStreams
(int64_t stream)
override
;
159
160
double
m_correlationDistance
;
//!< The correlation distance for the ShadowingMap
161
162
/**
163
* Map linking a square to a ShadowingMap.
164
* Each square of the shadowing grid has a corresponding ShadowingMap, and a
165
* square is identified by a pair of coordinates. Coordinates are computed as
166
* such:
167
*
168
* o---------o---------o---------o---------o---------o
169
* | | | ' | | |
170
* | (-2,2) | (-1,2) | (0,2) | (1,2) | (2,2) |
171
* | | | ' | | |
172
* o---------o---------o----+----o---------o---------o
173
* | | | ' | | |
174
* | (-2,1) | (-1,1) | (0,1) | (1,1) | (2,1) |
175
* | | | ' | | |
176
* o---------o---------o----+----o---------o---------o
177
* | | | ' | | |
178
* |--(-2,0)-+--(-1,0)-+--(0,0)--+--(1,0)--+--(2,0)--|
179
* | | | ' | | |
180
* o---------o---------o----+----o---------o---------o
181
* | | | ' | | |
182
* | (-2,-1) | (-1,-1) | (0,-1) | (1,-1) | (2,-1) |
183
* | | | ' | | |
184
* o---------o---------o----+----o---------o---------o
185
* | | | ' | | |
186
* | (-2,-2) | (-1,-2) | (0,-2) | (1,-2) | (2,-2) |
187
* | | | ' | | |
188
* o---------o---------o---------o---------o---------o
189
*
190
* For each one of these coordinates, a ShadowingMap is computed. That is,
191
* each one of the points belonging to the same square sees the same
192
* shadowing for the points around it. This is one level of correlation for
193
* the shadowing, i.e. close nodes transmitting to the same point will see
194
* the same shadowing since they are using the same shadowing map.
195
* Further, the ShadowingMap will be "smooth": when transmitting from point
196
* a to points b and c, the shadowing experienced by b and c will be similar
197
* if they are close (ideally, within a correlation distance).
198
*/
199
mutable
std::map<std::pair<int, int>,
Ptr<ShadowingMap>
>
m_shadowingGrid
;
200
};
201
202
}
// namespace lorawan
203
204
}
// namespace ns3
205
#endif
ns3::PropagationLossModel
Models the propagation loss through a transmission medium.
Definition:
propagation-loss-model.h:56
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::SimpleRefCount
A template-based reference counting class.
Definition:
simple-ref-count.h:81
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position
Stores x,y values and overrides critical operators.
Definition:
correlated-shadowing-propagation-loss-model.h:45
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::Position
Position()
Default constructor.
Definition:
correlated-shadowing-propagation-loss-model.cc:264
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::operator==
bool operator==(const Position &other) const
Equality comparison operator.
Definition:
correlated-shadowing-propagation-loss-model.cc:279
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::x
double x
Stores the x coordinate.
Definition:
correlated-shadowing-propagation-loss-model.h:57
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::y
double y
Stores the y coordinate.
Definition:
correlated-shadowing-propagation-loss-model.h:58
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::operator<
bool operator<(const Position &other) const
Less-then comparison operator.
Definition:
correlated-shadowing-propagation-loss-model.cc:291
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap
This initializes the shadowing map with a grid of independent shadowing values, one m_correlationDist...
Definition:
correlated-shadowing-propagation-loss-model.h:102
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::m_correlationDistance
double m_correlationDistance
The distance after which two samples are to be considered almost uncorrelated.
Definition:
correlated-shadowing-propagation-loss-model.h:130
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::ShadowingMap
ShadowingMap()
Default constructor.
Definition:
correlated-shadowing-propagation-loss-model.cc:139
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::~ShadowingMap
~ShadowingMap()
Destructor.
Definition:
correlated-shadowing-propagation-loss-model.cc:151
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::GetLoss
double GetLoss(CorrelatedShadowingPropagationLossModel::Position position)
Get the loss for a certain position.
Definition:
correlated-shadowing-propagation-loss-model.cc:157
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::m_shadowingValue
Ptr< NormalRandomVariable > m_shadowingValue
The normal random variable that is used to obtain shadowing values.
Definition:
correlated-shadowing-propagation-loss-model.h:135
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::m_kInv
static const double m_kInv[4][4]
The inverted K matrix.
Definition:
correlated-shadowing-propagation-loss-model.h:142
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::m_shadowingMap
std::map< CorrelatedShadowingPropagationLossModel::Position, double > m_shadowingMap
For each Position, this map gives a corresponding loss.
Definition:
correlated-shadowing-propagation-loss-model.h:124
ns3::lorawan::CorrelatedShadowingPropagationLossModel
Propagation loss model for spatially correlated shadowing in a city.
Definition:
correlated-shadowing-propagation-loss-model.h:39
ns3::lorawan::CorrelatedShadowingPropagationLossModel::m_correlationDistance
double m_correlationDistance
The correlation distance for the ShadowingMap.
Definition:
correlated-shadowing-propagation-loss-model.h:160
ns3::lorawan::CorrelatedShadowingPropagationLossModel::CorrelatedShadowingPropagationLossModel
CorrelatedShadowingPropagationLossModel()
Default constructor.
Definition:
correlated-shadowing-propagation-loss-model.cc:52
ns3::lorawan::CorrelatedShadowingPropagationLossModel::m_shadowingGrid
std::map< std::pair< int, int >, Ptr< ShadowingMap > > m_shadowingGrid
Map linking a square to a ShadowingMap.
Definition:
correlated-shadowing-propagation-loss-model.h:199
ns3::lorawan::CorrelatedShadowingPropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition:
correlated-shadowing-propagation-loss-model.cc:57
ns3::lorawan::CorrelatedShadowingPropagationLossModel::DoAssignStreams
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition:
correlated-shadowing-propagation-loss-model.cc:123
ns3::lorawan::CorrelatedShadowingPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
correlated-shadowing-propagation-loss-model.cc:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lorawan
model
correlated-shadowing-propagation-loss-model.h
Generated on Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6