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 * \brief Get the MAC protocol data unit (MPDU) corresponding to this item
189 * (i.e. a copy of the packet stored in this item wrapped with MAC
190 * header and trailer)
191 * \return the MAC protocol data unit corresponding to this item.
192 */
194
195 /**
196 * Mark this MPDU as being in flight on the given link.
197 *
198 * \param linkId the ID of the given link
199 */
200 void SetInFlight(uint8_t linkId) const;
201 /**
202 * Mark this MPDU as not being in flight on the given link.
203 *
204 * \param linkId the ID of the given link
205 */
206 void ResetInFlight(uint8_t linkId) const;
207 /**
208 * \return the set of IDs of the links on which this MPDU is currently in flight
209 */
210 std::set<uint8_t> GetInFlightLinkIds() const;
211 /**
212 * \return true if this MPDU is in flight on any link, false otherwise
213 */
214 bool IsInFlight() const;
215
216 /**
217 * Set the sequence number of this MPDU (and of the original copy, if this is an alias)
218 * to the given value. Also, record that a sequence number has been assigned to this MPDU.
219 *
220 * \param seqNo the given sequence number
221 */
222 void AssignSeqNo(uint16_t seqNo);
223 /**
224 * \return whether a sequence number has been assigned to this MPDU
225 */
226 bool HasSeqNoAssigned() const;
227 /**
228 * Record that a sequence number is no (longer) assigned to this MPDU.
229 */
230 void UnassignSeqNo();
231
232 /**
233 * Create an alias for this MPDU (which must be an original copy) for transmission
234 * on the link with the given ID. Aliases have their own copy of the MAC header and
235 * cannot be used to perform non-const operations on the frame body.
236 *
237 * \param linkId the ID of the given link
238 * \return an alias for this MPDU
239 */
240 Ptr<WifiMpdu> CreateAlias(uint8_t linkId) const;
241
242 /**
243 * \brief Print the item contents.
244 * \param os output stream in which the data should be printed.
245 */
246 virtual void Print(std::ostream& os) const;
247
248 private:
249 /**
250 * \brief Aggregate the MSDU contained in the given MPDU to this MPDU (thus
251 * constituting an A-MSDU). Note that the given MPDU cannot contain
252 * an A-MSDU.
253 * \param msdu the MPDU containing the MSDU to aggregate
254 */
256
257 /**
258 * \return the queue iterator stored by this object
259 */
260 Iterator GetQueueIt() const;
261
262 /**
263 * Private default constructor (used to construct aliases).
264 */
265 WifiMpdu() = default;
266
267 /**
268 * Information stored by both the original copy and the aliases
269 */
270 WifiMacHeader m_header; //!< Wifi MAC header associated with the packet
271
272 /**
273 * Information stored by the original copy only.
274 */
276 {
277 Ptr<const Packet> m_packet; //!< MSDU or A-MSDU contained in this queue item
278 Time m_timestamp; //!< construction time
279 DeaggregatedMsdus m_msduList; //!< list of aggregated MSDUs included in this MPDU
280 std::optional<Iterator> m_queueIt; //!< Queue iterator pointing to this MPDU, if queued
281 bool m_seqNoAssigned; //!< whether a sequence number has been assigned
282 };
283
284 /**
285 * \return a reference to the information held by the original copy of the MPDU.
286 */
288 /**
289 * \return a const reference to the information held by the original copy of the MPDU.
290 */
291 const OriginalInfo& GetOriginalInfo() const;
292
293 /// Information stored by the original copy and an alias, respectively
294 using InstanceInfo = std::variant<OriginalInfo, Ptr<WifiMpdu>>;
295
296 InstanceInfo m_instanceInfo; //!< information associated with the instance type
297 static constexpr std::size_t ORIGINAL =
298 0; //!< index of original copy in the InstanceInfo variant
299 static constexpr std::size_t ALIAS = 1; //!< index of an alias in the InstanceInfo variant
300};
301
302/**
303 * \brief Stream insertion operator.
304 *
305 * \param os the output stream
306 * \param item the WifiMpdu
307 * \returns a reference to the stream
308 */
309std::ostream& operator<<(std::ostream& os, const WifiMpdu& item);
310
311} // namespace ns3
312
313#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:46
InstanceInfo m_instanceInfo
information associated with the instance type
Definition wifi-mpdu.h:296
Time GetTimestamp() const
Definition wifi-mpdu.cc:106
bool HasSeqNoAssigned() const
Definition wifi-mpdu.cc:347
Time GetExpiryTime() const
Definition wifi-mpdu.cc:294
bool IsInFlight() const
Definition wifi-mpdu.cc:327
static constexpr std::size_t ALIAS
index of an alias in the InstanceInfo variant
Definition wifi-mpdu.h:299
void ResetInFlight(uint8_t linkId) const
Mark this MPDU as not being in flight on the given link.
Definition wifi-mpdu.cc:306
WifiMacHeader m_header
Information stored by both the original copy and the aliases.
Definition wifi-mpdu.h:270
void SetInFlight(uint8_t linkId) const
Mark this MPDU as being in flight on the given link.
Definition wifi-mpdu.cc:300
Iterator GetQueueIt() const
Definition wifi-mpdu.cc:281
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:117
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:162
OriginalInfo & GetOriginalInfo()
Definition wifi-mpdu.cc:78
virtual ~WifiMpdu()
Definition wifi-mpdu.cc:39
uint32_t GetSize() const
Return the size of the packet stored by this item, including header size and trailer size.
Definition wifi-mpdu.cc:141
Ptr< Packet > GetProtocolDataUnit() const
Get the MAC protocol data unit (MPDU) corresponding to this item (i.e.
Definition wifi-mpdu.cc:153
std::variant< OriginalInfo, Ptr< WifiMpdu > > InstanceInfo
Information stored by the original copy and an alias, respectively.
Definition wifi-mpdu.h:294
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:209
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:353
virtual void Print(std::ostream &os) const
Print the item contents.
Definition wifi-mpdu.cc:371
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:100
DeaggregatedMsdusCI end() const
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
Definition wifi-mpdu.cc:365
DeaggregatedMsdusCI begin() const
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
Definition wifi-mpdu.cc:359
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:135
AcIndex GetQueueAc() const
Get the AC of the queue this item is stored into.
Definition wifi-mpdu.cc:288
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:129
bool IsQueued() const
Return true if this item is stored in some queue, false otherwise.
Definition wifi-mpdu.cc:259
void SetQueueIt(std::optional< Iterator > queueIt, WmqIteratorTag tag)
Set the queue iterator stored by this object.
Definition wifi-mpdu.cc:265
bool IsFragment() const
Return true if this item contains an MSDU fragment, false otherwise.
Definition wifi-mpdu.cc:147
std::set< uint8_t > GetInFlightLinkIds() const
Definition wifi-mpdu.cc:312
Ptr< const WifiMpdu > GetOriginal() const
Definition wifi-mpdu.cc:52
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:333
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:62
static constexpr std::size_t ORIGINAL
index of original copy in the InstanceInfo variant
Definition wifi-mpdu.h:297
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:276
Time m_timestamp
construction time
Definition wifi-mpdu.h:278
bool m_seqNoAssigned
whether a sequence number has been assigned
Definition wifi-mpdu.h:281
DeaggregatedMsdus m_msduList
list of aggregated MSDUs included in this MPDU
Definition wifi-mpdu.h:279
Ptr< const Packet > m_packet
MSDU or A-MSDU contained in this queue item.
Definition wifi-mpdu.h:277
std::optional< Iterator > m_queueIt
Queue iterator pointing to this MPDU, if queued.
Definition wifi-mpdu.h:280