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
* SPDX-License-Identifier: GPL-2.0-only
3
*
4
* Author: Davide Magrin <magrinda@dei.unipd.it>
5
*/
6
7
#ifndef CORRELATED_SHADOWING_PROPAGATION_LOSS_MODEL_H
8
#define CORRELATED_SHADOWING_PROPAGATION_LOSS_MODEL_H
9
10
#include "ns3/propagation-loss-model.h"
11
12
namespace
ns3
13
{
14
namespace
lorawan
15
{
16
17
/**
18
* @ingroup lorawan
19
*
20
* Propagation loss model for spatially correlated shadowing in a city
21
*/
22
class
CorrelatedShadowingPropagationLossModel
:
public
PropagationLossModel
23
{
24
public
:
25
/**
26
* Stores x,y values and overrides critical operators.
27
*/
28
class
Position
29
{
30
public
:
31
Position
();
//!< Default constructor
32
33
/**
34
* Construct a new Position object with values.
35
*
36
* @param x The x coordinate.
37
* @param y The y coordinate.
38
*/
39
Position
(
double
x
,
double
y
);
40
41
double
x
;
//!< Stores the x coordinate.
42
double
y
;
//!< Stores the y coordinate.
43
44
/**
45
* Equality comparison operator
46
*
47
* @param other Second Position to compare this instance to.
48
* @return True if the positions are equal.
49
*/
50
bool
operator==
(
const
Position
& other)
const
;
51
/**
52
* Less-then comparison operator
53
*
54
* @param other Second Position to compare this instance to.
55
* @return True if either the x or y coordinate of first Position is less than the
56
* respective one of the second Position
57
*/
58
bool
operator<
(
const
Position
& other)
const
;
59
};
60
61
/**
62
* @ingroup lorawan
63
*
64
* This initializes the shadowing map with a grid of independent
65
* shadowing values, one m_correlationDistance meters apart from the next
66
* one. The result is something like:
67
*
68
* o---o---o---o---o
69
* | | | | |
70
* o---o---o---o---o
71
* | | | | |
72
* o---o---o---o---o
73
* | | | | |
74
* o---o---o---o---o
75
*
76
* where at each o we have an independently generated shadowing value.
77
* We can then interpolate the 4 values surrounding any point in space
78
* in order to get a correlated shadowing value. After generating this
79
* value, we will add it to the map so that we don't have to compute it
80
* twice. Also, since interpolation is a deterministic operation, we are
81
* guaranteed that, as long as the grid doesn't change, also two values
82
* generated in the same square will be correlated.
83
*/
84
class
ShadowingMap
85
:
public
SimpleRefCount
<CorrelatedShadowingPropagationLossModel::ShadowingMap>
86
{
87
public
:
88
ShadowingMap
();
//!< Default constructor
89
~ShadowingMap
();
//!< Destructor
90
91
/**
92
* Get the loss for a certain position.
93
*
94
* If the position is not already in the map, add it by computing the
95
* interpolation of neighboring shadowing values belonging to the grid.
96
*
97
* @param position The Position instance.
98
* @return The loss as a double.
99
*/
100
double
GetLoss
(
CorrelatedShadowingPropagationLossModel::Position
position);
101
102
private
:
103
/**
104
* For each Position, this map gives a corresponding loss.
105
* The map contains a basic grid that is initialized at construction
106
* time, and then newly computed values are added as they are created.
107
*/
108
std::map<CorrelatedShadowingPropagationLossModel::Position, double>
m_shadowingMap
;
109
110
/**
111
* The distance after which two samples are to be considered almost
112
* uncorrelated
113
*/
114
double
m_correlationDistance
;
115
116
/**
117
* The normal random variable that is used to obtain shadowing values.
118
*/
119
Ptr<NormalRandomVariable>
m_shadowingValue
;
120
121
/**
122
* The inverted K matrix.
123
* This matrix is used to compute the coefficients to be used when
124
* interpolating the vertices of a grid square.
125
*/
126
static
const
double
m_kInv
[4][4];
127
};
128
129
/**
130
* Register this type.
131
* @return The object TypeId.
132
*/
133
static
TypeId
GetTypeId
();
134
135
CorrelatedShadowingPropagationLossModel
();
//!< Default constructor
136
137
private
:
138
double
DoCalcRxPower
(
double
txPowerDbm,
139
Ptr<MobilityModel>
a,
140
Ptr<MobilityModel>
b)
const override
;
141
142
int64_t
DoAssignStreams
(int64_t stream)
override
;
143
144
double
m_correlationDistance
;
//!< The correlation distance for the ShadowingMap
145
146
/**
147
* Map linking a square to a ShadowingMap.
148
* Each square of the shadowing grid has a corresponding ShadowingMap, and a
149
* square is identified by a pair of coordinates. Coordinates are computed as
150
* such:
151
*
152
* o---------o---------o---------o---------o---------o
153
* | | | ' | | |
154
* | (-2,2) | (-1,2) | (0,2) | (1,2) | (2,2) |
155
* | | | ' | | |
156
* o---------o---------o----+----o---------o---------o
157
* | | | ' | | |
158
* | (-2,1) | (-1,1) | (0,1) | (1,1) | (2,1) |
159
* | | | ' | | |
160
* o---------o---------o----+----o---------o---------o
161
* | | | ' | | |
162
* |--(-2,0)-+--(-1,0)-+--(0,0)--+--(1,0)--+--(2,0)--|
163
* | | | ' | | |
164
* o---------o---------o----+----o---------o---------o
165
* | | | ' | | |
166
* | (-2,-1) | (-1,-1) | (0,-1) | (1,-1) | (2,-1) |
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
* For each one of these coordinates, a ShadowingMap is computed. That is,
175
* each one of the points belonging to the same square sees the same
176
* shadowing for the points around it. This is one level of correlation for
177
* the shadowing, i.e. close nodes transmitting to the same point will see
178
* the same shadowing since they are using the same shadowing map.
179
* Further, the ShadowingMap will be "smooth": when transmitting from point
180
* a to points b and c, the shadowing experienced by b and c will be similar
181
* if they are close (ideally, within a correlation distance).
182
*/
183
mutable
std::map<std::pair<int, int>,
Ptr<ShadowingMap>
>
m_shadowingGrid
;
184
};
185
186
}
// namespace lorawan
187
}
// namespace ns3
188
189
#endif
/* CORRELATED_SHADOWING_PROPAGATION_LOSS_MODEL_H */
ns3::PropagationLossModel::PropagationLossModel
PropagationLossModel()
Definition
propagation-loss-model.cc:41
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::SimpleRefCount< CorrelatedShadowingPropagationLossModel::ShadowingMap >::SimpleRefCount
SimpleRefCount()
Definition
simple-ref-count.h:79
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position
Stores x,y values and overrides critical operators.
Definition
correlated-shadowing-propagation-loss-model.h:29
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::Position
Position()
Default constructor.
Definition
correlated-shadowing-propagation-loss-model.cc:251
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::operator==
bool operator==(const Position &other) const
Equality comparison operator.
Definition
correlated-shadowing-propagation-loss-model.cc:266
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::x
double x
Stores the x coordinate.
Definition
correlated-shadowing-propagation-loss-model.h:41
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::y
double y
Stores the y coordinate.
Definition
correlated-shadowing-propagation-loss-model.h:42
ns3::lorawan::CorrelatedShadowingPropagationLossModel::Position::operator<
bool operator<(const Position &other) const
Less-then comparison operator.
Definition
correlated-shadowing-propagation-loss-model.cc:278
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:114
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::ShadowingMap
ShadowingMap()
Default constructor.
Definition
correlated-shadowing-propagation-loss-model.cc:126
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::~ShadowingMap
~ShadowingMap()
Destructor.
Definition
correlated-shadowing-propagation-loss-model.cc:138
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::GetLoss
double GetLoss(CorrelatedShadowingPropagationLossModel::Position position)
Get the loss for a certain position.
Definition
correlated-shadowing-propagation-loss-model.cc:144
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:119
ns3::lorawan::CorrelatedShadowingPropagationLossModel::ShadowingMap::m_kInv
static const double m_kInv[4][4]
The inverted K matrix.
Definition
correlated-shadowing-propagation-loss-model.h:126
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:108
ns3::lorawan::CorrelatedShadowingPropagationLossModel::m_correlationDistance
double m_correlationDistance
The correlation distance for the ShadowingMap.
Definition
correlated-shadowing-propagation-loss-model.h:144
ns3::lorawan::CorrelatedShadowingPropagationLossModel::CorrelatedShadowingPropagationLossModel
CorrelatedShadowingPropagationLossModel()
Default constructor.
Definition
correlated-shadowing-propagation-loss-model.cc:39
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:183
ns3::lorawan::CorrelatedShadowingPropagationLossModel::DoCalcRxPower
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Definition
correlated-shadowing-propagation-loss-model.cc:44
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:110
ns3::lorawan::CorrelatedShadowingPropagationLossModel::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
correlated-shadowing-propagation-loss-model.cc:22
ns3::lorawan
Definition
forwarder-helper.cc:19
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
for ns-3 by
1.15.0