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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Rediet <getachew.redieteab@orange.com>
7 */
8
9#ifndef WIFI_PPDU_H
10#define WIFI_PPDU_H
11
12#include "wifi-tx-vector.h"
13
14#include "ns3/nstime.h"
15
16#include <list>
17#include <optional>
18#include <unordered_map>
19#include <vector>
20
21/**
22 * \file
23 * \ingroup wifi
24 * Declaration of ns3::WifiPpdu class
25 * and ns3::WifiConstPsduMap.
26 */
27
28namespace ns3
29{
30
31class Packet;
32class WifiPsdu;
33class WifiPhyOperatingChannel;
34
35/**
36 * Map of const PSDUs indexed by STA-ID
37 */
38typedef std::unordered_map<uint16_t /* STA-ID */, Ptr<const WifiPsdu> /* PSDU */> WifiConstPsduMap;
39
40/**
41 * \ingroup wifi
42 *
43 * WifiPpdu stores a preamble, a modulation class, PHY headers and a PSDU.
44 * This class should be subclassed for each amendment.
45 */
46class WifiPpdu : public SimpleRefCount<WifiPpdu>
47{
48 public:
49 /**
50 * Create a PPDU storing a PSDU.
51 *
52 * \param psdu the PHY payload (PSDU)
53 * \param txVector the TXVECTOR that was used for this PPDU
54 * \param channel the operating channel of the PHY used to transmit this PPDU
55 * \param uid the unique ID of this PPDU
56 */
58 const WifiTxVector& txVector,
59 const WifiPhyOperatingChannel& channel,
60 uint64_t uid = UINT64_MAX);
61 /**
62 * Create a PPDU storing a map of PSDUs.
63 *
64 * \param psdus the PHY payloads (PSDUs)
65 * \param txVector the TXVECTOR that was used for this PPDU
66 * \param channel the operating channel of the PHY used to transmit this PPDU
67 * \param uid the unique ID of this PPDU
68 */
69 WifiPpdu(const WifiConstPsduMap& psdus,
70 const WifiTxVector& txVector,
71 const WifiPhyOperatingChannel& channel,
72 uint64_t uid);
73 /**
74 * Destructor for WifiPpdu.
75 */
76 virtual ~WifiPpdu();
77
78 /**
79 * Get the TXVECTOR used to send the PPDU.
80 *
81 * \return the TXVECTOR of the PPDU.
82 */
83 const WifiTxVector& GetTxVector() const;
84
85 /**
86 * Reset the TXVECTOR.
87 */
88 void ResetTxVector() const;
89
90 /**
91 * Update the TXVECTOR based on some information known at the receiver.
92 *
93 * \param updatedTxVector the updated TXVECTOR.
94 */
95 void UpdateTxVector(const WifiTxVector& updatedTxVector) const;
96
97 /**
98 * Get the payload of the PPDU.
99 *
100 * \return the PSDU
101 */
103
104 /**
105 * \return c\ true if the PPDU's transmission was aborted due to transmitter switch off
106 */
107 bool IsTruncatedTx() const;
108
109 /**
110 * Indicate that the PPDU's transmission was aborted due to transmitter switch off.
111 */
112 void SetTruncatedTx();
113
114 /**
115 * Get the total transmission duration of the PPDU.
116 *
117 * \return the transmission duration of the PPDU
118 */
119 virtual Time GetTxDuration() const;
120
121 /**
122 * Get the channel width over which the PPDU will effectively be
123 * transmitted.
124 *
125 * \return the effective channel width used for the tranmsission
126 */
127 virtual MHz_u GetTxChannelWidth() const;
128
129 /**
130 * \return the center frequency per segment used for the transmission of this PPDU
131 */
132 std::vector<MHz_u> GetTxCenterFreqs() const;
133
134 /**
135 * Check whether the given PPDU overlaps a given channel.
136 *
137 * \param minFreq the minimum frequency of the channel
138 * \param maxFreq the maximum frequency of the channel
139 * \return true if this PPDU overlaps the channel, false otherwise
140 */
141 bool DoesOverlapChannel(MHz_u minFreq, MHz_u maxFreq) const;
142
143 /**
144 * Get the modulation used for the PPDU.
145 * \return the modulation used for the PPDU
146 */
148
149 /**
150 * Get the UID of the PPDU.
151 * \return the UID of the PPDU
152 */
153 uint64_t GetUid() const;
154
155 /**
156 * Get the preamble of the PPDU.
157 * \return the preamble of the PPDU
158 */
160
161 /**
162 * \brief Print the PPDU contents.
163 * \param os output stream in which the data should be printed.
164 */
165 void Print(std::ostream& os) const;
166 /**
167 * \brief Copy this instance.
168 * \return a Ptr to a copy of this instance.
169 */
170 virtual Ptr<WifiPpdu> Copy() const;
171
172 /**
173 * Return the PPDU type (\see WifiPpduType)
174 * \return the PPDU type
175 */
176 virtual WifiPpduType GetType() const;
177
178 /**
179 * Get the ID of the STA that transmitted the PPDU for UL MU,
180 * SU_STA_ID otherwise.
181 * \return the ID of the STA that transmitted the PPDU for UL MU, SU_STA_ID otherwise
182 */
183 virtual uint16_t GetStaId() const;
184
185 protected:
186 /**
187 * \brief Print the payload of the PPDU.
188 * \return information on the payload part of the PPDU
189 */
190 virtual std::string PrintPayload() const;
191
192 WifiPreamble m_preamble; //!< the PHY preamble
193 WifiModulationClass m_modulation; //!< the modulation used for the transmission of this PPDU
194 WifiConstPsduMap m_psdus; //!< the PSDUs contained in this PPDU
195 std::vector<MHz_u> m_txCenterFreqs; //!< the center frequency per segment used for the
196 //!< transmission of this PPDU
197 uint64_t m_uid; //!< the unique ID of this PPDU
198 mutable std::optional<WifiTxVector>
199 m_txVector; //!< the TXVECTOR at TX PHY or the reconstructed TXVECTOR at RX PHY (or
200 //!< std::nullopt if TXVECTOR has not been reconstructed yet)
201 const WifiPhyOperatingChannel& m_operatingChannel; //!< the operating channel of the PHY
202
203 private:
204 /**
205 * Get the TXVECTOR used to send the PPDU.
206 *
207 * \return the TXVECTOR of the PPDU.
208 */
209 virtual WifiTxVector DoGetTxVector() const;
210
211 bool m_truncatedTx; //!< flag indicating whether the frame's transmission was aborted due to
212 //!< transmitter switch off
213 uint8_t m_txPowerLevel; //!< the transmission power level (used only for TX and initializing the
214 //!< returned WifiTxVector)
215 uint8_t m_txAntennas; //!< the number of antennas used to transmit this PPDU
216
217 MHz_u m_txChannelWidth; /**< The channel width used for the transmission of this
218 PPDU. This has to be stored since channel width can not
219 always be obtained from the PHY headers, especially for
220 non-HT PPDU, since we do not sense the spectrum to
221 determine the occupied channel width for simplicity. */
222}; // class WifiPpdu
223
224/**
225 * \brief Stream insertion operator.
226 *
227 * \param os the stream
228 * \param ppdu the const pointer to the PPDU
229 * \returns a reference to the stream
230 */
231std::ostream& operator<<(std::ostream& os, const Ptr<const WifiPpdu>& ppdu);
232
233/**
234 * \brief Stream insertion operator.
235 *
236 * \param os the stream
237 * \param psdus the PSDUs
238 * \returns a reference to the stream
239 */
240std::ostream& operator<<(std::ostream& os, const WifiConstPsduMap& psdus);
241
242} // namespace ns3
243
244#endif /* WIFI_PPDU_H */
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
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:47
void Print(std::ostream &os) const
Print the PPDU contents.
Definition wifi-ppdu.cc:265
virtual Time GetTxDuration() const
Get the total transmission duration of the PPDU.
Definition wifi-ppdu.cc:257
bool IsTruncatedTx() const
Definition wifi-ppdu.cc:155
WifiPreamble GetPreamble() const
Get the preamble of the PPDU.
Definition wifi-ppdu.cc:239
virtual MHz_u GetTxChannelWidth() const
Get the channel width over which the PPDU will effectively be transmitted.
Definition wifi-ppdu.cc:174
void ResetTxVector() const
Reset the TXVECTOR.
Definition wifi-ppdu.cc:134
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:251
const WifiPhyOperatingChannel & m_operatingChannel
the operating channel of the PHY
Definition wifi-ppdu.h:201
WifiPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, const WifiPhyOperatingChannel &channel, uint64_t uid=UINT64_MAX)
Create a PPDU storing a PSDU.
Definition wifi-ppdu.cc:64
void UpdateTxVector(const WifiTxVector &updatedTxVector) const
Update the TXVECTOR based on some information known at the receiver.
Definition wifi-ppdu.cc:141
virtual WifiPpduType GetType() const
Return the PPDU type (.
Definition wifi-ppdu.cc:245
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:199
WifiModulationClass m_modulation
the modulation used for the transmission of this PPDU
Definition wifi-ppdu.h:193
WifiPreamble m_preamble
the PHY preamble
Definition wifi-ppdu.h:192
MHz_u m_txChannelWidth
The channel width used for the transmission of this PPDU.
Definition wifi-ppdu.h:217
virtual ~WifiPpdu()
Destructor for WifiPpdu.
Definition wifi-ppdu.cc:103
Ptr< const WifiPsdu > GetPsdu() const
Get the payload of the PPDU.
Definition wifi-ppdu.cc:149
virtual WifiTxVector DoGetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition wifi-ppdu.cc:126
uint64_t m_uid
the unique ID of this PPDU
Definition wifi-ppdu.h:197
std::vector< MHz_u > m_txCenterFreqs
the center frequency per segment used for the transmission of this PPDU
Definition wifi-ppdu.h:195
void SetTruncatedTx()
Indicate that the PPDU's transmission was aborted due to transmitter switch off.
Definition wifi-ppdu.cc:161
bool DoesOverlapChannel(MHz_u minFreq, MHz_u maxFreq) const
Check whether the given PPDU overlaps a given channel.
Definition wifi-ppdu.cc:186
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
Definition wifi-ppdu.cc:113
uint64_t GetUid() const
Get the UID of the PPDU.
Definition wifi-ppdu.cc:233
WifiModulationClass GetModulation() const
Get the modulation used for the PPDU.
Definition wifi-ppdu.cc:168
WifiConstPsduMap m_psdus
the PSDUs contained in this PPDU
Definition wifi-ppdu.h:194
virtual std::string PrintPayload() const
Print the payload of the PPDU.
Definition wifi-ppdu.cc:273
uint8_t m_txAntennas
the number of antennas used to transmit this PPDU
Definition wifi-ppdu.h:215
uint8_t m_txPowerLevel
the transmission power level (used only for TX and initializing the returned WifiTxVector)
Definition wifi-ppdu.h:213
virtual Ptr< WifiPpdu > Copy() const
Copy this instance.
Definition wifi-ppdu.cc:281
bool m_truncatedTx
flag indicating whether the frame's transmission was aborted due to transmitter switch off
Definition wifi-ppdu.h:211
std::vector< MHz_u > GetTxCenterFreqs() const
Definition wifi-ppdu.cc:180
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:148