A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mpdu.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Mirko Banchi <mk.banchi@gmail.com>
20 * Stefano Avallone <stavallo@unina.it>
21 */
22
23#ifndef WIFI_MPDU_H
24#define WIFI_MPDU_H
25
27#include "wifi-mac-header.h"
28#include "wifi-mac-queue-elem.h"
29
30#include "ns3/packet.h"
31#include "ns3/simulator.h"
32
33#include <list>
34#include <optional>
35#include <set>
36#include <variant>
37
38namespace ns3
39{
40
41/**
42 * \ingroup wifi
43 *
44 * Tag used to allow (only) WifiMacQueue to access the queue iterator stored
45 * by a WifiMpdu.
46 */
48{
49 friend class WifiMacQueue;
50 WmqIteratorTag() = default;
51};
52
53/**
54 * \ingroup wifi
55 *
56 * WifiMpdu stores a (const) packet along with a MAC header. To support 802.11be
57 * Multi-Link Operation (MLO), a WifiMpdu variant, referred to as WifiMpdu alias,
58 * is added. A WifiMpdu alias stores its own MAC header and a pointer to the original
59 * copy of the WifiMpdu.
60 */
61class WifiMpdu : public SimpleRefCount<WifiMpdu>
62{
63 public:
64 /**
65 * \brief Create a Wifi MAC queue item containing a packet and a Wifi MAC header.
66 * \param p the const packet included in the created item.
67 * \param header the Wifi MAC header included in the created item.
68 * \param stamp the timestamp to associate with the MPDU
69 */
70 WifiMpdu(Ptr<const Packet> p, const WifiMacHeader& header, Time stamp = Simulator::Now());
71
72 virtual ~WifiMpdu();
73
74 /**
75 * \return whether this is the original version of the MPDU
76 */
77 bool IsOriginal() const;
78
79 /**
80 * \return the original version of this MPDU
81 */
83
84 /**
85 * \brief Get the packet stored in this item
86 * \return the packet stored in this item.
87 */
89
90 /**
91 * \brief Get the header stored in this item
92 * \return the header stored in this item.
93 */
94 const WifiMacHeader& GetHeader() const;
95
96 /**
97 * \brief Get the header stored in this item
98 * \return the header stored in this item.
99 */
101
102 /**
103 * \brief Return the destination address present in the header
104 * \return the destination address
105 */
107
108 /**
109 * \brief Return the size of the packet stored by this item, including header
110 * size and trailer size
111 *
112 * \return the size of the packet stored by this item in bytes.
113 */
114 uint32_t GetSize() const;
115
116 /**
117 * \brief Return the size in bytes of the packet or control header or management
118 * header stored by this item.
119 *
120 * \return the size in bytes of the packet or control header or management header
121 * stored by this item
122 */
123 uint32_t GetPacketSize() const;
124
125 /**
126 * Return true if this item contains an MSDU fragment, false otherwise
127 * \return true if this item contains an MSDU fragment, false otherwise
128 */
129 bool IsFragment() const;
130
131 /**
132 * \brief Aggregate the MSDU contained in the given MPDU to this MPDU (thus
133 * constituting an A-MSDU). Note that the given MPDU cannot contain
134 * an A-MSDU. If the given MPDU is a null pointer, the effect of this
135 * call is to add only an A-MSDU subframe header, thus producing an A-MSDU
136 * containing a single MSDU.
137 * \param msdu the MPDU containing the MSDU to aggregate
138 */
140
141 /// DeaggregatedMsdus typedef
142 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>> DeaggregatedMsdus;
143 /// DeaggregatedMsdusCI typedef
144 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>>::const_iterator
146
147 /**
148 * \brief Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
149 *
150 * \return a constant iterator pointing to the first MSDU in the list of aggregated MSDUs
151 */
153 /**
154 * \brief Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
155 *
156 * \return a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs
157 */
158 DeaggregatedMsdusCI end() const;
159
160 /// Const iterator typedef
161 typedef std::list<WifiMacQueueElem>::iterator Iterator;
162
163 /**
164 * Set the queue iterator stored by this object.
165 *
166 * \param queueIt the queue iterator for this object
167 * \param tag a wifi MAC queue iterator tag (allows only WifiMacQueue to call this method)
168 */
169 void SetQueueIt(std::optional<Iterator> queueIt, WmqIteratorTag tag);
170 /**
171 * \param tag a wifi MAC queue iterator tag (allows only WifiMacQueue to call this method)
172 * \return the queue iterator stored by this object
173 */
175
176 /**
177 * Return true if this item is stored in some queue, false otherwise.
178 *
179 * \return true if this item is stored in some queue, false otherwise
180 */
181 bool IsQueued() const;
182 /**
183 * Get the AC of the queue this item is stored into. Abort if this item
184 * is not stored in a queue.
185 *
186 * \return the AC of the queue this item is stored into
187 */
188 AcIndex GetQueueAc() const;
189 /**
190 * \return the time this MPDU was constructed
191 */
192 Time GetTimestamp() const;
193 /**
194 * \return the expiry time of this MPDU
195 */
196 Time GetExpiryTime() const;
197
198 /**
199 * \brief Get the MAC protocol data unit (MPDU) corresponding to this item
200 * (i.e. a copy of the packet stored in this item wrapped with MAC
201 * header and trailer)
202 * \return the MAC protocol data unit corresponding to this item.
203 */
205
206 /**
207 * Mark this MPDU as being in flight on the given link.
208 *
209 * \param linkId the ID of the given link
210 */
211 void SetInFlight(uint8_t linkId) const;
212 /**
213 * Mark this MPDU as not being in flight on the given link.
214 *
215 * \param linkId the ID of the given link
216 */
217 void ResetInFlight(uint8_t linkId) const;
218 /**
219 * \return the set of IDs of the links on which this MPDU is currently in flight
220 */
221 std::set<uint8_t> GetInFlightLinkIds() const;
222 /**
223 * \return true if this MPDU is in flight on any link, false otherwise
224 */
225 bool IsInFlight() const;
226
227 /**
228 * Set the sequence number of this MPDU (and of the original copy, if this is an alias)
229 * to the given value. Also, record that a sequence number has been assigned to this MPDU.
230 *
231 * \param seqNo the given sequence number
232 */
233 void AssignSeqNo(uint16_t seqNo);
234 /**
235 * \return whether a sequence number has been assigned to this MPDU
236 */
237 bool HasSeqNoAssigned() const;
238 /**
239 * Record that a sequence number is no (longer) assigned to this MPDU.
240 */
241 void UnassignSeqNo();
242
243 /**
244 * Create an alias for this MPDU (which must be an original copy) for transmission
245 * on the link with the given ID. Aliases have their own copy of the MAC header and
246 * cannot be used to perform non-const operations on the frame body.
247 *
248 * \param linkId the ID of the given link
249 * \return an alias for this MPDU
250 */
251 Ptr<WifiMpdu> CreateAlias(uint8_t linkId) const;
252
253 /**
254 * \brief Print the item contents.
255 * \param os output stream in which the data should be printed.
256 */
257 virtual void Print(std::ostream& os) const;
258
259 private:
260 /**
261 * \brief Aggregate the MSDU contained in the given MPDU to this MPDU (thus
262 * constituting an A-MSDU). Note that the given MPDU cannot contain
263 * an A-MSDU.
264 * \param msdu the MPDU containing the MSDU to aggregate
265 */
267
268 /**
269 * \return the queue iterator stored by this object
270 */
271 Iterator GetQueueIt() const;
272
273 /**
274 * Private default constructor (used to construct aliases).
275 */
276 WifiMpdu() = default;
277
278 /**
279 * Information stored by both the original copy and the aliases
280 */
281 WifiMacHeader m_header; //!< Wifi MAC header associated with the packet
282
283 /**
284 * Information stored by the original copy only.
285 */
287 {
288 Ptr<const Packet> m_packet; //!< MSDU or A-MSDU contained in this queue item
289 Time m_timestamp; //!< construction time
290 DeaggregatedMsdus m_msduList; //!< list of aggregated MSDUs included in this MPDU
291 std::optional<Iterator> m_queueIt; //!< Queue iterator pointing to this MPDU, if queued
292 bool m_seqNoAssigned; //!< whether a sequence number has been assigned
293 };
294
295 /**
296 * \return a reference to the information held by the original copy of the MPDU.
297 */
299 /**
300 * \return a const reference to the information held by the original copy of the MPDU.
301 */
302 const OriginalInfo& GetOriginalInfo() const;
303
304 /// Information stored by the original copy and an alias, respectively
305 using InstanceInfo = std::variant<OriginalInfo, Ptr<WifiMpdu>>;
306
307 InstanceInfo m_instanceInfo; //!< information associated with the instance type
308 static constexpr std::size_t ORIGINAL =
309 0; //!< index of original copy in the InstanceInfo variant
310 static constexpr std::size_t ALIAS = 1; //!< index of an alias in the InstanceInfo variant
311};
312
313/**
314 * \brief Stream insertion operator.
315 *
316 * \param os the output stream
317 * \param item the WifiMpdu
318 * \returns a reference to the stream
319 */
320std::ostream& operator<<(std::ostream& os, const WifiMpdu& item);
321
322} // namespace ns3
323
324#endif /* WIFI_MPDU_H */
Headers for A-MSDU subframes.
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.
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Implements the IEEE 802.11 MAC header.
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
WifiMpdu stores a (const) packet along with a MAC header.
Definition: wifi-mpdu.h:62
bool IsOriginal() const
Definition: wifi-mpdu.cc:57
InstanceInfo m_instanceInfo
information associated with the instance type
Definition: wifi-mpdu.h:307
Time GetTimestamp() const
Definition: wifi-mpdu.cc:119
bool HasSeqNoAssigned() const
Definition: wifi-mpdu.cc:360
Time GetExpiryTime() const
Definition: wifi-mpdu.cc:307
bool IsInFlight() const
Definition: wifi-mpdu.cc:340
static constexpr std::size_t ALIAS
index of an alias in the InstanceInfo variant
Definition: wifi-mpdu.h:310
void ResetInFlight(uint8_t linkId) const
Mark this MPDU as not being in flight on the given link.
Definition: wifi-mpdu.cc:319
WifiMacHeader m_header
Information stored by both the original copy and the aliases.
Definition: wifi-mpdu.h:281
void SetInFlight(uint8_t linkId) const
Mark this MPDU as being in flight on the given link.
Definition: wifi-mpdu.cc:313
Iterator GetQueueIt() const
Definition: wifi-mpdu.cc:294
std::list< std::pair< Ptr< constPacket >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
Definition: wifi-mpdu.h:145
const WifiMacHeader & GetHeader() const
Get the header stored in this item.
Definition: wifi-mpdu.cc:130
std::variant< OriginalInfo, Ptr< WifiMpdu > > InstanceInfo
Information stored by the original copy and an alias, respectively.
Definition: wifi-mpdu.h:305
void Aggregate(Ptr< const WifiMpdu > msdu)
Aggregate the MSDU contained in the given MPDU to this MPDU (thus constituting an A-MSDU).
Definition: wifi-mpdu.cc:175
OriginalInfo & GetOriginalInfo()
Definition: wifi-mpdu.cc:91
virtual ~WifiMpdu()
Definition: wifi-mpdu.cc:50
uint32_t GetSize() const
Return the size of the packet stored by this item, including header size and trailer size.
Definition: wifi-mpdu.cc:154
Ptr< Packet > GetProtocolDataUnit() const
Get the MAC protocol data unit (MPDU) corresponding to this item (i.e.
Definition: wifi-mpdu.cc:166
void DoAggregate(Ptr< const WifiMpdu > msdu)
Aggregate the MSDU contained in the given MPDU to this MPDU (thus constituting an A-MSDU).
Definition: wifi-mpdu.cc:222
std::list< std::pair< Ptr< const Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Definition: wifi-mpdu.h:142
void UnassignSeqNo()
Record that a sequence number is no (longer) assigned to this MPDU.
Definition: wifi-mpdu.cc:366
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: wifi-mpdu.cc:384
WifiMpdu()=default
Private default constructor (used to construct aliases).
Ptr< const Packet > GetPacket() const
Get the packet stored in this item.
Definition: wifi-mpdu.cc:113
DeaggregatedMsdusCI end() const
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
Definition: wifi-mpdu.cc:378
DeaggregatedMsdusCI begin() const
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
Definition: wifi-mpdu.cc:372
uint32_t GetPacketSize() const
Return the size in bytes of the packet or control header or management header stored by this item.
Definition: wifi-mpdu.cc:148
AcIndex GetQueueAc() const
Get the AC of the queue this item is stored into.
Definition: wifi-mpdu.cc:301
std::list< WifiMacQueueElem >::iterator Iterator
Const iterator typedef.
Definition: wifi-mpdu.h:161
Mac48Address GetDestinationAddress() const
Return the destination address present in the header.
Definition: wifi-mpdu.cc:142
bool IsQueued() const
Return true if this item is stored in some queue, false otherwise.
Definition: wifi-mpdu.cc:272
void SetQueueIt(std::optional< Iterator > queueIt, WmqIteratorTag tag)
Set the queue iterator stored by this object.
Definition: wifi-mpdu.cc:278
bool IsFragment() const
Return true if this item contains an MSDU fragment, false otherwise.
Definition: wifi-mpdu.cc:160
std::set< uint8_t > GetInFlightLinkIds() const
Definition: wifi-mpdu.cc:325
Ptr< const WifiMpdu > GetOriginal() const
Definition: wifi-mpdu.cc:63
void AssignSeqNo(uint16_t seqNo)
Set the sequence number of this MPDU (and of the original copy, if this is an alias) to the given val...
Definition: wifi-mpdu.cc:346
Ptr< WifiMpdu > CreateAlias(uint8_t linkId) const
Create an alias for this MPDU (which must be an original copy) for transmission on the link with the ...
Definition: wifi-mpdu.cc:73
static constexpr std::size_t ORIGINAL
index of original copy in the InstanceInfo variant
Definition: wifi-mpdu.h:308
Tag used to allow (only) WifiMacQueue to access the queue iterator stored by a WifiMpdu.
Definition: wifi-mpdu.h:48
WmqIteratorTag()=default
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
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
Information stored by the original copy only.
Definition: wifi-mpdu.h:287
Time m_timestamp
construction time
Definition: wifi-mpdu.h:289
bool m_seqNoAssigned
whether a sequence number has been assigned
Definition: wifi-mpdu.h:292
DeaggregatedMsdus m_msduList
list of aggregated MSDUs included in this MPDU
Definition: wifi-mpdu.h:290
Ptr< const Packet > m_packet
MSDU or A-MSDU contained in this queue item.
Definition: wifi-mpdu.h:288
std::optional< Iterator > m_queueIt
Queue iterator pointing to this MPDU, if queued.
Definition: wifi-mpdu.h:291