A Discrete-Event Network Simulator
API
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 
26 #include "amsdu-subframe-header.h"
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 
38 namespace ns3
39 {
40 
48 {
49  friend class WifiMacQueue;
50  WmqIteratorTag() = default;
51 };
52 
61 class 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 
139  void Aggregate(Ptr<const WifiMpdu> msdu);
140 
142  typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>> DeaggregatedMsdus;
144  typedef std::list<std::pair<Ptr<const Packet>, AmsduSubframeHeader>>::const_iterator
146 
152  DeaggregatedMsdusCI begin() const;
158  DeaggregatedMsdusCI end() const;
159 
161  typedef std::list<WifiMacQueueElem>::iterator Iterator;
162 
169  void SetQueueIt(std::optional<Iterator> queueIt, WmqIteratorTag tag);
175 
181  bool IsQueued() const;
188  AcIndex GetQueueAc() const;
192  Time GetTimestamp() const;
196  Time GetExpiryTime() const;
197 
205 
211  void SetInFlight(uint8_t linkId) const;
217  void ResetInFlight(uint8_t linkId) const;
221  std::set<uint8_t> GetInFlightLinkIds() const;
225  bool IsInFlight() const;
226 
233  void AssignSeqNo(uint16_t seqNo);
237  bool HasSeqNoAssigned() const;
241  void UnassignSeqNo();
242 
251  Ptr<WifiMpdu> CreateAlias(uint8_t linkId) const;
252 
257  virtual void Print(std::ostream& os) const;
258 
259  private:
266  void DoAggregate(Ptr<const WifiMpdu> msdu);
267 
271  Iterator GetQueueIt() const;
272 
276  WifiMpdu() = default;
277 
282 
287  {
291  std::optional<Iterator> m_queueIt;
293  };
294 
302  const OriginalInfo& GetOriginalInfo() const;
303 
305  using InstanceInfo = std::variant<OriginalInfo, Ptr<WifiMpdu>>;
306 
308  static constexpr std::size_t ORIGINAL =
309  0;
310  static constexpr std::size_t ALIAS = 1;
311 };
312 
320 std::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
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
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
std::list< std::pair< Ptr< const Packet >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
Definition: wifi-mpdu.h:145
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