A Discrete-Event Network Simulator
API
qos-txop.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef QOS_TXOP_H
24 #define QOS_TXOP_H
25 
26 #include "ns3/traced-value.h"
27 #include "block-ack-manager.h"
28 #include "txop.h"
29 #include "qos-utils.h"
30 
31 namespace ns3 {
32 
33 class QosBlockedDestinations;
34 class MgtAddBaResponseHeader;
35 class MgtDelBaHeader;
36 class AggregationCapableTransmissionListener;
37 class WifiTxVector;
38 class QosFrameExchangeManager;
39 class WifiTxParameters;
40 
71 class QosTxop : public Txop
72 {
73 public:
78  static TypeId GetTypeId (void);
79 
85  QosTxop (AcIndex ac = AC_UNDEF);
86 
87  virtual ~QosTxop ();
88 
89  bool IsQosTxop (void) const override;
90  bool HasFramesToTransmit (void) override;
91  void NotifyChannelAccessed (Time txopDuration) override;
92  void NotifyChannelReleased (void) override;
93  void SetDroppedMpduCallback (DroppedMpdu callback) override;
94 
101 
107  AcIndex GetAccessCategory (void) const;
108 
114  bool UseExplicitBarAfterMissedBlockAck (void) const;
115 
131  bool GetBaAgreementEstablished (Mac48Address address, uint8_t tid) const;
141  uint16_t GetBaBufferSize (Mac48Address address, uint8_t tid) const;
152  uint16_t GetBaStartingSequence (Mac48Address address, uint8_t tid) const;
161  BlockAckReqType GetBlockAckReqType (Mac48Address recipient, uint8_t tid) const;
170  BlockAckType GetBlockAckType (Mac48Address recipient, uint8_t tid) const;
181  Ptr<const WifiMacQueueItem> PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const;
189  void ScheduleBar (Ptr<const WifiMacQueueItem> bar, bool skipIfNoDataQueued = false);
190 
191  /* Event handlers */
198  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
205  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
212  void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid);
219  void ResetBa (Mac48Address recipient, uint8_t tid);
220 
228  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
229 
236  void SetBlockAckThreshold (uint8_t threshold);
242  uint8_t GetBlockAckThreshold (void) const;
243 
249  void SetBlockAckInactivityTimeout (uint16_t timeout);
255  uint16_t GetBlockAckInactivityTimeout (void) const;
268  void SetAddBaResponseTimeout (Time addBaResponseTimeout);
274  Time GetAddBaResponseTimeout (void) const;
281  void SetFailedAddBaTimeout (Time failedAddBaTimeout);
287  Time GetFailedAddBaTimeout (void) const;
288 
296  uint16_t GetNextSequenceNumberFor (const WifiMacHeader *hdr);
304  uint16_t PeekNextSequenceNumberFor (const WifiMacHeader *hdr);
319  Ptr<const WifiMacQueueItem> PeekNextMpdu (uint8_t tid = 8,
321  Ptr<const WifiMacQueueItem> item = nullptr);
341  Time availableTime, bool initialFrame);
342 
350 
359  uint8_t GetQosQueueSize (uint8_t tid, Mac48Address receiver) const;
360 
366  virtual bool IsTxopStarted (void) const;
372  virtual Time GetRemainingTxop (void) const;
373 
380  void SetMuCwMin (uint16_t cwMin);
387  void SetMuCwMax (uint16_t cwMax);
394  void SetMuAifsn (uint8_t aifsn);
400  void SetMuEdcaTimer (Time timer);
404  void StartMuEdcaTimerNow (void);
410  bool MuEdcaTimerRunning (void) const;
417  bool EdcaDisabled (void) const;
425  uint32_t GetMinCw (void) const override;
433  uint32_t GetMaxCw (void) const override;
441  uint8_t GetAifsn (void) const override;
442 
443 protected:
444  void DoDispose (void) override;
445 
446 private:
449 
450  void DoInitialize (void) override;
451 
461 
475 
476  uint32_t m_muCwMin;
477  uint32_t m_muCwMax;
478  uint8_t m_muAifsn;
481 
483 };
484 
485 } //namespace ns3
486 
487 #endif /* QOS_TXOP_H */
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1150
Implement the header for management frames of type Delete Block Ack.
Definition: mgt-headers.h:1271
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:72
Time m_muEdcaTimer
the MU EDCA Timer
Definition: qos-txop.h:479
QosTxop(AcIndex ac=AC_UNDEF)
Constructor.
Definition: qos-txop.cc:93
uint32_t m_muCwMax
the MU CW maximum
Definition: qos-txop.h:477
uint32_t m_muCwMin
the MU CW minimum
Definition: qos-txop.h:476
uint8_t m_blockAckThreshold
the block ack threshold (use BA mechanism if number of packets in queue reaches this value.
Definition: qos-txop.h:466
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:482
virtual bool IsTxopStarted(void) const
Return true if a TXOP has started.
Definition: qos-txop.cc:544
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:165
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:473
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:325
void SetQosFrameExchangeManager(const Ptr< QosFrameExchangeManager > qosFem)
Set the Frame Exchange Manager associated with this QoS STA.
Definition: qos-txop.cc:143
bool IsQosTxop(void) const override
Check for QoS TXOP.
Definition: qos-txop.cc:739
void DoInitialize(void) override
Initialize() implementation.
Definition: qos-txop.cc:673
Time m_startTxop
the start TXOP time
Definition: qos-txop.h:470
void NotifyChannelAccessed(Time txopDuration) override
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
Definition: qos-txop.cc:533
void NotifyChannelReleased(void) override
Called by the FrameExchangeManager to notify the completion of the transmissions.
Definition: qos-txop.cc:551
void AssignSequenceNumber(Ptr< WifiMacQueueItem > 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:509
void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid)
Callback when ADDBA response is not received after timeout.
Definition: qos-txop.cc:681
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
Definition: qos-txop.cc:179
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:255
uint8_t m_muAifsn
the MU AIFSN
Definition: qos-txop.h:478
Time m_txopDuration
the duration of a TXOP
Definition: qos-txop.h:471
void DoDispose(void) override
Destructor implementation.
Definition: qos-txop.cc:119
bool HasFramesToTransmit(void) override
Check if the Txop has frames to transmit.
Definition: qos-txop.cc:301
virtual Time GetRemainingTxop(void) const
Return the remaining duration in the current TXOP.
Definition: qos-txop.cc:565
virtual ~QosTxop()
Definition: qos-txop.cc:113
bool IsQosOldPacket(Ptr< const WifiMacQueueItem > mpdu)
Check if the given MPDU is to be considered old according to the current starting sequence number of ...
Definition: qos-txop.cc:331
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ack mechanism.
Definition: qos-txop.cc:660
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:319
AcIndex m_ac
the access category
Definition: qos-txop.h:462
bool MuEdcaTimerRunning(void) const
Return true if the MU EDCA Timer is running, false otherwise.
Definition: qos-txop.cc:198
void SetDroppedMpduCallback(DroppedMpdu callback) override
Definition: qos-txop.cc:150
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response
Definition: qos-txop.h:474
Time GetFailedAddBaTimeout(void) const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:733
void CompleteMpduTx(Ptr< WifiMacQueueItem > mpdu)
Stores an MPDU (part of an A-MPDU) in block ack agreement (i.e.
Definition: qos-txop.cc:634
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:448
Ptr< const WifiMacQueueItem > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:267
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:133
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:249
uint32_t GetMinCw(void) const override
Return the minimum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:211
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:698
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: qos-txop.cc:579
Time GetAddBaResponseTimeout(void) const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:720
void StartMuEdcaTimerNow(void)
Start the MU EDCA Timer.
Definition: qos-txop.cc:186
BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:527
uint8_t GetAifsn(void) const override
Return the number of slots that make up an AIFS according to the EDCA Parameter Set or the MU EDCA Pa...
Definition: qos-txop.cc:233
Ptr< WifiMacQueueItem > GetNextMpdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame)
Prepare the frame to transmit starting from the MPDU that has been previously peeked by calling PeekN...
Definition: qos-txop.cc:443
uint16_t GetBlockAckInactivityTimeout(void) const
Get the BlockAck inactivity timeout.
Definition: qos-txop.cc:667
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
Definition: qos-txop.cc:243
bool UseExplicitBarAfterMissedBlockAck(void) const
Return true if an explicit BlockAckRequest is sent after a missed BlockAck.
Definition: qos-txop.cc:295
bool EdcaDisabled(void) const
Return true if the EDCA is disabled (the MU EDCA Timer is running and the MU AIFSN is zero),...
Definition: qos-txop.cc:205
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:726
uint16_t m_blockAckInactivityTimeout
the BlockAck inactivity timeout value (in TUs, i.e.
Definition: qos-txop.h:469
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
Definition: qos-txop.cc:172
AcIndex GetAccessCategory(void) const
Get the access category of this object.
Definition: qos-txop.cc:745
uint32_t GetMaxCw(void) const override
Return the maximum contention window size from the EDCA Parameter Set or the MU EDCA Parameter Set,...
Definition: qos-txop.cc:222
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
Definition: qos-txop.cc:591
Time m_muEdcaTimerStartTime
last start time of the MU EDCA Timer
Definition: qos-txop.h:480
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ack mechanism.
Definition: qos-txop.cc:645
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:626
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the BlockAck inactivity timeout.
Definition: qos-txop.cc:653
BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:521
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:713
static TypeId GetTypeId(void)
Get the type ID.
Definition: qos-txop.cc:53
Ptr< QosFrameExchangeManager > m_qosFem
the QoS Frame Exchange Manager
Definition: qos-txop.h:463
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:261
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:158
Ptr< const WifiMacQueueItem > PeekNextMpdu(uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast(), Ptr< const WifiMacQueueItem > item=nullptr)
Peek the next frame to transmit to the given receiver and of the given TID from the EDCA queue.
Definition: qos-txop.cc:357
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
the QoS blocked destinations
Definition: qos-txop.h:464
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:472
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
Definition: qos-txop.cc:289
Ptr< BlockAckManager > m_baManager
the block ack manager
Definition: qos-txop.h:465
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Forward calls to a chain of Callback.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65
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:71
@ AC_UNDEF
Total number of ACs.
Definition: qos-utils.h:85
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout
The different BlockAckRequest variants.
The different BlockAck variants.