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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Mirko Banchi <mk.banchi@gmail.com>
9 * Stefano Avallone <stavallo@unina.it>
10 */
11
12#ifndef WIFI_MPDU_H
13#define WIFI_MPDU_H
14
16#include "wifi-mac-header.h"
17#include "wifi-mac-queue-elem.h"
18
19#include "ns3/packet.h"
20#include "ns3/simulator.h"
21
22#include <list>
23#include <optional>
24#include <set>
25#include <variant>
26
27namespace ns3
28{
29
30/**
31 * @ingroup wifi
32 *
33 * Tag used to allow (only) WifiMacQueue to access the queue iterator stored
34 * by a WifiMpdu.
35 */
37{
38 friend class WifiMacQueue;
39 WmqIteratorTag() = default;
40};
41
42/**
43 * @ingroup wifi
44 *
45 * WifiMpdu stores a (const) packet along with a MAC header. To support 802.11be
46 * Multi-Link Operation (MLO), a WifiMpdu variant, referred to as WifiMpdu alias,
47 * is added. A WifiMpdu alias stores its own MAC header and a pointer to the original
48 * copy of the WifiMpdu.
49 */
50class WifiMpdu : public SimpleRefCount<WifiMpdu>
51{
52 public:
53 /**
54 * @brief Create a Wifi MAC queue item containing a packet and a Wifi MAC header.
55 * @param p the const packet included in the created item.
56 * @param header the Wifi MAC header included in the created item.
57 * @param stamp the timestamp to associate with the MPDU
58 */
59 WifiMpdu(Ptr<const Packet> p, const WifiMacHeader& header, Time stamp = Simulator::Now());
60
61 virtual ~WifiMpdu();
62
63 /**
64 * @return whether this is the original version of the MPDU
65 */
66 bool IsOriginal() const;
67
68 /**
69 * @return the original version of this MPDU
70 */
72
73 /**
74 * @brief Get the packet stored in this item
75 * @return the packet stored in this item.
76 */
78
79 /**
80 * @brief Get the header stored in this item
81 * @return the header stored in this item.
82 */
83 const WifiMacHeader& GetHeader() const;
84
85 /**
86 * @brief Get the header stored in this item
87 * @return the header stored in this item.
88 */
90
91 /**
92 * @brief Return the destination address present in the header
93 * @return the destination address
94 */
96
97 /**
98 * @brief Return the size of the packet stored by this item, including header
99 * size and trailer size
100 *
101 * @return the size of the packet stored by this item in bytes.
102 */
103 uint32_t GetSize() const;
104
105 /**
106 * @brief Return the size in bytes of the packet or control header or management
107 * header stored by this item.
108 *
109 * @return the size in bytes of the packet or control header or management header
110 * stored by this item
111 */
112 uint32_t GetPacketSize() const;
113
114 /**
115 * Return true if this item contains an MSDU fragment, false otherwise
116 * @return true if this item contains an MSDU fragment, false otherwise
117 */
118 bool IsFragment() const;
119
120 /**
121 * @brief Aggregate the MSDU contained in the given MPDU to this MPDU (thus
122 * constituting an A-MSDU). Note that the given MPDU cannot contain
123 * an A-MSDU. If the given MPDU is a null pointer, the effect of this
124 * call is to add only an A-MSDU subframe header, thus producing an A-MSDU
125 * containing a single MSDU.
126 * @param msdu the MPDU containing the MSDU to aggregate
127 */
129
130 /// DeaggregatedMsdus typedef
131 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>> DeaggregatedMsdus;
132 /// DeaggregatedMsdusCI typedef
133 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>>::const_iterator
135
136 /**
137 * @brief Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
138 *
139 * @return a constant iterator pointing to the first MSDU in the list of aggregated MSDUs
140 */
142 /**
143 * @brief Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
144 *
145 * @return a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs
146 */
147 DeaggregatedMsdusCI end() const;
148
149 /// Const iterator typedef
150 typedef std::list<WifiMacQueueElem>::iterator Iterator;
151
152 /**
153 * Set the queue iterator stored by this object.
154 *
155 * @param queueIt the queue iterator for this object
156 * @param tag a wifi MAC queue iterator tag (allows only WifiMacQueue to call this method)
157 */
158 void SetQueueIt(std::optional<Iterator> queueIt, WmqIteratorTag tag);
159 /**
160 * @param tag a wifi MAC queue iterator tag (allows only WifiMacQueue to call this method)
161 * @return the queue iterator stored by this object
162 */
164
165 /**
166 * Return true if this item is stored in some queue, false otherwise.
167 *
168 * @return true if this item is stored in some queue, false otherwise
169 */
170 bool IsQueued() const;
171 /**
172 * Get the AC of the queue this item is stored into. Abort if this item
173 * is not stored in a queue.
174 *
175 * @return the AC of the queue this item is stored into
176 */
177 AcIndex GetQueueAc() const;
178 /**
179 * @return the time this MPDU was constructed
180 */
181 Time GetTimestamp() const;
182 /**
183 * @return the expiry time of this MPDU
184 */
185 Time GetExpiryTime() const;
186
187 /**
188 * @return the frame retry count
189 */
190 uint32_t GetRetryCount() const;
191
192 /**
193 * Increment the frame retry count.
194 */
195 void IncrementRetryCount();
196
197 /**
198 * @brief Get the MAC protocol data unit (MPDU) corresponding to this item
199 * (i.e. a copy of the packet stored in this item wrapped with MAC
200 * header and trailer)
201 * @return the MAC protocol data unit corresponding to this item.
202 */
204
205 /**
206 * Mark this MPDU as being in flight on the given link.
207 *
208 * @param linkId the ID of the given link
209 */
210 void SetInFlight(uint8_t linkId) const;
211 /**
212 * Mark this MPDU as not being in flight on the given link.
213 *
214 * @param linkId the ID of the given link
215 */
216 void ResetInFlight(uint8_t linkId) const;
217 /**
218 * @return the set of IDs of the links on which this MPDU is currently in flight
219 */
220 std::set<uint8_t> GetInFlightLinkIds() const;
221 /**
222 * @return true if this MPDU is in flight on any link, false otherwise
223 */
224 bool IsInFlight() const;
225
226 /**
227 * Set the sequence number of this MPDU (and of the original copy, if this is an alias)
228 * to the given value. Also, record that a sequence number has been assigned to this MPDU.
229 *
230 * @param seqNo the given sequence number
231 */
232 void AssignSeqNo(uint16_t seqNo);
233 /**
234 * @return whether a sequence number has been assigned to this MPDU
235 */
236 bool HasSeqNoAssigned() const;
237 /**
238 * Record that a sequence number is no (longer) assigned to this MPDU.
239 */
240 void UnassignSeqNo();
241
242 /**
243 * Create an alias for this MPDU (which must be an original copy) for transmission
244 * on the link with the given ID. Aliases have their own copy of the MAC header and
245 * cannot be used to perform non-const operations on the frame body.
246 *
247 * @param linkId the ID of the given link
248 * @return an alias for this MPDU
249 */
250 Ptr<WifiMpdu> CreateAlias(uint8_t linkId) const;
251
252 /**
253 * @brief Print the item contents.
254 * @param os output stream in which the data should be printed.
255 */
256 virtual void Print(std::ostream& os) const;
257
258 private:
259 /**
260 * @brief Aggregate the MSDU contained in the given MPDU to this MPDU (thus
261 * constituting an A-MSDU). Note that the given MPDU cannot contain
262 * an A-MSDU.
263 * @param msdu the MPDU containing the MSDU to aggregate
264 */
266
267 /**
268 * @return the queue iterator stored by this object
269 */
270 Iterator GetQueueIt() const;
271
272 /**
273 * Private default constructor (used to construct aliases).
274 */
275 WifiMpdu() = default;
276
277 /**
278 * Information stored by both the original copy and the aliases
279 */
280 WifiMacHeader m_header; //!< Wifi MAC header associated with the packet
281
282 /**
283 * Information stored by the original copy only.
284 */
286 {
287 Ptr<const Packet> m_packet; //!< MSDU or A-MSDU contained in this queue item
288 Time m_timestamp; //!< construction time
289 DeaggregatedMsdus m_msduList; //!< list of aggregated MSDUs included in this MPDU
290 std::optional<Iterator> m_queueIt; //!< Queue iterator pointing to this MPDU, if queued
291 bool m_seqNoAssigned; //!< whether a sequence number has been assigned
292 uint32_t m_retryCount; //!< the frame retry count maintained for each MSDU, A-MSDU or MMPDU
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
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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:51
bool IsOriginal() const
Definition wifi-mpdu.cc:47
InstanceInfo m_instanceInfo
information associated with the instance type
Definition wifi-mpdu.h:307
Time GetTimestamp() const
Definition wifi-mpdu.cc:107
bool HasSeqNoAssigned() const
Definition wifi-mpdu.cc:384
Time GetExpiryTime() const
Definition wifi-mpdu.cc:331
bool IsInFlight() const
Definition wifi-mpdu.cc:364
static constexpr std::size_t ALIAS
index of an alias in the InstanceInfo variant
Definition wifi-mpdu.h:310
uint32_t GetRetryCount() const
Definition wifi-mpdu.cc:118
void ResetInFlight(uint8_t linkId) const
Mark this MPDU as not being in flight on the given link.
Definition wifi-mpdu.cc:343
void IncrementRetryCount()
Increment the frame retry count.
Definition wifi-mpdu.cc:129
WifiMacHeader m_header
Information stored by both the original copy and the aliases.
Definition wifi-mpdu.h:280
void SetInFlight(uint8_t linkId) const
Mark this MPDU as being in flight on the given link.
Definition wifi-mpdu.cc:337
Iterator GetQueueIt() const
Definition wifi-mpdu.cc:318
std::list< std::pair< Ptr< constPacket >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
Definition wifi-mpdu.h:134
const WifiMacHeader & GetHeader() const
Get the header stored in this item.
Definition wifi-mpdu.cc:153
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:198
OriginalInfo & GetOriginalInfo()
Definition wifi-mpdu.cc:79
virtual ~WifiMpdu()
Definition wifi-mpdu.cc:40
uint32_t GetSize() const
Return the size of the packet stored by this item, including header size and trailer size.
Definition wifi-mpdu.cc:177
Ptr< Packet > GetProtocolDataUnit() const
Get the MAC protocol data unit (MPDU) corresponding to this item (i.e.
Definition wifi-mpdu.cc:189
std::variant< OriginalInfo, Ptr< WifiMpdu > > InstanceInfo
Information stored by the original copy and an alias, respectively.
Definition wifi-mpdu.h:305
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:246
std::list< std::pair< Ptr< const Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Definition wifi-mpdu.h:131
void UnassignSeqNo()
Record that a sequence number is no (longer) assigned to this MPDU.
Definition wifi-mpdu.cc:390
virtual void Print(std::ostream &os) const
Print the item contents.
Definition wifi-mpdu.cc:408
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:101
DeaggregatedMsdusCI end() const
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
Definition wifi-mpdu.cc:402
DeaggregatedMsdusCI begin() const
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
Definition wifi-mpdu.cc:396
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:171
AcIndex GetQueueAc() const
Get the AC of the queue this item is stored into.
Definition wifi-mpdu.cc:325
std::list< WifiMacQueueElem >::iterator Iterator
Const iterator typedef.
Definition wifi-mpdu.h:150
Mac48Address GetDestinationAddress() const
Return the destination address present in the header.
Definition wifi-mpdu.cc:165
bool IsQueued() const
Return true if this item is stored in some queue, false otherwise.
Definition wifi-mpdu.cc:296
void SetQueueIt(std::optional< Iterator > queueIt, WmqIteratorTag tag)
Set the queue iterator stored by this object.
Definition wifi-mpdu.cc:302
bool IsFragment() const
Return true if this item contains an MSDU fragment, false otherwise.
Definition wifi-mpdu.cc:183
std::set< uint8_t > GetInFlightLinkIds() const
Definition wifi-mpdu.cc:349
Ptr< const WifiMpdu > GetOriginal() const
Definition wifi-mpdu.cc:53
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:370
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:63
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:37
WmqIteratorTag()=default
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
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
Information stored by the original copy only.
Definition wifi-mpdu.h:286
Time m_timestamp
construction time
Definition wifi-mpdu.h:288
uint32_t m_retryCount
the frame retry count maintained for each MSDU, A-MSDU or MMPDU
Definition wifi-mpdu.h:292
bool m_seqNoAssigned
whether a sequence number has been assigned
Definition wifi-mpdu.h:291
DeaggregatedMsdus m_msduList
list of aggregated MSDUs included in this MPDU
Definition wifi-mpdu.h:289
Ptr< const Packet > m_packet
MSDU or A-MSDU contained in this queue item.
Definition wifi-mpdu.h:287
std::optional< Iterator > m_queueIt
Queue iterator pointing to this MPDU, if queued.
Definition wifi-mpdu.h:290