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