A Discrete-Event Network Simulator
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
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  */
23 #ifndef QOS_TXOP_H
24 #define QOS_TXOP_H
26 #include "ns3/traced-value.h"
27 #include "block-ack-manager.h"
28 #include "txop.h"
29 #include "qos-utils.h"
33 class HeAggregationTest;
35 namespace ns3 {
37 class QosBlockedDestinations;
38 class MgtAddBaResponseHeader;
39 class MgtDelBaHeader;
40 class AggregationCapableTransmissionListener;
41 class WifiTxVector;
42 class WifiAckPolicySelector;
48 {
49  STA,
50  AP,
57 };
92 class QosTxop : public Txop
93 {
94 public:
96  friend class ::AmpduAggregationTest;
98  friend class ::TwoLevelAggregationTest;
100  friend class ::HeAggregationTest;
102  std::map<Mac48Address, bool> m_aMpduEnabled;
108  static TypeId GetTypeId (void);
110  QosTxop ();
111  virtual ~QosTxop ();
113  // Overridden from Txop
114  bool IsQosTxop (void) const;
116  virtual bool HasFramesToTransmit (void);
117  void NotifyAccessGranted (void);
118  void NotifyInternalCollision (void);
119  void GotAck (void);
120  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient,
121  double rxSnr, double dataSnr, WifiTxVector dataTxVector);
122  void MissedBlockAck (uint8_t nMpdus);
123  void MissedAck (void);
124  void StartNextPacket (void);
125  void EndTxNoAck (void);
126  void RestartAccessIfNeeded (void);
127  void StartAccessIfNeeded (void);
128  Time GetTxopRemaining (void) const;
129  bool NeedFragmentation (void) const;
149  void SetTypeOfStation (TypeOfStation type);
155  TypeOfStation GetTypeOfStation (void) const;
166  bool GetBaAgreementEstablished (Mac48Address address, uint8_t tid) const;
176  uint16_t GetBaBufferSize (Mac48Address address, uint8_t tid) const;
187  uint16_t GetBaStartingSequence (Mac48Address address, uint8_t tid) const;
197  Ptr<const WifiMacQueueItem> PrepareBlockAckRequest (Mac48Address recipient, uint8_t tid) const;
205  void ScheduleBar (Ptr<const WifiMacQueueItem> bar, bool skipIfNoDataQueued = false);
207  /* Event handlers */
221  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
228  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
236  bool NeedBarRetransmission (void);
243  void SetAccessCategory (AcIndex ac);
252  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
257  void CompleteConfig (void);
265  void SetBlockAckThreshold (uint8_t threshold);
271  uint8_t GetBlockAckThreshold (void) const;
278  void SetBlockAckInactivityTimeout (uint16_t timeout);
287  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
301  bool GetAmpduExist (Mac48Address dest) const;
308  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
314  void SetAddBaResponseTimeout (Time addBaResponseTimeout);
320  Time GetAddBaResponseTimeout (void) const;
327  void SetFailedAddBaTimeout (Time failedAddBaTimeout);
333  Time GetFailedAddBaTimeout (void) const;
342  uint16_t GetNextSequenceNumberFor (const WifiMacHeader *hdr);
350  uint16_t PeekNextSequenceNumberFor (const WifiMacHeader *hdr);
384  bool aggregate = true, uint32_t ampduSize = 0,
385  Time ppduDurationLimit = Time::Min ());
409  void BaTxOk (const WifiMacHeader &hdr);
415  void BaTxFailed (const WifiMacHeader &hdr);
441 private:
445  // Overridden from Txop
446  void DoDispose (void);
447  void DoInitialize (void);
448  void TerminateTxop (void);
449  uint32_t GetNextFragmentSize (void) const;
450  uint32_t GetFragmentSize (void) const;
451  uint32_t GetFragmentOffset (void) const;
452  bool IsLastFragment (void) const;
460  bool SetupBlockAckIfNeeded (void);
471  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
472  uint16_t timeout, bool immediateBAck);
489  bool IsTxopFragmentation (void) const;
495  uint32_t GetTxopFragmentSize (void) const;
501  uint32_t GetNTxopFragment (void) const;
508  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
515  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
522  void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid);
529  void ResetBa (Mac48Address recipient, uint8_t tid);
550 };
552 } //namespace ns3
554 #endif /* QOS_TXOP_H */
AcIndex m_ac
the access category
Definition: qos-txop.h:531
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
Definition: qos-txop.cc:167
void MissedAck(void)
Event handler when an Ack is missed.
Definition: qos-txop.cc:818
Ptr< const WifiMacQueueItem > PeekNextFrame(uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast())
Peek the next frame to transmit to the given receiver and of the given TID from the block ack manager...
Definition: qos-txop.cc:253
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time GetTxopRemaining(void) const
Return the remaining duration in the current TXOP.
Definition: qos-txop.cc:1160
bool GetAmpduExist(Mac48Address dest) const
Return whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1501
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:1722
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: qos-txop.cc:987
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
BlockAckType m_blockAckType
the BlockAck type
Definition: qos-txop.h:539
static Time Min()
Minimum representable Time.
Definition: nstime.h:271
Time m_startTxop
the start TXOP time
Definition: qos-txop.h:542
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set destination address in A-MSDU subframes.
Definition: qos-txop.cc:1421
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: qos-txop.h:543
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:92
void MissedBlockAck(uint8_t nMpdus)
Event handler when a BlockAck timeout has occurred.
Definition: qos-txop.cc:876
bool NeedBarRetransmission(void)
Check if BlockAckRequest should be re-transmitted.
Definition: qos-txop.cc:1052
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the BlockAck inactivity timeout.
Definition: qos-txop.cc:1567
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
Sends DELBA frame to cancel a block ack agreement with STA addressed by addr for TID tid...
Definition: qos-txop.cc:1642
Ptr< WifiAckPolicySelector > GetAckPolicySelector(void) const
Return the ack policy selector.
Definition: qos-txop.cc:188
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:140
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:1480
virtual ~QosTxop()
Definition: qos-txop.cc:112
ns3::Time timeout
void SetAccessCategory(AcIndex ac)
Set the access category of this EDCAF.
Definition: qos-txop.cc:1398
static TypeId GetTypeId(void)
Get the type ID.
Definition: qos-txop.cc:54
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ack mechanism.
Definition: qos-txop.cc:1574
void DoDispose(void)
Destructor implementation.
Definition: qos-txop.cc:118
uint32_t GetTxopFragmentSize(void) const
Calculate the size of the current TXOP fragment.
Definition: qos-txop.cc:1224
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:546
control how a packet is transmitted.
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: qos-txop.cc:1361
uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: qos-txop.cc:1345
Time GetAddBaResponseTimeout(void) const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:1744
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, double dataSnr, WifiTxVector dataTxVector)
Event handler when a BlockAck is received.
Definition: qos-txop.cc:1488
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:443
uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: qos-txop.cc:1330
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1512
void StartAccessIfNeeded(void)
Request access from Txop if needed.
Definition: qos-txop.cc:1023
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:1750
Ptr< BlockAckManager > m_baManager
the block ack manager
Definition: qos-txop.h:535
static Mac48Address GetBroadcast(void)
Headers for BlockAck response.
Definition: ctrl-headers.h:193
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
Event handler when an ADDBA response is received.
Definition: qos-txop.cc:1446
void SetTypeOfStation(TypeOfStation type)
Set type of station with the given type.
Definition: qos-txop.cc:194
#define list
uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Definition: qos-txop.cc:1315
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:215
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: qos-txop.cc:1437
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:221
bool IsQosTxop(void) const
Check for QoS TXOP.
Definition: qos-txop.cc:1763
uint32_t GetNTxopFragment(void) const
Calculate the number of TXOP fragments needed for the transmission of the current packet...
Definition: qos-txop.cc:1257
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:1737
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: first.py:44
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1698
void NotifyMissedCts(std::list< Ptr< WifiMacQueueItem >> mpduList)
Event handler when a CTS timeout has occurred.
Definition: qos-txop.cc:712
void CompleteMpduTx(Ptr< WifiMacQueueItem > mpdu)
Stores an MPDU (part of an A-MPDU) in block ack agreement (i.e.
Definition: qos-txop.cc:1519
an EUI-48 address
Definition: mac48-address.h:43
MacLowTransmissionParameters GetTransmissionParameters(Ptr< const WifiMacQueueItem > frame) const
Compute the MacLow transmission parameters for the given frame.
Definition: qos-txop.cc:419
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1688
void EndTxNoAck(void)
Event handler when a transmission that does not require an Ack has completed.
Definition: qos-txop.cc:1173
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ack mechanism.
Definition: qos-txop.cc:1559
void UpdateCurrentPacket(Ptr< WifiMacQueueItem > mpdu)
Update the current packet this QosTxop is trying to transmit.
Definition: qos-txop.cc:493
uint8_t m_blockAckThreshold
the block ack threshold (use BA mechanism if number of packets in queue reaches this value...
Definition: qos-txop.h:536
Two Level Aggregation Test.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this Txop is associated to.
Definition: qos-txop.cc:173
uint32_t GetTxopFragmentOffset(uint32_t fragmentNumber) const
Calculate the offset for the fragment.
Definition: qos-txop.cc:1270
Ptr< WifiAckPolicySelector > m_ackPolicySelector
the ack policy selector
Definition: qos-txop.h:533
Ampdu Aggregation Test.
Ptr< WifiMacQueueItem > DequeuePeekedFrame(Ptr< const WifiMacQueueItem > peekedItem, WifiTxVector txVector, bool aggregate=true, uint32_t ampduSize=0, Time ppduDurationLimit=Time::Min())
Dequeue the frame that has been previously peeked by calling PeekNextFrame.
Definition: qos-txop.cc:318
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:227
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Definition: qos-txop.cc:207
void GotAck(void)
Event handler when an Ack is received.
Definition: qos-txop.cc:758
void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: qos-txop.cc:1075
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1135
Implement the header for management frames of type Delete Block Ack.
Definition: mgt-headers.h:1256
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set source address in A-MSDU subframes. ...
Definition: qos-txop.cc:1405
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:128
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit BlockAckRequest should be sent upon missed BlockAck Response ...
Definition: qos-txop.h:547
TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: qos-txop.cc:201
Ptr< const WifiMacQueueItem > PrepareBlockAckRequest(Mac48Address recipient, uint8_t tid) const
Definition: qos-txop.cc:146
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
the QoS blocked destinations
Definition: qos-txop.h:534
void NotifyAccessGranted(void)
Notify the Txop that access has been granted.
Definition: qos-txop.cc:502
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:134
void CompleteConfig(void)
Complete block ack configuration.
Definition: qos-txop.cc:1550
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: qos-txop.h:544
void SetAckPolicySelector(Ptr< WifiAckPolicySelector > ackSelector)
Set the ack policy selector.
Definition: qos-txop.cc:181
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:549
void DoInitialize(void)
Initialize() implementation.
Definition: qos-txop.cc:1679
void TerminateTxop(void)
Update backoff and restart access if needed.
Definition: qos-txop.cc:1147
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: qos-txop.cc:1183
Enumeration for type of station.
Definition: qos-txop.h:47
Time m_currentPacketTimestamp
the current packet timestamp
Definition: qos-txop.h:540
bool IsTxopFragmentation(void) const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: qos-txop.cc:1209
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: qos-txop.cc:1377
Time GetFailedAddBaTimeout(void) const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:1757
uint16_t m_blockAckInactivityTimeout
the BlockAck inactivity timeout value (in TUs, i.e.
Definition: qos-txop.h:541
bool SetupBlockAckIfNeeded(void)
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
Definition: qos-txop.cc:1530
void NotifyInternalCollision(void)
Notify the Txop that internal collision has occurred.
Definition: qos-txop.cc:630
uint32_t GetNextTxopFragmentSize(uint32_t fragmentNumber) const
Calculate the size of the next TXOP fragment.
Definition: qos-txop.cc:1296
TypeOfStation m_typeOfStation
the type of station
Definition: qos-txop.h:532
a unique identifier for an interface.
Definition: type-id.h:58
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:38
void AddBaResponseTimeout(Mac48Address recipient, uint8_t tid)
Callback when ADDBA response is not received after timeout.
Definition: qos-txop.cc:1708
Implements the IEEE 802.11 MAC header.
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:545
std::map< Mac48Address, bool > m_aMpduEnabled
list containing flags whether A-MPDU is enabled for a given destination address
Definition: qos-txop.h:102
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBA Request to establish a block ack agreement with STA addressed by recipient for TID tid...
Definition: qos-txop.cc:1581
The different block ack policies.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:66