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 ();
118  bool IsQosTxop (void) const;
143  void SetTypeOfStation (TypeOfStation type);
149  TypeOfStation GetTypeOfStation (void) const;
155  virtual bool HasFramesToTransmit (void);
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  /* dcf notifications forwarded here */
211  void NotifyAccessGranted (void);
215  void NotifyInternalCollision (void);
217  /* Event handlers */
227  void GotAck (void);
237  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr);
242  void MissedBlockAck (uint8_t nMpdus);
249  void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
256  void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient);
260  void MissedAck (void);
265  void StartNextPacket (void);
269  void EndTxNoAck (void);
273  void RestartAccessIfNeeded (void);
277  void StartAccessIfNeeded (void);
284  Time GetTxopRemaining (void) const;
292  bool NeedBarRetransmission (void);
300  bool NeedFragmentation (void) const;
317  void SetAccessCategory (AcIndex ac);
326  void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr);
331  void CompleteConfig (void);
339  void SetBlockAckThreshold (uint8_t threshold);
345  uint8_t GetBlockAckThreshold (void) const;
352  void SetBlockAckInactivityTimeout (uint16_t timeout);
361  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
375  bool GetAmpduExist (Mac48Address dest) const;
382  void SetAmpduExist (Mac48Address dest, bool enableAmpdu);
388  void SetAddBaResponseTimeout (Time addBaResponseTimeout);
394  Time GetAddBaResponseTimeout (void) const;
401  void SetFailedAddBaTimeout (Time failedAddBaTimeout);
407  Time GetFailedAddBaTimeout (void) const;
416  uint16_t GetNextSequenceNumberFor (const WifiMacHeader *hdr);
424  uint16_t PeekNextSequenceNumberFor (const WifiMacHeader *hdr);
458  bool aggregate = true, uint32_t ampduSize = 0,
459  Time ppduDurationLimit = Time::Min ());
483  void BaTxOk (const WifiMacHeader &hdr);
489  void BaTxFailed (const WifiMacHeader &hdr);
515 private:
525  bool SetupBlockAckIfNeeded (void);
536  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq,
537  uint16_t timeout, bool immediateBAck);
550  void TerminateTxop (void);
557  uint32_t GetNextFragmentSize (void) const;
563  uint32_t GetFragmentSize (void) const;
569  uint32_t GetFragmentOffset (void) const;
576  bool IsLastFragment (void) const;
584  bool IsTxopFragmentation (void) const;
590  uint32_t GetTxopFragmentSize (void) const;
596  uint32_t GetNTxopFragment (void) const;
603  uint32_t GetNextTxopFragmentSize (uint32_t fragmentNumber) const;
610  uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const;
617  void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid);
624  void ResetBa (Mac48Address recipient, uint8_t tid);
626  void DoDispose (void);
627  void DoInitialize (void);
646 };
648 } //namespace ns3
650 #endif /* QOS_TXOP_H */
AcIndex m_ac
the access category
Definition: qos-txop.h:629
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:817
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:1165
bool GetAmpduExist(Mac48Address dest) const
Return whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1507
void ResetBa(Mac48Address recipient, uint8_t tid)
Reset BA agreement after BA negotiation failed.
Definition: qos-txop.cc:1728
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: qos-txop.cc:985
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:635
static Time Min()
Minimum representable Time.
Definition: nstime.h:268
Time m_startTxop
the start TXOP time
Definition: qos-txop.h:638
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set destination address in A-MSDU subframes.
Definition: qos-txop.cc:1426
bool m_isAccessRequestedForRts
flag whether access is requested to transmit a RTS frame
Definition: qos-txop.h:639
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 Block ACK timeout has occurred.
Definition: qos-txop.cc:875
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: qos-txop.cc:1057
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the Block Ack inactivity timeout.
Definition: qos-txop.cc:1573
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:1648
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:1486
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:1403
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:1580
void DoDispose(void)
Destructor implementation.
Definition: qos-txop.cc:118
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:1229
Time m_failedAddBaTimeout
timeout after failed BA agreement
Definition: qos-txop.h:642
control how a packet is transmitted.
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: qos-txop.cc:1366
uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: qos-txop.cc:1350
Time GetAddBaResponseTimeout(void) const
Get the timeout for ADDBA response.
Definition: qos-txop.cc:1750
friend class AggregationCapableTransmissionListener
allow AggregationCapableTransmissionListener class access
Definition: qos-txop.h:517
uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: qos-txop.cc:1335
void SetAmpduExist(Mac48Address dest, bool enableAmpdu)
Set indication whether A-MPDU is used to transmit data to a peer station.
Definition: qos-txop.cc:1518
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: qos-txop.cc:1025
void SetFailedAddBaTimeout(Time failedAddBaTimeout)
Set the timeout for failed BA agreement.
Definition: qos-txop.cc:1756
Ptr< BlockAckManager > m_baManager
the Block ACK manager
Definition: qos-txop.h:633
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:1452
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:1320
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:1442
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:1769
uint32_t GetNTxopFragment(void) const
Calculate the number of TXOP fragments needed for the transmission of the current packet...
Definition: qos-txop.cc:1262
void SetAddBaResponseTimeout(Time addBaResponseTimeout)
Set the timeout to wait for ADDBA response.
Definition: qos-txop.cc:1743
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:1704
void NotifyMissedCts(std::list< Ptr< WifiMacQueueItem >> mpduList)
Event handler when a CTS timeout has occurred.
Definition: qos-txop.cc:711
void CompleteMpduTx(Ptr< WifiMacQueueItem > mpdu)
Stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
Definition: qos-txop.cc:1525
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:417
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
Definition: qos-txop.cc:1694
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: qos-txop.cc:1178
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
Definition: qos-txop.cc:1565
void UpdateCurrentPacket(Ptr< WifiMacQueueItem > mpdu)
Update the current packet this QosTxop is trying to transmit.
Definition: qos-txop.cc:492
uint8_t m_blockAckThreshold
the Block ACK threshold
Definition: qos-txop.h:634
Two Level Aggregation Test.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this QosTxop 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:1275
Ptr< WifiAckPolicySelector > m_ackPolicySelector
Ack policy selector.
Definition: qos-txop.h:631
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 EDCAF has frames to transmit.
Definition: qos-txop.cc:207
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:1494
void GotAck(void)
Event handler when an ACK is received.
Definition: qos-txop.cc:757
void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: qos-txop.cc:1080
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 del 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:1410
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
Definition: qos-txop.cc:128
bool m_useExplicitBarAfterMissedBlockAck
flag whether explicit Block Ack Request should be sent upon missed Block Ack Response ...
Definition: qos-txop.h:643
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
QOS blocked destinations.
Definition: qos-txop.h:632
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: qos-txop.cc:501
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:1556
bool m_currentIsFragmented
flag whether current packet is fragmented
Definition: qos-txop.h:640
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:645
void DoInitialize(void)
Initialize() implementation.
Definition: qos-txop.cc:1685
void TerminateTxop(void)
Update backoff and restart access if needed.
Definition: qos-txop.cc:1152
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: qos-txop.cc:1188
Enumeration for type of station.
Definition: qos-txop.h:47
Time m_currentPacketTimestamp
the current packet timestamp
Definition: qos-txop.h:636
bool IsTxopFragmentation(void) const
Check if the current packet is fragmented because of an exceeded TXOP duration.
Definition: qos-txop.cc:1214
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: qos-txop.cc:1382
Time GetFailedAddBaTimeout(void) const
Get the timeout for failed BA agreement.
Definition: qos-txop.cc:1763
uint16_t m_blockAckInactivityTimeout
the Block ACK inactivity timeout
Definition: qos-txop.h:637
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:1536
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: qos-txop.cc:629
uint32_t GetNextTxopFragmentSize(uint32_t fragmentNumber) const
Calculate the size of the next TXOP fragment.
Definition: qos-txop.cc:1301
TypeOfStation m_typeOfStation
the type of station
Definition: qos-txop.h:630
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:1714
Implements the IEEE 802.11 MAC header.
Time m_addBaResponseTimeout
timeout for ADDBA response
Definition: qos-txop.h:641
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:1587
The different block ACK policies.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:65