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
48{
49 friend class WifiMacQueue;
50 WmqIteratorTag() = default;
51};
52
61class WifiMpdu : public SimpleRefCount<WifiMpdu>
62{
63 public:
70 WifiMpdu(Ptr<const Packet> p, const WifiMacHeader& header, Time stamp = Simulator::Now());
71
72 virtual ~WifiMpdu();
73
77 bool IsOriginal() const;
78
83
89
94 const WifiMacHeader& GetHeader() const;
95
101
107
114 uint32_t GetSize() const;
115
123 uint32_t GetPacketSize() const;
124
129 bool IsFragment() const;
130
138
140 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>> DeaggregatedMsdus;
142 typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>>::const_iterator
144
156 DeaggregatedMsdusCI end() const;
157
159 typedef std::list<WifiMacQueueElem>::iterator Iterator;
160
167 void SetQueueIt(std::optional<Iterator> queueIt, WmqIteratorTag tag);
173
179 bool IsQueued() const;
186 AcIndex GetQueueAc() const;
190 Time GetTimestamp() const;
194 Time GetExpiryTime() const;
195
203
209 void SetInFlight(uint8_t linkId) const;
215 void ResetInFlight(uint8_t linkId) const;
219 std::set<uint8_t> GetInFlightLinkIds() const;
223 bool IsInFlight() const;
224
231 void AssignSeqNo(uint16_t seqNo);
235 bool HasSeqNoAssigned() const;
239 void UnassignSeqNo();
240
249 Ptr<WifiMpdu> CreateAlias(uint8_t linkId) const;
250
255 virtual void Print(std::ostream& os) const;
256
257 private:
265
269 Iterator GetQueueIt() const;
270
274 WifiMpdu() = default;
275
280
285 {
289 std::optional<Iterator> m_queueIt;
291 };
292
300 const OriginalInfo& GetOriginalInfo() const;
301
303 using InstanceInfo = std::variant<OriginalInfo, Ptr<WifiMpdu>>;
304
306 static constexpr std::size_t ORIGINAL =
307 0;
308 static constexpr std::size_t ALIAS = 1;
309};
310
318std::ostream& operator<<(std::ostream& os, const WifiMpdu& item);
319
320} // namespace ns3
321
322#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:78
A template-based reference counting class.
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
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:305
Time GetTimestamp() const
Definition: wifi-mpdu.cc:119
bool HasSeqNoAssigned() const
Definition: wifi-mpdu.cc:351
Time GetExpiryTime() const
Definition: wifi-mpdu.cc:298
bool IsInFlight() const
Definition: wifi-mpdu.cc:331
static constexpr std::size_t ALIAS
index of an alias in the InstanceInfo variant
Definition: wifi-mpdu.h:308
void ResetInFlight(uint8_t linkId) const
Mark this MPDU as not being in flight on the given link.
Definition: wifi-mpdu.cc:310
WifiMacHeader m_header
Information stored by both the original copy and the aliases.
Definition: wifi-mpdu.h:279
void SetInFlight(uint8_t linkId) const
Mark this MPDU as being in flight on the given link.
Definition: wifi-mpdu.cc:304
Iterator GetQueueIt() const
Definition: wifi-mpdu.cc:285
std::list< std::pair< Ptr< constPacket >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
Definition: wifi-mpdu.h:143
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:303
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:213
std::list< std::pair< Ptr< const Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Definition: wifi-mpdu.h:140
void UnassignSeqNo()
Record that a sequence number is no (longer) assigned to this MPDU.
Definition: wifi-mpdu.cc:357
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: wifi-mpdu.cc:375
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:369
DeaggregatedMsdusCI begin() const
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
Definition: wifi-mpdu.cc:363
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:292
std::list< WifiMacQueueElem >::iterator Iterator
Const iterator typedef.
Definition: wifi-mpdu.h:159
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:263
void SetQueueIt(std::optional< Iterator > queueIt, WmqIteratorTag tag)
Set the queue iterator stored by this object.
Definition: wifi-mpdu.cc:269
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:316
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:337
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:306
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:72
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:129
Information stored by the original copy only.
Definition: wifi-mpdu.h:285
Time m_timestamp
construction time
Definition: wifi-mpdu.h:287
bool m_seqNoAssigned
whether a sequence number has been assigned
Definition: wifi-mpdu.h:290
DeaggregatedMsdus m_msduList
list of aggregated MSDUs included in this MPDU
Definition: wifi-mpdu.h:288
Ptr< const Packet > m_packet
MSDU or A-MSDU contained in this queue item.
Definition: wifi-mpdu.h:286
std::optional< Iterator > m_queueIt
Queue iterator pointing to this MPDU, if queued.
Definition: wifi-mpdu.h:289