A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-ppdu.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Orange Labs
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Rediet <getachew.redieteab@orange.com>
18 */
19
20#ifndef WIFI_PPDU_H
21#define WIFI_PPDU_H
22
23#include "wifi-tx-vector.h"
24
25#include "ns3/nstime.h"
26
27#include <list>
28#include <optional>
29#include <unordered_map>
30
31/**
32 * \file
33 * \ingroup wifi
34 * Declaration of ns3::WifiPpdu class
35 * and ns3::WifiConstPsduMap.
36 */
37
38namespace ns3
39{
40
41class Packet;
42class WifiPsdu;
43class WifiPhyOperatingChannel;
44
45/**
46 * Map of const PSDUs indexed by STA-ID
47 */
48typedef std::unordered_map<uint16_t /* STA-ID */, Ptr<const WifiPsdu> /* PSDU */> WifiConstPsduMap;
49
50/**
51 * \ingroup wifi
52 *
53 * WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
54 * This class should be subclassed for each amendment.
55 */
56class WifiPpdu : public SimpleRefCount<WifiPpdu>
57{
58 public:
59 /**
60 * Create a PPDU storing a PSDU.
61 *
62 * \param psdu the PHY payload (PSDU)
63 * \param txVector the TXVECTOR that was used for this PPDU
64 * \param channel the operating channel of the PHY used to transmit this PPDU
65 * \param uid the unique ID of this PPDU
66 */
68 const WifiTxVector& txVector,
69 const WifiPhyOperatingChannel& channel,
70 uint64_t uid = UINT64_MAX);
71 /**
72 * Create a PPDU storing a map of PSDUs.
73 *
74 * \param psdus the PHY payloads (PSDUs)
75 * \param txVector the TXVECTOR that was used for this PPDU
76 * \param channel the operating channel of the PHY used to transmit this PPDU
77 * \param uid the unique ID of this PPDU
78 */
79 WifiPpdu(const WifiConstPsduMap& psdus,
80 const WifiTxVector& txVector,
81 const WifiPhyOperatingChannel& channel,
82 uint64_t uid);
83 /**
84 * Destructor for WifiPpdu.
85 */
86 virtual ~WifiPpdu();
87
88 /**
89 * Get the TXVECTOR used to send the PPDU.
90 *
91 * \return the TXVECTOR of the PPDU.
92 */
93 const WifiTxVector& GetTxVector() const;
94
95 /**
96 * Reset the TXVECTOR.
97 */
98 void ResetTxVector() const;
99
100 /**
101 * Update the TXVECTOR based on some information known at the receiver.
102 *
103 * \param updatedTxVector the updated TXVECTOR.
104 */
105 void UpdateTxVector(const WifiTxVector& updatedTxVector) const;
106
107 /**
108 * Get the payload of the PPDU.
109 *
110 * \return the PSDU
111 */
113
114 /**
115 * \return c\ true if the PPDU's transmission was aborted due to transmitter switch off
116 */
117 bool IsTruncatedTx() const;
118
119 /**
120 * Indicate that the PPDU's transmission was aborted due to transmitter switch off.
121 */
122 void SetTruncatedTx();
123
124 /**
125 * Get the total transmission duration of the PPDU.
126 *
127 * \return the transmission duration of the PPDU
128 */
129 virtual Time GetTxDuration() const;
130
131 /**
132 * Get the channel width over which the PPDU will effectively be
133 * transmitted.
134 *
135 * \return the effective channel width (in MHz) used for the tranmsission
136 */
137 virtual uint16_t GetTxChannelWidth() const;
138
139 /**
140 * \return the center frequency (MHz) used for the transmission of this PPDU
141 */
142 uint16_t GetTxCenterFreq() const;
143
144 /**
145 * Check whether the given PPDU overlaps a given channel.
146 *
147 * \param minFreq the minimum frequency (MHz) of the channel
148 * \param maxFreq the maximum frequency (MHz) of the channel
149 * \return true if this PPDU overlaps the channel, false otherwise
150 */
151 bool DoesOverlapChannel(uint16_t minFreq, uint16_t maxFreq) const;
152
153 /**
154 * Get the modulation used for the PPDU.
155 * \return the modulation used for the PPDU
156 */
158
159 /**
160 * Get the UID of the PPDU.
161 * \return the UID of the PPDU
162 */
163 uint64_t GetUid() const;
164
165 /**
166 * Get the preamble of the PPDU.
167 * \return the preamble of the PPDU
168 */
170
171 /**
172 * \brief Print the PPDU contents.
173 * \param os output stream in which the data should be printed.
174 */
175 void Print(std::ostream& os) const;
176 /**
177 * \brief Copy this instance.
178 * \return a Ptr to a copy of this instance.
179 */
180 virtual Ptr<WifiPpdu> Copy() const;
181
182 /**
183 * Return the PPDU type (\see WifiPpduType)
184 * \return the PPDU type
185 */
186 virtual WifiPpduType GetType() const;
187
188 /**
189 * Get the ID of the STA that transmitted the PPDU for UL MU,
190 * SU_STA_ID otherwise.
191 * \return the ID of the STA that transmitted the PPDU for UL MU, SU_STA_ID otherwise
192 */
193 virtual uint16_t GetStaId() const;
194
195 protected:
196 /**
197 * \brief Print the payload of the PPDU.
198 * \return information on the payload part of the PPDU
199 */
200 virtual std::string PrintPayload() const;
201
202 WifiPreamble m_preamble; //!< the PHY preamble
203 WifiModulationClass m_modulation; //!< the modulation used for the transmission of this PPDU
204 WifiConstPsduMap m_psdus; //!< the PSDUs contained in this PPDU
205 uint16_t m_txCenterFreq; //!< the center frequency (MHz) used for the transmission of this PPDU
206 uint64_t m_uid; //!< the unique ID of this PPDU
207 mutable std::optional<WifiTxVector>
208 m_txVector; //!< the TXVECTOR at TX PHY or the reconstructed TXVECTOR at RX PHY (or
209 //!< std::nullopt if TXVECTOR has not been reconstructed yet)
210 const WifiPhyOperatingChannel& m_operatingChannel; //!< the operating channel of the PHY
211
212 private:
213 /**
214 * Get the TXVECTOR used to send the PPDU.
215 *
216 * \return the TXVECTOR of the PPDU.
217 */
218 virtual WifiTxVector DoGetTxVector() const;
219
220 bool m_truncatedTx; //!< flag indicating whether the frame's transmission was aborted due to
221 //!< transmitter switch off
222 uint8_t m_txPowerLevel; //!< the transmission power level (used only for TX and initializing the
223 //!< returned WifiTxVector)
224 uint8_t m_txAntennas; //!< the number of antennas used to transmit this PPDU
225
226 uint16_t m_txChannelWidth; /**< The channel width (MHz) used for the transmission of this
227 PPDU. This has to be stored since channel width can not
228 always be obtained from the PHY headers, especially for
229 non-HT PPDU, since we do not sense the spectrum to
230 determine the occupied channel width for simplicity. */
231}; // class WifiPpdu
232
233/**
234 * \brief Stream insertion operator.
235 *
236 * \param os the stream
237 * \param ppdu the const pointer to the PPDU
238 * \returns a reference to the stream
239 */
240std::ostream& operator<<(std::ostream& os, const Ptr<const WifiPpdu>& ppdu);
241
242/**
243 * \brief Stream insertion operator.
244 *
245 * \param os the stream
246 * \param psdus the PSDUs
247 * \returns a reference to the stream
248 */
249std::ostream& operator<<(std::ostream& os, const WifiConstPsduMap& psdus);
250
251} // namespace ns3
252
253#endif /* WIFI_PPDU_H */
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
Class that keeps track of all information about the current PHY operating channel.
WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
Definition: wifi-ppdu.h:57
void Print(std::ostream &os) const
Print the PPDU contents.
Definition: wifi-ppdu.cc:228
virtual Time GetTxDuration() const
Get the total transmission duration of the PPDU.
Definition: wifi-ppdu.cc:220
bool IsTruncatedTx() const
Definition: wifi-ppdu.cc:127
WifiPreamble GetPreamble() const
Get the preamble of the PPDU.
Definition: wifi-ppdu.cc:202
uint16_t GetTxCenterFreq() const
Definition: wifi-ppdu.cc:152
void ResetTxVector() const
Reset the TXVECTOR.
Definition: wifi-ppdu.cc:106
virtual uint16_t GetStaId() const
Get the ID of the STA that transmitted the PPDU for UL MU, SU_STA_ID otherwise.
Definition: wifi-ppdu.cc:214
uint16_t m_txChannelWidth
The channel width (MHz) used for the transmission of this PPDU.
Definition: wifi-ppdu.h:226
const WifiPhyOperatingChannel & m_operatingChannel
the operating channel of the PHY
Definition: wifi-ppdu.h:210
uint16_t m_txCenterFreq
the center frequency (MHz) used for the transmission of this PPDU
Definition: wifi-ppdu.h:205
void UpdateTxVector(const WifiTxVector &updatedTxVector) const
Update the TXVECTOR based on some information known at the receiver.
Definition: wifi-ppdu.cc:113
virtual WifiPpduType GetType() const
Return the PPDU type (.
Definition: wifi-ppdu.cc:208
std::optional< WifiTxVector > m_txVector
the TXVECTOR at TX PHY or the reconstructed TXVECTOR at RX PHY (or std::nullopt if TXVECTOR has not b...
Definition: wifi-ppdu.h:208
WifiModulationClass m_modulation
the modulation used for the transmission of this PPDU
Definition: wifi-ppdu.h:203
WifiPreamble m_preamble
the PHY preamble
Definition: wifi-ppdu.h:202
virtual ~WifiPpdu()
Destructor for WifiPpdu.
Definition: wifi-ppdu.cc:75
Ptr< const WifiPsdu > GetPsdu() const
Get the payload of the PPDU.
Definition: wifi-ppdu.cc:121
virtual WifiTxVector DoGetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:98
uint64_t m_uid
the unique ID of this PPDU
Definition: wifi-ppdu.h:206
void SetTruncatedTx()
Indicate that the PPDU's transmission was aborted due to transmitter switch off.
Definition: wifi-ppdu.cc:133
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition: wifi-ppdu.cc:85
uint64_t GetUid() const
Get the UID of the PPDU.
Definition: wifi-ppdu.cc:196
WifiModulationClass GetModulation() const
Get the modulation used for the PPDU.
Definition: wifi-ppdu.cc:140
WifiConstPsduMap m_psdus
the PSDUs contained in this PPDU
Definition: wifi-ppdu.h:204
virtual std::string PrintPayload() const
Print the payload of the PPDU.
Definition: wifi-ppdu.cc:236
virtual uint16_t GetTxChannelWidth() const
Get the channel width over which the PPDU will effectively be transmitted.
Definition: wifi-ppdu.cc:146
uint8_t m_txAntennas
the number of antennas used to transmit this PPDU
Definition: wifi-ppdu.h:224
bool DoesOverlapChannel(uint16_t minFreq, uint16_t maxFreq) const
Check whether the given PPDU overlaps a given channel.
Definition: wifi-ppdu.cc:158
uint8_t m_txPowerLevel
the transmission power level (used only for TX and initializing the returned WifiTxVector)
Definition: wifi-ppdu.h:222
virtual Ptr< WifiPpdu > Copy() const
Copy this instance.
Definition: wifi-ppdu.cc:244
bool m_truncatedTx
flag indicating whether the frame's transmission was aborted due to transmitter switch off
Definition: wifi-ppdu.h:220
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPpduType
The type of PPDU (SU, DL MU, or UL MU)
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159