A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-psdu.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef WIFI_PSDU_H
10#define WIFI_PSDU_H
11
12#include "wifi-mac-header.h"
13#include "wifi-mpdu.h"
14
15#include "ns3/nstime.h"
16
17#include <set>
18#include <vector>
19
20namespace ns3
21{
22
23class Packet;
24
25/**
26 * \ingroup wifi
27 *
28 * WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and
29 * payload(s) separate for each constituent MPDU.
30 */
31class WifiPsdu : public SimpleRefCount<WifiPsdu>
32{
33 public:
34 /**
35 * Create a PSDU storing an MPDU. Typically used for control and management
36 * frames that do not have to keep an associated lifetime and are not stored
37 * in an S-MPDU.
38 *
39 * \param p the payload of the MPDU.
40 * \param header the Wifi MAC header of the MPDU.
41 */
43
44 /**
45 * Create a PSDU storing an MPDU or S-MPDU. Typically used for QoS data
46 * frames that have to keep an associated lifetime.
47 *
48 * \param mpdu the MPDU.
49 * \param isSingle true for an S-MPDU
50 */
51 WifiPsdu(Ptr<WifiMpdu> mpdu, bool isSingle);
52
53 /**
54 * Create a PSDU storing an MPDU or S-MPDU. Typically used for QoS data
55 * frames that have to keep an associated lifetime.
56 *
57 * \param mpdu the MPDU.
58 * \param isSingle true for an S-MPDU
59 */
60 WifiPsdu(Ptr<const WifiMpdu> mpdu, bool isSingle);
61
62 /**
63 * Create a PSDU storing an S-MPDU or A-MPDU.
64 *
65 * \param mpduList the list of constituent MPDUs.
66 */
67 WifiPsdu(std::vector<Ptr<WifiMpdu>> mpduList);
68
69 virtual ~WifiPsdu();
70
71 /**
72 * Return true if the PSDU is an S-MPDU
73 * \return true if the PSDU is an S-MPDU.
74 */
75 bool IsSingle() const;
76
77 /**
78 * Return true if the PSDU is an S-MPDU or A-MPDU
79 * \return true if the PSDU is an S-MPDU or A-MPDU.
80 */
81 bool IsAggregate() const;
82
83 /**
84 * \brief Get the PSDU as a single packet
85 * \return the PSDU.
86 */
88
89 /**
90 * \brief Get the header of the i-th MPDU
91 * \param i index in the list of MPDUs
92 * \return the header of the i-th MPDU.
93 */
94 const WifiMacHeader& GetHeader(std::size_t i) const;
95
96 /**
97 * \brief Get the header of the i-th MPDU
98 * \param i index in the list of MPDUs
99 * \return the header of the i-th MPDU.
100 */
101 WifiMacHeader& GetHeader(std::size_t i);
102
103 /**
104 * \brief Get the payload of the i-th MPDU
105 * \param i index in the list of MPDUs
106 * \return the payload of the i-th MPDU.
107 */
108 Ptr<const Packet> GetPayload(std::size_t i) const;
109
110 /**
111 * \brief Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly
112 * padding)
113 * \param i the index in the list of A-MPDU subframes \return the i-th A-MPDU subframe.
114 */
115 Ptr<Packet> GetAmpduSubframe(std::size_t i) const;
116
117 /**
118 * \brief Return the size of the i-th A-MPDU subframe.
119 * \param i the index in the list of A-MPDU subframes
120 * \return the size of the i-th A-MPDU subframe.
121 */
122 std::size_t GetAmpduSubframeSize(std::size_t i) const;
123
124 /**
125 * Get the Receiver Address (RA), which is common to all the MPDUs
126 * \return the Receiver Address.
127 */
128 Mac48Address GetAddr1() const;
129
130 /**
131 * Get the Transmitter Address (TA), which is common to all the MPDUs
132 * \return the Transmitter Address.
133 */
134 Mac48Address GetAddr2() const;
135
136 /**
137 * \return true if the Duration/ID field contains a value for setting the NAV
138 */
139 bool HasNav() const;
140
141 /**
142 * Get the duration from the Duration/ID field, which is common to all the MPDUs
143 * \return the duration from the Duration/ID field.
144 */
145 Time GetDuration() const;
146
147 /**
148 * Set the Duration/ID field on all the MPDUs
149 * \param duration the value for the Duration/ID field.
150 */
151 void SetDuration(Time duration);
152
153 /**
154 * Get the set of TIDs of the QoS Data frames included in the PSDU. Note that
155 * only single-TID A-MPDUs are currently supported, hence the returned set
156 * contains at most one TID value.
157 *
158 * \return the set of TIDs of the QoS Data frames included in the PSDU.
159 */
160 std::set<uint8_t> GetTids() const;
161
162 /**
163 * Get the QoS Ack Policy of the QoS Data frames included in the PSDU that
164 * have the given TID. Also, check that all the QoS Data frames having the
165 * given TID have the same QoS Ack Policy. Do not call this method if there
166 * is no QoS Date frame in the PSDU.
167 *
168 * \param tid the given TID
169 * \return the QoS Ack Policy common to all QoS Data frames having the given TID.
170 */
172
173 /**
174 * Set the QoS Ack Policy of the QoS Data frames included in the PSDU that
175 * have the given TID to the given policy.
176 *
177 * \param tid the given TID
178 * \param policy the given QoS Ack policy
179 */
180 void SetAckPolicyForTid(uint8_t tid, WifiMacHeader::QosAckPolicy policy);
181
182 /**
183 * Get the maximum distance between the sequence number of any QoS Data frame
184 * included in this PSDU that is not an old frame and the given starting
185 * sequence number. If this PSDU does not contain any QoS Data frame that
186 * is not an old frame, an invalid distance (4096) is returned.
187 *
188 * \param startingSeq the given starting sequence number.
189 * \return the maximum distance between the sequence numbers included in the
190 * PSDU and the given starting sequence number
191 */
192 uint16_t GetMaxDistFromStartingSeq(uint16_t startingSeq) const;
193
194 /**
195 * \brief Return the size of the PSDU in bytes
196 *
197 * \return the size of the PSDU.
198 */
199 uint32_t GetSize() const;
200
201 /**
202 * \brief Return the number of MPDUs constituting the PSDU
203 *
204 * \return the number of MPDUs constituting the PSDU.
205 */
206 std::size_t GetNMpdus() const;
207
208 /**
209 * \brief Return a const iterator to the first MPDU
210 *
211 * \return a const iterator to the first MPDU.
212 */
213 std::vector<Ptr<WifiMpdu>>::const_iterator begin() const;
214
215 /**
216 * \brief Return an iterator to the first MPDU
217 *
218 * \return an iterator to the first MPDU.
219 */
220 std::vector<Ptr<WifiMpdu>>::iterator begin();
221
222 /**
223 * \brief Return a const iterator to past-the-last MPDU
224 *
225 * \return a const iterator to past-the-last MPDU.
226 */
227 std::vector<Ptr<WifiMpdu>>::const_iterator end() const;
228
229 /**
230 * \brief Return an iterator to past-the-last MPDU
231 *
232 * \return an iterator to past-the-last MPDU.
233 */
234 std::vector<Ptr<WifiMpdu>>::iterator end();
235
236 /**
237 * \brief Print the PSDU contents.
238 * \param os output stream in which the data should be printed.
239 */
240 void Print(std::ostream& os) const;
241
242 private:
243 bool m_isSingle; //!< true for an S-MPDU
244 std::vector<Ptr<WifiMpdu>> m_mpduList; //!< list of constituent MPDUs
245 uint32_t m_size; //!< the size of the PSDU in bytes
246};
247
248/**
249 * \brief Stream insertion operator.
250 *
251 * \param os the stream
252 * \param psdu the PSDU
253 * \returns a reference to the stream
254 */
255std::ostream& operator<<(std::ostream& os, const WifiPsdu& psdu);
256
257} // namespace ns3
258
259#endif /* WIFI_PSDU_H */
an EUI-48 address
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
Implements the IEEE 802.11 MAC header.
QosAckPolicy
Ack policy for QoS frames.
WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and payload(s) separate for each cons...
Definition wifi-psdu.h:32
std::set< uint8_t > GetTids() const
Get the set of TIDs of the QoS Data frames included in the PSDU.
Definition wifi-psdu.cc:167
void SetAckPolicyForTid(uint8_t tid, WifiMacHeader::QosAckPolicy policy)
Set the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID to the giv...
Definition wifi-psdu.cc:215
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
Definition wifi-psdu.cc:268
void Print(std::ostream &os) const
Print the PSDU contents.
Definition wifi-psdu.cc:346
Time GetDuration() const
Get the duration from the Duration/ID field, which is common to all the MPDUs.
Definition wifi-psdu.cc:142
Ptr< const Packet > GetPacket() const
Get the PSDU as a single packet.
Definition wifi-psdu.cc:78
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding)
Definition wifi-psdu.cc:286
std::vector< Ptr< WifiMpdu > >::const_iterator end() const
Return a const iterator to past-the-last MPDU.
Definition wifi-psdu.cc:334
std::vector< Ptr< WifiMpdu > >::const_iterator begin() const
Return a const iterator to the first MPDU.
Definition wifi-psdu.cc:322
WifiPsdu(Ptr< const Packet > p, const WifiMacHeader &header)
Create a PSDU storing an MPDU.
Definition wifi-psdu.cc:24
Mac48Address GetAddr2() const
Get the Transmitter Address (TA), which is common to all the MPDUs.
Definition wifi-psdu.cc:117
bool HasNav() const
Definition wifi-psdu.cc:132
uint32_t m_size
the size of the PSDU in bytes
Definition wifi-psdu.h:245
virtual ~WifiPsdu()
Definition wifi-psdu.cc:61
uint32_t GetSize() const
Return the size of the PSDU in bytes.
Definition wifi-psdu.cc:262
Ptr< const Packet > GetPayload(std::size_t i) const
Get the payload of the i-th MPDU.
Definition wifi-psdu.cc:280
std::size_t GetAmpduSubframeSize(std::size_t i) const
Return the size of the i-th A-MPDU subframe.
Definition wifi-psdu.cc:303
bool m_isSingle
true for an S-MPDU
Definition wifi-psdu.h:243
WifiPsdu(Ptr< const WifiMpdu > mpdu, bool isSingle)
Create a PSDU storing an MPDU or S-MPDU.
Mac48Address GetAddr1() const
Get the Receiver Address (RA), which is common to all the MPDUs.
Definition wifi-psdu.cc:102
bool IsAggregate() const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition wifi-psdu.cc:72
bool IsSingle() const
Return true if the PSDU is an S-MPDU.
Definition wifi-psdu.cc:66
void SetDuration(Time duration)
Set the Duration/ID field on all the MPDUs.
Definition wifi-psdu.cc:157
std::vector< Ptr< WifiMpdu > > m_mpduList
list of constituent MPDUs
Definition wifi-psdu.h:244
uint16_t GetMaxDistFromStartingSeq(uint16_t startingSeq) const
Get the maximum distance between the sequence number of any QoS Data frame included in this PSDU that...
Definition wifi-psdu.cc:228
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
Definition wifi-psdu.cc:316
WifiMacHeader::QosAckPolicy GetAckPolicyForTid(uint8_t tid) const
Get the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID.
Definition wifi-psdu.cc:181
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