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 namespace ns3
32 {
33 
34 class QosBlockedDestinations;
35 class MgtAddBaResponseHeader;
36 class MgtDelBaHeader;
37 class AggregationCapableTransmissionListener;
38 class WifiTxVector;
39 class QosFrameExchangeManager;
40 class WifiTxParameters;
41 
72 class QosTxop : public Txop
73 {
74  public:
79  static TypeId GetTypeId();
80 
86  QosTxop(AcIndex ac = AC_UNDEF);
87 
88  ~QosTxop() override;
89 
90  bool IsQosTxop() const override;
91  bool HasFramesToTransmit(uint8_t linkId) override;
92  void NotifyChannelAccessed(uint8_t linkId, Time txopDuration) override;
93  void NotifyChannelReleased(uint8_t linkId) override;
94  void SetDroppedMpduCallback(DroppedMpdu callback) override;
95 
101  AcIndex GetAccessCategory() const;
102 
109 
125  uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const;
136  uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const;
147  Ptr<WifiMpdu> PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const;
148 
149  /* Event handlers */
156  void GotAddBaResponse(const MgtAddBaResponseHeader& respHdr, Mac48Address recipient);
163  void GotDelBaFrame(const MgtDelBaHeader* delBaHdr, Mac48Address recipient);
171  void NotifyOriginatorAgreementNoReply(const Mac48Address& recipient, uint8_t tid);
178  void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid);
185  void ResetBa(Mac48Address recipient, uint8_t tid);
186 
193  void SetBlockAckThreshold(uint8_t threshold);
199  uint8_t GetBlockAckThreshold() const;
200 
206  void SetBlockAckInactivityTimeout(uint16_t timeout);
212  uint16_t GetBlockAckInactivityTimeout() const;
219  void CompleteMpduTx(Ptr<WifiMpdu> mpdu);
225  void SetAddBaResponseTimeout(Time addBaResponseTimeout);
238  void SetFailedAddBaTimeout(Time failedAddBaTimeout);
244  Time GetFailedAddBaTimeout() const;
245 
253  uint16_t GetNextSequenceNumberFor(const WifiMacHeader* hdr);
262  uint16_t PeekNextSequenceNumberFor(const WifiMacHeader* hdr);
279  Ptr<WifiMpdu> PeekNextMpdu(uint8_t linkId,
280  uint8_t tid = 8,
282  Ptr<const WifiMpdu> mpdu = nullptr);
302  Ptr<WifiMpdu> GetNextMpdu(uint8_t linkId,
303  Ptr<WifiMpdu> peekedItem,
304  WifiTxParameters& txParams,
305  Time availableTime,
306  bool initialFrame);
307 
314  void AssignSequenceNumber(Ptr<WifiMpdu> mpdu) const;
315 
324  uint8_t GetQosQueueSize(uint8_t tid, Mac48Address receiver) const;
325 
332  virtual bool IsTxopStarted(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 
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 
480  uint8_t m_nMaxInflights;
483 
485  typedef TracedCallback<Time /* start time */, Time /* duration */, uint8_t /* link ID*/>
487 
489 };
490 
491 } // namespace ns3
492 
493 #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.
Definition: mgt-headers.h:1642
Implement the header for management frames of type Delete Block Ack.
Definition: mgt-headers.h:1761
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:73
TracedCallback< Time, Time, uint8_t > TxopTracedCallback
TracedCallback for TXOP trace typedef.
Definition: qos-txop.h:486
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:142
~QosTxop() override
Definition: qos-txop.cc:123
uint8_t m_blockAckThreshold
the block ack threshold (use BA mechanism if number of packets in queue reaches this value.
Definition: qos-txop.h:470
Ptr< BlockAckManager > GetBaManager()
Get the Block Ack Manager associated with this QosTxop.
Definition: qos-txop.cc:261
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:477
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:359
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:327
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:173
bool UseExplicitBarAfterMissedBlockAck() const
Return true if an explicit BlockAckRequest is sent after a missed BlockAck.
Definition: qos-txop.cc:304
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:223
Time GetAddBaResponseTimeout() const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:741
AcIndex GetAccessCategory() const
Get the access category of this object.
Definition: qos-txop.cc:766
void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid)
Callback when ADDBA response is not received after timeout.
Definition: qos-txop.cc:706
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:267
void DoDispose() override
Destructor implementation.
Definition: qos-txop.cc:129
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:180
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:214
void StartMuEdcaTimerNow(uint8_t linkId)
Start the MU EDCA Timer for the given link.
Definition: qos-txop.cc:201
uint8_t GetBlockAckThreshold() const
Return the current threshold for block ack mechanism.
Definition: qos-txop.cc:693
void NotifyChannelReleased(uint8_t linkId) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: qos-txop.cc:576
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:321
uint16_t GetBlockAckInactivityTimeout() const
Get the BlockAck inactivity timeout.
Definition: qos-txop.cc:700
TxopTracedCallback m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:488
virtual Time GetRemainingTxop(uint8_t linkId) const
Return the remaining duration in the current TXOP on the given link.
Definition: qos-txop.cc:591
AcIndex m_ac
the access category
Definition: qos-txop.h:467
void SetDroppedMpduCallback(DroppedMpdu callback) override
Definition: qos-txop.cc:165
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response
Definition: qos-txop.h:478
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:187
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:650
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:154
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:719
Time GetFailedAddBaTimeout() const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:754
void GotAddBaResponse(const MgtAddBaResponseHeader &respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
Definition: qos-txop.cc:607
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:543
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:747
uint16_t m_blockAckInactivityTimeout
the BlockAck inactivity timeout value (in TUs, i.e.
Definition: qos-txop.h:474
QosLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: qos-txop.cc:148
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:474
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ack mechanism.
Definition: qos-txop.cc:678
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:333
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:642
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the BlockAck inactivity timeout.
Definition: qos-txop.cc:686
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:480
void CompleteMpduTx(Ptr< WifiMpdu > mpdu)
Stores an MPDU (part of an A-MPDU) in block ack agreement (i.e.
Definition: qos-txop.cc:664
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:734
bool HasFramesToTransmit(uint8_t linkId) override
Check if the Txop has frames to transmit over the given link.
Definition: qos-txop.cc:310
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:273
bool IsQosTxop() const override
Check for QoS TXOP.
Definition: qos-txop.cc:760
Ptr< WifiMpdu > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:279
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
the QoS blocked destinations
Definition: qos-txop.h:468
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:476
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:557
void SetMuEdcaTimer(Time timer, uint8_t linkId)
Set the MU EDCA Timer for the given link.
Definition: qos-txop.cc:194
Ptr< BlockAckManager > m_baManager
the block ack manager
Definition: qos-txop.h:469
virtual bool IsTxopStarted(uint8_t linkId) const
Return true if a TXOP has started on the given link.
Definition: qos-txop.cc:568
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:71
uint32_t GetMinCw() const
Return the minimum contention window size.
Definition: txop.cc:404
uint8_t GetAifsn() const
Return the number of slots that make up an AIFS.
Definition: txop.cc:450
uint32_t GetMaxCw() const
Return the maximum contention window size.
Definition: txop.cc:427
a unique identifier for an interface.
Definition: type-id.h:60
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:72
@ AC_UNDEF
Total number of ACs.
Definition: qos-utils.h:86
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout