A Discrete-Event Network Simulator
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
26namespace ns3
27{
28class MobilityModel;
29
30namespace lorawan
31{
32
33/**
34 * \ingroup lorawan
35 *
36 * Propagation loss model for spatially correlated shadowing in a city
37 */
39{
40 public:
41 /**
42 * Stores x,y values and overrides critical operators.
43 */
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 */
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 */
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 */
131
132 /**
133 * The normal random variable that is used to obtain shadowing values.
134 */
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,
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
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:59
bool operator==(const Position &other) const
Equality comparison operator.
bool operator<(const Position &other) const
Less-then comparison operator.
This initializes the shadowing map with a grid of independent shadowing values, one m_correlationDist...
double m_correlationDistance
The distance after which two samples are to be considered almost uncorrelated.
double GetLoss(CorrelatedShadowingPropagationLossModel::Position position)
Get the loss for a certain position.
Ptr< NormalRandomVariable > m_shadowingValue
The normal random variable that is used to obtain shadowing values.
std::map< CorrelatedShadowingPropagationLossModel::Position, double > m_shadowingMap
For each Position, this map gives a corresponding loss.
Propagation loss model for spatially correlated shadowing in a city.
double m_correlationDistance
The correlation distance for the ShadowingMap.
std::map< std::pair< int, int >, Ptr< ShadowingMap > > m_shadowingGrid
Map linking a square to a ShadowingMap.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Every class exported by the ns3 library is enclosed in the ns3 namespace.