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;
47 {
48  STA,
49  AP,
56 };
91 class QosTxop : public Txop
92 {
93 public:
95  friend class ::AmpduAggregationTest;
96  friend class ::TwoLevelAggregationTest;
97  friend class ::HeAggregationTest;
99  std::map<Mac48Address, bool> m_aMpduEnabled;
105  static TypeId GetTypeId (void);
107  QosTxop ();
108  virtual ~QosTxop ();
115  bool IsQosTxop (void) const;
128  void SetTypeOfStation (TypeOfStation type);
134  TypeOfStation GetTypeOfStation (void) const;
145  bool GetBaAgreementEstablished (Mac48Address address, uint8_t tid) const;
155  uint16_t GetBaBufferSize (Mac48Address address, uint8_t tid) const;
166  uint16_t GetBaStartingSequence (Mac48Address address, uint8_t tid) const;
168  /* dcf notifications forwarded here */
172  void NotifyAccessGranted (void);
176  void NotifyInternalCollision (void);
180  void NotifyCollision (void);
182  /* Event handlers */
192  void GotAck (void);
202  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
207  void MissedBlockAck (uint8_t nMpdus);
214  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
221  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
225  void MissedAck (void);
230  void StartNextPacket (void);
234  void EndTxNoAck (void);
238  void RestartAccessIfNeeded (void);
242  void StartAccessIfNeeded (void);
250  bool NeedBarRetransmission (void);
258  bool NeedFragmentation (void) const;
275  void SetAccessCategory (AcIndex ac);
284  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
289  void CompleteConfig (void);
297  void SetBlockAckThreshold (uint8_t threshold);
303  uint8_t GetBlockAckThreshold (void) const;
310  void SetBlockAckInactivityTimeout (uint16_t timeout);
319  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
334  bool GetAmpduExist (Mac48Address dest) const;
341  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
347  void SetAddBaResponseTimeout (Time addBaResponseTimeout);
353  Time GetAddBaResponseTimeout (void) const;
360  void SetFailedAddBaTimeout (Time failedAddBaTimeout);
366  Time GetFailedAddBaTimeout (void) const;
375  uint16_t GetNextSequenceNumberFor (const WifiMacHeader *hdr);
383  uint16_t PeekNextSequenceNumberFor (const WifiMacHeader *hdr);
416  bool aggregate = true, uint32_t ampduSize = 0,
417  Time ppduDurationLimit = Seconds (0));
433  void BaTxOk (const WifiMacHeader &hdr);
439  void BaTxFailed (const WifiMacHeader &hdr);
465 private:
475  bool SetupBlockAckIfNeeded (void);
486  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
487  uint16_t timeout, bool immediateBAck);
494  void SendBlockAckRequest (const Bar &bar);
508  void CompleteTx (void);
513  void VerifyBlockAck (void);
519  Time GetTxopRemaining (void) const;
523  void TerminateTxop (void);
530  uint32_t GetNextFragmentSize (void) const;
536  uint32_t GetFragmentSize (void) const;
542  uint32_t GetFragmentOffset (void) const;
549  bool IsLastFragment (void) const;
557  bool IsTxopFragmentation (void) const;
563  uint32_t GetTxopFragmentSize (void) const;
569  uint32_t GetNTxopFragment (void) const;
576  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
583  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
590  void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid);
597  void ResetBa (Mac48Address recipient, uint8_t tid);
599  void DoDispose (void);
600  void DoInitialize (void);
619 };
621 } //namespace ns3
623 #endif /* QOS_TXOP_H */
AcIndex m_ac
the access category
Definition: qos-txop.h:602
void MissedAck(void)
Event handler when an ACK is missed.
Definition: qos-txop.cc:793
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:202
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:1132
bool GetAmpduExist(Mac48Address dest) const
Return whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1474
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:1739
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
Definition: qos-txop.cc:1459
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: qos-txop.cc:940
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
BlockAckType m_blockAckType
the Block ACK type
Definition: qos-txop.h:607
Time m_startTxop
the start TXOP time
Definition: qos-txop.h:611
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set destination address in A-MSDU subframes.
Definition: qos-txop.cc:1393
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: qos-txop.h:612
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Definition: qos-txop.h:91
void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: qos-txop.cc:853
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: qos-txop.cc:1006
Ptr< WifiMacQueueItem > DequeuePeekedFrame(Ptr< const WifiMacQueueItem > peekedItem, WifiTxVector txVector, bool aggregate=true, uint32_t ampduSize=0, Time ppduDurationLimit=Seconds(0))
Dequeue the frame that has been previously peeked by calling PeekNextFrame or PeekNextFrameByTidAndAd...
Definition: qos-txop.cc:267
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the Block Ack inactivity timeout.
Definition: qos-txop.cc:1580
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:1655
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:137
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
Event handler when a DELBA frame is received.
Definition: qos-txop.cc:1437
virtual ~QosTxop()
Definition: qos-txop.cc:110
ns3::Time timeout
void SetAccessCategory(AcIndex ac)
Set the access category of this EDCAF.
Definition: qos-txop.cc:1370
static TypeId GetTypeId(void)
Get the type ID.
Definition: qos-txop.cc:52
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ACK mechanism.
Definition: qos-txop.cc:1587
Block Ack Request.
void DoDispose(void)
Destructor implementation.
Definition: qos-txop.cc:116
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint32_t GetTxopFragmentSize(void) const
Calculate the size of the current TXOP fragment.
Definition: qos-txop.cc:1196
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:615
control how a packet is transmitted.
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: qos-txop.cc:1333
uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: qos-txop.cc:1317
Time GetAddBaResponseTimeout(void) const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:1756
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:467
uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: qos-txop.cc:1302
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1485
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: qos-txop.cc:977
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:1762
void SendBlockAckRequest(const Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
Definition: qos-txop.cc:1540
Ptr< BlockAckManager > m_baManager
the Block ACK manager
Definition: qos-txop.h:605
static Mac48Address GetBroadcast(void)
Headers for Block ack 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:1419
void SetTypeOfStation(TypeOfStation type)
Set type of station with the given type.
Definition: qos-txop.cc:151
#define list
uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Definition: qos-txop.cc:1287
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: qos-txop.cc:164
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: qos-txop.cc:1409
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:170
bool IsQosTxop(void) const
Check for QoS TXOP.
Definition: qos-txop.cc:1775
uint32_t GetNTxopFragment(void) const
Calculate the number of TXOP fragments needed for the transmission of the current packet...
Definition: qos-txop.cc:1229
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:1749
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: first.py:37
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1713
Bar m_currentBar
the current BAR
Definition: qos-txop.h:610
void NotifyMissedCts(std::list< Ptr< WifiMacQueueItem >> mpduList)
Event handler when a CTS timeout has occurred.
Definition: qos-txop.cc:685
void CompleteMpduTx(Ptr< WifiMacQueueItem > mpdu)
Stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
Definition: qos-txop.cc:1509
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:366
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1703
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: qos-txop.cc:1145
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
Definition: qos-txop.cc:1572
uint8_t m_blockAckThreshold
the Block ACK threshold
Definition: qos-txop.h:606
Two Level Aggregation Test.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this QosTxop is associated to.
Definition: qos-txop.cc:143
uint32_t GetTxopFragmentOffset(uint32_t fragmentNumber) const
Calculate the offset for the fragment.
Definition: qos-txop.cc:1242
Ampdu Aggregation Test.
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: qos-txop.cc:675
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:176
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
Definition: qos-txop.cc:1445
void GotAck(void)
Event handler when an ACK is received.
Definition: qos-txop.cc:733
void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: qos-txop.cc:1033
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
void CompleteTx(void)
For now is typically invoked to complete transmission of a packets sent with ack policy Block Ack: th...
Definition: qos-txop.cc:1492
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:1129
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:1250
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set source address in A-MSDU subframes. ...
Definition: qos-txop.cc:1377
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:125
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit Block Ack Request should be sent upon missed Block Ack Response ...
Definition: qos-txop.h:616
TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: qos-txop.cc:158
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
Ptr< QosBlockedDestinations > m_qosBlockedDestinations
QOS blocked destinations.
Definition: qos-txop.h:604
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: qos-txop.cc:460
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:131
void CompleteConfig(void)
Complete block ACK configuration.
Definition: qos-txop.cc:1563
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: qos-txop.h:613
TracedCallback< Time, Time > m_txopTrace
TXOP trace callback.
Definition: qos-txop.h:618
void DoInitialize(void)
Initialize() implementation.
Definition: qos-txop.cc:1692
void TerminateTxop(void)
Update backoff and restart access if needed.
Definition: qos-txop.cc:1116
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: qos-txop.cc:1155
Enumeration for type of station.
Definition: qos-txop.h:46
Time m_currentPacketTimestamp
the current packet timestamp
Definition: qos-txop.h:608
bool IsTxopFragmentation(void) const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: qos-txop.cc:1181
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: qos-txop.cc:1349
Time GetFailedAddBaTimeout(void) const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:1769
uint16_t m_blockAckInactivityTimeout
the Block ACK inactivity timeout
Definition: qos-txop.h:609
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:1520
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: qos-txop.cc:591
uint32_t GetNextTxopFragmentSize(uint32_t fragmentNumber) const
Calculate the size of the next TXOP fragment.
Definition: qos-txop.cc:1268
TypeOfStation m_typeOfStation
the type of station
Definition: qos-txop.h:603
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:1723
Implements the IEEE 802.11 MAC header.
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:614
std::map< Mac48Address, bool > m_aMpduEnabled
list containing flags whether A-MPDU is enabled for a given destination address
Definition: qos-txop.h:99
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:1594
The different block ACK policies.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65