A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
matrix-based-channel-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
4 * Copyright (c) 2020 Institute for the Wireless Internet of Things,
5 * Northeastern University
6 *
7 * SPDX-License-Identifier: GPL-2.0-only
8 */
9
10#ifndef MATRIX_BASED_CHANNEL_H
11#define MATRIX_BASED_CHANNEL_H
12
13// #include <complex>
14#include <ns3/matrix-array.h>
15#include <ns3/nstime.h>
16#include <ns3/object.h>
17#include <ns3/phased-array-model.h>
18#include <ns3/vector.h>
19
20#include <tuple>
21
22namespace ns3
23{
24
25class MobilityModel;
26
27/**
28 * \ingroup spectrum
29 *
30 * This is an interface for a channel model that can be described
31 * by a channel matrix, e.g., the 3GPP Spatial Channel Models,
32 * which is generally used in combination with antenna arrays
33 */
35{
36 public:
37 /**
38 * Destructor for MatrixBasedChannelModel
39 */
40 ~MatrixBasedChannelModel() override;
41
42 /// Type definition for vectors of doubles
43 using DoubleVector = std::vector<double>;
44
45 /// Type definition for matrices of doubles
46 using Double2DVector = std::vector<DoubleVector>;
47
48 /// Type definition for 3D matrices of doubles
49 using Double3DVector = std::vector<Double2DVector>;
50
51 using Complex2DVector = ComplexMatrixArray; //!< Create an alias for 2D complex vectors
52 using Complex3DVector = ComplexMatrixArray; //!< Create an alias for 3D complex vectors
53
54 /**
55 * Data structure that stores a channel realization
56 */
57 struct ChannelMatrix : public SimpleRefCount<ChannelMatrix>
58 {
59 /**
60 * Channel matrix H[u][s][n].
61 */
63
64 /**
65 * Generation time.
66 */
68
69 /**
70 * The first element is the ID of the antenna of the s-node (the
71 * antenna of the transmitter when the channel was generated), the
72 * second element is ID of the antenna of the u-node antenna (the
73 * antenna of the receiver when the channel was generated).
74 */
75 std::pair<uint32_t, uint32_t> m_antennaPair;
76
77 /**
78 * The first element is the s-node ID (the transmitter when the channel was
79 * generated), the second element is the u-node ID (the receiver when the
80 * channel was generated).
81 */
82 std::pair<uint32_t, uint32_t> m_nodeIds;
83
84 /**
85 * Returns true if the ChannelMatrix object was generated
86 * considering node b as transmitter and node a as receiver.
87 * \param aAntennaId the ID of the antenna array of the a node
88 * \param bAntennaId the ID of the antenna array of the b node
89 * \return true if b is the rx and a is the tx, false otherwise
90 */
91 bool IsReverse(uint32_t aAntennaId, uint32_t bAntennaId) const
92 {
93 uint32_t sAntennaId;
94 uint32_t uAntennaId;
95 std::tie(sAntennaId, uAntennaId) = m_antennaPair;
96 NS_ASSERT_MSG((sAntennaId == aAntennaId && uAntennaId == bAntennaId) ||
97 (sAntennaId == bAntennaId && uAntennaId == aAntennaId),
98 "This channel matrix does not represent the channel among the antenna "
99 "arrays for which are provided IDs.");
100 return (sAntennaId == bAntennaId && uAntennaId == aAntennaId);
101 }
102 };
103
104 /**
105 * Data structure that stores channel parameters
106 */
107 struct ChannelParams : public SimpleRefCount<ChannelParams>
108 {
109 /**
110 * Generation time.
111 */
113
114 /**
115 * Cluster delay in nanoseconds.
116 */
118
119 /**
120 * Cluster angle angle[direction][n], where direction = 0(AOA), 1(ZOA), 2(AOD), 3(ZOD)
121 * in degree.
122 */
124
125 /**
126 * Sin/cos of cluster angle angle[direction][n], where direction = 0(AOA), 1(ZOA), 2(AOD),
127 * 3(ZOD) in degree.
128 */
129 std::vector<std::vector<std::pair<double, double>>> m_cachedAngleSincos;
130
131 /**
132 * Alpha term per cluster as described in 3GPP TR 37.885 v15.3.0, Sec. 6.2.3
133 * for calculating doppler.
134 */
136
137 /**
138 * D term per cluster as described in 3GPP TR 37.885 v15.3.0, Sec. 6.2.3
139 * for calculating doppler.
140 */
142
143 /**
144 * The first element is the s-node ID (the transmitter when the channel params were
145 * generated), the second element is the u-node ID (the receiver when the channel params
146 * were generated generated).
147 */
148 std::pair<uint32_t, uint32_t> m_nodeIds;
149
150 /**
151 * Auxiliary variable to m_cachedDelaySincos
152 *
153 * It is used to determine RB width (12*SCS) changes due to numerology,
154 * in case the number of the RBs in the channel remains constant.
155 */
156 mutable double m_cachedRbWidth = 0.0;
157
158 /**
159 * Matrix array that holds the precomputed delay sincos
160 */
162
163 /**
164 * Destructor for ChannelParams
165 */
166 virtual ~ChannelParams() = default;
167 };
168
169 /**
170 * Returns a matrix with a realization of the channel between
171 * the nodes with mobility objects passed as input parameters.
172 *
173 * We assume channel reciprocity between each node pair (i.e., H_ab = H_ba^T),
174 * therefore GetChannel (a, b) and GetChannel (b, a) will return the same
175 * ChannelMatrix object.
176 * To understand if the channel matrix corresponds to H_ab or H_ba, we provide
177 * the method ChannelMatrix::IsReverse. For instance, if the channel
178 * matrix corresponds to H_ab, a call to IsReverse (idA, idB) will return
179 * false, conversely, IsReverse (idB, idA) will return true.
180 *
181 * \param aMob mobility model of the a device
182 * \param bMob mobility model of the b device
183 * \param aAntenna antenna of the a device
184 * \param bAntenna antenna of the b device
185 * \return the channel matrix
186 */
190 Ptr<const PhasedArrayModel> bAntenna) = 0;
191
192 /**
193 * Returns a channel parameters structure used to obtain the channel between
194 * the nodes with mobility objects passed as input parameters.
195 *
196 * \param aMob mobility model of the a device
197 * \param bMob mobility model of the b device
198 * \return the channel matrix
199 */
201 Ptr<const MobilityModel> bMob) const = 0;
202
203 /**
204 * Generate a unique value for the pair of unsigned integer of 32 bits,
205 * where the order does not matter, i.e., the same value will be returned for (a,b) and (b,a).
206 * \param a the first value
207 * \param b the second value
208 * \return return an integer representing a unique value for the pair of values
209 */
210 static uint64_t GetKey(uint32_t a, uint32_t b)
211 {
212 return (uint64_t)std::min(a, b) << 32 | std::max(a, b);
213 }
214
215 static const uint8_t AOA_INDEX = 0; //!< index of the AOA value in the m_angle array
216 static const uint8_t ZOA_INDEX = 1; //!< index of the ZOA value in the m_angle array
217 static const uint8_t AOD_INDEX = 2; //!< index of the AOD value in the m_angle array
218 static const uint8_t ZOD_INDEX = 3; //!< index of the ZOD value in the m_angle array
219};
220
221}; // namespace ns3
222
223#endif // MATRIX_BASED_CHANNEL_H
This is an interface for a channel model that can be described by a channel matrix,...
std::vector< double > DoubleVector
Type definition for vectors of doubles.
static const uint8_t AOA_INDEX
index of the AOA value in the m_angle array
static const uint8_t ZOD_INDEX
index of the ZOD value in the m_angle array
static const uint8_t AOD_INDEX
index of the AOD value in the m_angle array
virtual Ptr< const ChannelParams > GetParams(Ptr< const MobilityModel > aMob, Ptr< const MobilityModel > bMob) const =0
Returns a channel parameters structure used to obtain the channel between the nodes with mobility obj...
~MatrixBasedChannelModel() override
Destructor for MatrixBasedChannelModel.
static const uint8_t ZOA_INDEX
index of the ZOA value in the m_angle array
std::vector< Double2DVector > Double3DVector
Type definition for 3D matrices of doubles.
std::vector< DoubleVector > Double2DVector
Type definition for matrices of doubles.
static uint64_t GetKey(uint32_t a, uint32_t b)
Generate a unique value for the pair of unsigned integer of 32 bits, where the order does not matter,...
virtual Ptr< const ChannelMatrix > GetChannel(Ptr< const MobilityModel > aMob, Ptr< const MobilityModel > bMob, Ptr< const PhasedArrayModel > aAntenna, Ptr< const PhasedArrayModel > bAntenna)=0
Returns a matrix with a realization of the channel between the nodes with mobility objects passed as ...
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
MatrixArray< std::complex< double > > ComplexMatrixArray
Create an alias for MatrixArray using complex type.
Data structure that stores a channel realization.
Complex3DVector m_channel
Channel matrix H[u][s][n].
bool IsReverse(uint32_t aAntennaId, uint32_t bAntennaId) const
Returns true if the ChannelMatrix object was generated considering node b as transmitter and node a a...
std::pair< uint32_t, uint32_t > m_antennaPair
The first element is the ID of the antenna of the s-node (the antenna of the transmitter when the cha...
std::pair< uint32_t, uint32_t > m_nodeIds
The first element is the s-node ID (the transmitter when the channel was generated),...
Data structure that stores channel parameters.
DoubleVector m_delay
Cluster delay in nanoseconds.
Double2DVector m_angle
Cluster angle angle[direction][n], where direction = 0(AOA), 1(ZOA), 2(AOD), 3(ZOD) in degree.
ComplexMatrixArray m_cachedDelaySincos
Matrix array that holds the precomputed delay sincos.
virtual ~ChannelParams()=default
Destructor for ChannelParams.
double m_cachedRbWidth
Auxiliary variable to m_cachedDelaySincos.
DoubleVector m_alpha
Alpha term per cluster as described in 3GPP TR 37.885 v15.3.0, Sec.
std::vector< std::vector< std::pair< double, double > > > m_cachedAngleSincos
Sin/cos of cluster angle angle[direction][n], where direction = 0(AOA), 1(ZOA), 2(AOD),...
DoubleVector m_D
D term per cluster as described in 3GPP TR 37.885 v15.3.0, Sec.
std::pair< uint32_t, uint32_t > m_nodeIds
The first element is the s-node ID (the transmitter when the channel params were generated),...