A Discrete-Event Network Simulator
API
qos-txop.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, 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  */
21 
22 #ifndef QOS_TXOP_H
23 #define QOS_TXOP_H
24 
25 #include "block-ack-manager.h"
26 #include "qos-utils.h"
27 #include "txop.h"
28 
29 #include "ns3/traced-value.h"
30 
31 #include <optional>
32 
33 namespace ns3
34 {
35 
36 class MgtAddBaResponseHeader;
37 class MgtDelBaHeader;
38 class AggregationCapableTransmissionListener;
39 class WifiTxVector;
40 class QosFrameExchangeManager;
41 class WifiTxParameters;
42 
73 class QosTxop : public Txop
74 {
75  public:
80  static TypeId GetTypeId();
81 
87  QosTxop(AcIndex ac = AC_UNDEF);
88 
89  ~QosTxop() override;
90 
91  bool IsQosTxop() const override;
92  bool HasFramesToTransmit(uint8_t linkId) override;
93  void NotifyChannelAccessed(uint8_t linkId, Time txopDuration) override;
94  void NotifyChannelReleased(uint8_t linkId) override;
95  void SetDroppedMpduCallback(DroppedMpdu callback) override;
96 
102  AcIndex GetAccessCategory() const;
103 
110 
126  uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const;
137  uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const;
148  std::pair<CtrlBAckRequestHeader, WifiMacHeader> PrepareBlockAckRequest(Mac48Address recipient,
149  uint8_t tid) const;
150 
151  /* Event handlers */
158  void GotAddBaResponse(const MgtAddBaResponseHeader& respHdr, Mac48Address recipient);
165  void GotDelBaFrame(const MgtDelBaHeader* delBaHdr, Mac48Address recipient);
173  void NotifyOriginatorAgreementNoReply(const Mac48Address& recipient, uint8_t tid);
180  void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid);
187  void ResetBa(Mac48Address recipient, uint8_t tid);
188 
195  void SetBlockAckThreshold(uint8_t threshold);
201  uint8_t GetBlockAckThreshold() const;
202 
208  void SetBlockAckInactivityTimeout(uint16_t timeout);
214  uint16_t GetBlockAckInactivityTimeout() const;
221  void CompleteMpduTx(Ptr<WifiMpdu> mpdu);
227  void SetAddBaResponseTimeout(Time addBaResponseTimeout);
240  void SetFailedAddBaTimeout(Time failedAddBaTimeout);
246  Time GetFailedAddBaTimeout() const;
247 
255  uint16_t GetNextSequenceNumberFor(const WifiMacHeader* hdr);
264  uint16_t PeekNextSequenceNumberFor(const WifiMacHeader* hdr);
281  Ptr<WifiMpdu> PeekNextMpdu(uint8_t linkId,
282  uint8_t tid = 8,
284  Ptr<const WifiMpdu> mpdu = nullptr);
304  Ptr<WifiMpdu> GetNextMpdu(uint8_t linkId,
305  Ptr<WifiMpdu> peekedItem,
306  WifiTxParameters& txParams,
307  Time availableTime,
308  bool initialFrame);
309 
316  void AssignSequenceNumber(Ptr<WifiMpdu> mpdu) const;
317 
326  uint8_t GetQosQueueSize(uint8_t tid, Mac48Address receiver) const;
327 
332  virtual std::optional<Time> GetTxopStartTime(uint8_t linkId) const;
339  virtual Time GetRemainingTxop(uint8_t linkId) const;
340 
348  void SetMuCwMin(uint16_t cwMin, uint8_t linkId);
356  void SetMuCwMax(uint16_t cwMax, uint8_t linkId);
364  void SetMuAifsn(uint8_t aifsn, uint8_t linkId);
371  void SetMuEdcaTimer(Time timer, uint8_t linkId);
377  void StartMuEdcaTimerNow(uint8_t linkId);
384  bool MuEdcaTimerRunning(uint8_t linkId) const;
392  bool EdcaDisabled(uint8_t linkId) const;
401  uint32_t GetMinCw(uint8_t linkId) const override;
410  uint32_t GetMaxCw(uint8_t linkId) const override;
419  uint8_t GetAifsn(uint8_t linkId) const override;
420 
421  protected:
428  {
430  ~QosLinkEntity() override = default;
431 
432  std::optional<Time> startTxop;
434  uint32_t muCwMin{0};
435  uint32_t muCwMax{0};
436  uint8_t muAifsn{0};
439  };
440 
441  void DoDispose() override;
442 
449  QosLinkEntity& GetLink(uint8_t linkId) const;
450 
451  private:
454 
455  std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
456 
466 
479  uint8_t m_nMaxInflights;
482 
484  typedef TracedCallback<Time /* start time */, Time /* duration */, uint8_t /* link ID*/>
486 
488 };
489 
490 } // namespace ns3
491 
492 #endif /* QOS_TXOP_H */
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
Implement the header for management frames of type Add Block Ack response.
Implement the header for management frames of type Delete Block Ack.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:74
TracedCallback< Time, Time, uint8_t > TxopTracedCallback
TracedCallback for TXOP trace typedef.
Definition: qos-txop.h:485
QosTxop(AcIndex ac=AC_UNDEF)
Constructor.
Definition: qos-txop.cc:106
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
Definition: qos-txop.cc:167
~QosTxop() override
Definition: qos-txop.cc:149
uint8_t m_blockAckThreshold
the block ack threshold (use BA mechanism if number of packets in queue reaches this value.
Definition: qos-txop.h:469
Ptr< BlockAckManager > GetBaManager()
Get the Block Ack Manager associated with this QosTxop.
Definition: qos-txop.cc:286
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:476
Ptr< WifiMpdu > PeekNextMpdu(uint8_t linkId, uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast(), Ptr< const WifiMpdu > mpdu=nullptr)
Peek the next frame to transmit on the given link to the given receiver and of the given TID from the...
Definition: qos-txop.cc:378
uint16_t PeekNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i....
Definition: qos-txop.cc:350
void SetMuCwMin(uint16_t cwMin, uint8_t linkId)
Set the minimum contention window size to use while the MU EDCA Timer is running for the given link.
Definition: qos-txop.cc:198
bool UseExplicitBarAfterMissedBlockAck() const
Return true if an explicit BlockAckRequest is sent after a missed BlockAck.
Definition: qos-txop.cc:327
bool EdcaDisabled(uint8_t linkId) const
Return true if the EDCA is disabled (the MU EDCA Timer is running and the MU AIFSN is zero) for the g...
Definition: qos-txop.cc:248
Time GetAddBaResponseTimeout() const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:775
AcIndex GetAccessCategory() const
Get the access category of this object.
Definition: qos-txop.cc:800
void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid)
Callback when ADDBA response is not received after timeout.
Definition: qos-txop.cc:740
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:292
void DoDispose() override
Destructor implementation.
Definition: qos-txop.cc:155
void SetMuCwMax(uint16_t cwMax, uint8_t linkId)
Set the maximum contention window size to use while the MU EDCA Timer is running for the given link.
Definition: qos-txop.cc:205
bool MuEdcaTimerRunning(uint8_t linkId) const
Return true if the MU EDCA Timer is running for the given link, false otherwise.
Definition: qos-txop.cc:239
void StartMuEdcaTimerNow(uint8_t linkId)
Start the MU EDCA Timer for the given link.
Definition: qos-txop.cc:226
uint8_t GetBlockAckThreshold() const
Return the current threshold for block ack mechanism.
Definition: qos-txop.cc:727
void NotifyChannelReleased(uint8_t linkId) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: qos-txop.cc:599
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:344
uint16_t GetBlockAckInactivityTimeout() const
Get the BlockAck inactivity timeout.
Definition: qos-txop.cc:734
TxopTracedCallback m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:487
virtual Time GetRemainingTxop(uint8_t linkId) const
Return the remaining duration in the current TXOP on the given link.
Definition: qos-txop.cc:636
AcIndex m_ac
the access category
Definition: qos-txop.h:467
void SetDroppedMpduCallback(DroppedMpdu callback) override
Definition: qos-txop.cc:190
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response
Definition: qos-txop.h:477
void SetMuAifsn(uint8_t aifsn, uint8_t linkId)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running for the given link.
Definition: qos-txop.cc:212
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:453
void NotifyOriginatorAgreementNoReply(const Mac48Address &recipient, uint8_t tid)
Take action upon notification of ADDBA_REQUEST frame being discarded (likely due to exceeded max retr...
Definition: qos-txop.cc:691
virtual std::optional< Time > GetTxopStartTime(uint8_t linkId) const
Definition: qos-txop.cc:591
uint8_t GetQosQueueSize(uint8_t tid, Mac48Address receiver) const
Get the value for the Queue Size subfield of the QoS Control field of a QoS data frame of the given T...
Definition: qos-txop.cc:179
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:753
Time GetFailedAddBaTimeout() const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:788
void GotAddBaResponse(const MgtAddBaResponseHeader &respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
Definition: qos-txop.cc:652
static TypeId GetTypeId()
Get the type ID.
Definition: qos-txop.cc:59
void AssignSequenceNumber(Ptr< WifiMpdu > mpdu) const
Assign a sequence number to the given MPDU, if it is not a fragment and it is not a retransmitted fra...
Definition: qos-txop.cc:566
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:781
uint16_t m_blockAckInactivityTimeout
the BlockAck inactivity timeout value (in TUs, i.e.
Definition: qos-txop.h:473
QosLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: qos-txop.cc:173
Ptr< WifiMpdu > GetNextMpdu(uint8_t linkId, Ptr< WifiMpdu > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame)
Prepare the frame to transmit on the given link starting from the MPDU that has been previously peeke...
Definition: qos-txop.cc:495
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ack mechanism.
Definition: qos-txop.cc:712
bool IsQosOldPacket(Ptr< const WifiMpdu > mpdu)
Check if the given MPDU is to be considered old according to the current starting sequence number of ...
Definition: qos-txop.cc:356
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:683
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the BlockAck inactivity timeout.
Definition: qos-txop.cc:720
uint8_t m_nMaxInflights
the maximum number of links on which an MPDU can be in-flight at the same time
Definition: qos-txop.h:479
void CompleteMpduTx(Ptr< WifiMpdu > mpdu)
Stores an MPDU (part of an A-MPDU) in block ack agreement (i.e.
Definition: qos-txop.cc:698
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:768
std::pair< CtrlBAckRequestHeader, WifiMacHeader > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:304
bool HasFramesToTransmit(uint8_t linkId) override
Check if the Txop has frames to transmit over the given link.
Definition: qos-txop.cc:333
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:298
bool IsQosTxop() const override
Check for QoS TXOP.
Definition: qos-txop.cc:794
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:475
void NotifyChannelAccessed(uint8_t linkId, Time txopDuration) override
Called by the FrameExchangeManager to notify that channel access has been granted on the given link f...
Definition: qos-txop.cc:580
void SetMuEdcaTimer(Time timer, uint8_t linkId)
Set the MU EDCA Timer for the given link.
Definition: qos-txop.cc:219
Ptr< BlockAckManager > m_baManager
the block ack manager
Definition: qos-txop.h:468
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:74
uint32_t GetMinCw() const
Return the minimum contention window size.
Definition: txop.cc:418
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
Definition: txop.cc:466
uint32_t GetMaxCw() const
Return the maximum contention window size.
Definition: txop.cc:442
a unique identifier for an interface.
Definition: type-id.h:59
Implements the IEEE 802.11 MAC header.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
@ AC_UNDEF
Total number of ACs.
Definition: qos-utils.h:87
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout