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