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 * 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
15namespace ns3
16{
17class MobilityModel;
18
19namespace lorawan
20{
21
22/**
23 * \ingroup lorawan
24 *
25 * Propagation loss model for spatially correlated shadowing in a city
26 */
28{
29 public:
30 /**
31 * Stores x,y values and overrides critical operators.
32 */
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 */
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 */
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 */
120
121 /**
122 * The normal random variable that is used to obtain shadowing values.
123 */
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,
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
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
a unique identifier for an interface.
Definition type-id.h:48
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.