A Discrete-Event Network Simulator
API
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  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation;
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef MATRIX_BASED_CHANNEL_H
22 #define MATRIX_BASED_CHANNEL_H
23 
24 // #include <complex>
25 #include <ns3/matrix-array.h>
26 #include <ns3/nstime.h>
27 #include <ns3/object.h>
28 #include <ns3/phased-array-model.h>
29 #include <ns3/vector.h>
30 
31 #include <tuple>
32 
33 namespace ns3
34 {
35 
36 class MobilityModel;
37 
46 {
47  public:
51  ~MatrixBasedChannelModel() override;
52 
54  using DoubleVector = std::vector<double>;
55 
57  using Double2DVector = std::vector<DoubleVector>;
58 
60  using Double3DVector = std::vector<Double2DVector>;
61 
64 
68  struct ChannelMatrix : public SimpleRefCount<ChannelMatrix>
69  {
74 
79 
86  std::pair<uint32_t, uint32_t> m_antennaPair;
87 
93  std::pair<uint32_t, uint32_t> m_nodeIds;
94 
98  virtual ~ChannelMatrix() = default;
99 
107  bool IsReverse(uint32_t aAntennaId, uint32_t bAntennaId) const
108  {
109  uint32_t sAntennaId;
110  uint32_t uAntennaId;
111  std::tie(sAntennaId, uAntennaId) = m_antennaPair;
112  NS_ASSERT_MSG((sAntennaId == aAntennaId && uAntennaId == bAntennaId) ||
113  (sAntennaId == bAntennaId && uAntennaId == aAntennaId),
114  "This channel matrix does not represent the channel among the antenna "
115  "arrays for which are provided IDs.");
116  return (sAntennaId == bAntennaId && uAntennaId == aAntennaId);
117  }
118  };
119 
123  struct ChannelParams : public SimpleRefCount<ChannelParams>
124  {
129 
134 
140 
146 
152 
158  std::pair<uint32_t, uint32_t> m_nodeIds;
159 
163  virtual ~ChannelParams() = default;
164  };
165 
187  Ptr<const PhasedArrayModel> bAntenna) = 0;
188 
198  Ptr<const MobilityModel> bMob) const = 0;
199 
207  static uint64_t GetKey(uint32_t a, uint32_t b)
208  {
209  return (uint64_t)std::min(a, b) << 32 | std::max(a, b);
210  }
211 
212  static const uint8_t AOA_INDEX = 0;
213  static const uint8_t ZOA_INDEX = 1;
214  static const uint8_t AOD_INDEX = 2;
215  static const uint8_t ZOD_INDEX = 3;
216 };
217 
218 }; // namespace ns3
219 
220 #endif // MATRIX_BASED_CHANNEL_H
#define min(a, b)
Definition: 80211b.c:41
#define max(a, b)
Definition: 80211b.c:42
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
Definition: matrix-array.h:83
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
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...
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
~MatrixBasedChannelModel() override
Destructor for MatrixBasedChannelModel.
static const uint8_t ZOA_INDEX
index of the ZOA value in the m_angle array
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 ...
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,...
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
#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:86
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.
Definition: matrix-array.h:247
Data structure that stores a channel realization.
virtual ~ChannelMatrix()=default
Destructor for ChannelMatrix.
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.
virtual ~ChannelParams()=default
Destructor for ChannelParams.
DoubleVector m_alpha
Alpha term per cluster as described in 3GPP TR 37.885 v15.3.0, Sec.
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),...