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