A Discrete-Event Network Simulator
API
block-ack-manager.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009, 2010 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  * Author: Mirko Banchi <mk.banchi@gmail.com>
19  */
20 
21 #ifndef BLOCK_ACK_MANAGER_H
22 #define BLOCK_ACK_MANAGER_H
23 
24 #include <map>
25 #include "ns3/nstime.h"
26 #include "ns3/traced-callback.h"
27 #include "wifi-mac-header.h"
29 #include "block-ack-type.h"
30 #include "wifi-mac-queue-item.h"
31 #include "wifi-tx-vector.h"
32 
33 namespace ns3 {
34 
35 class MgtAddBaResponseHeader;
36 class MgtAddBaRequestHeader;
37 class CtrlBAckResponseHeader;
38 class CtrlBAckRequestHeader;
39 class WifiMacQueue;
40 class WifiMode;
41 class Packet;
42 
48 struct Bar
49 {
50  Bar ();
58  Bar (Ptr<const WifiMacQueueItem> bar, uint8_t tid, bool skipIfNoDataQueued = false);
60  uint8_t tid;
62 };
63 
64 
69 class BlockAckManager : public Object
70 {
71 private:
80 
81 
82 public:
87  static TypeId GetTypeId (void);
88 
89  BlockAckManager ();
91 
101  bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const;
112  bool ExistsAgreementInState (Mac48Address recipient, uint8_t tid,
122  void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported = true);
130  void DestroyAgreement (Mac48Address recipient, uint8_t tid);
138  void UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient,
139  uint16_t startingSeq);
159  Ptr<const WifiMacQueueItem> GetBar (bool remove = true, uint8_t tid = 8,
168  bool HasPackets (void);
203  std::pair<uint16_t,uint16_t> NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck,
204  Mac48Address recipient, const std::set<uint8_t>& tids,
205  size_t index = 0);
214  void NotifyMissedBlockAck (Mac48Address recipient, uint8_t tid);
223  void DiscardOutstandingMpdus (Mac48Address recipient, uint8_t tid);
233  uint32_t GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const;
242  void NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
251  void NotifyAgreementRejected (Mac48Address recipient, uint8_t tid);
260  void NotifyAgreementNoReply (Mac48Address recipient, uint8_t tid);
267  void NotifyAgreementReset (Mac48Address recipient, uint8_t tid);
274  void SetBlockAckThreshold (uint8_t nPackets);
281 
285  void SetQueue (const Ptr<WifiMacQueue> queue);
286 
302 
316  bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
327  bool NeedBarRetransmission (uint8_t tid, Mac48Address recipient);
336  uint16_t GetRecipientBufferSize (Mac48Address recipient, uint8_t tid) const;
345  BlockAckReqType GetBlockAckReqType (Mac48Address recipient, uint8_t tid) const;
354  BlockAckType GetBlockAckType (Mac48Address recipient, uint8_t tid) const;
363  uint16_t GetOriginatorStartingSequence (Mac48Address recipient, uint8_t tid) const;
364 
377  void SetTxOkCallback (TxOk callback);
382  void SetTxFailedCallback (TxFailed callback);
383 
392  typedef void (* AgreementStateTracedCallback)(Time now, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
393 
405 
414  CtrlBAckRequestHeader GetBlockAckReqHeader (Mac48Address recipient, uint8_t tid) const;
415 
425  void ScheduleBar (Ptr<const WifiMacQueueItem> bar, bool skipIfNoDataQueued = false);
426 
427 protected:
428  void DoDispose () override;
429 
430 private:
436  void InactivityTimeout (Mac48Address recipient, uint8_t tid);
437 
448  void RemoveOldPackets (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
449 
453  typedef std::list<Ptr<WifiMacQueueItem>> PacketQueue;
457  typedef std::list<Ptr<WifiMacQueueItem>>::iterator PacketQueueI;
461  typedef std::list<Ptr<WifiMacQueueItem>>::const_iterator PacketQueueCI;
465  typedef std::map<std::pair<Mac48Address, uint8_t>,
466  std::pair<OriginatorBlockAckAgreement, PacketQueue> > Agreements;
470  typedef std::map<std::pair<Mac48Address, uint8_t>,
471  std::pair<OriginatorBlockAckAgreement, PacketQueue> >::iterator AgreementsI;
475  typedef std::map<std::pair<Mac48Address, uint8_t>,
476  std::pair<OriginatorBlockAckAgreement, PacketQueue> >::const_iterator AgreementsCI;
477 
485 
494  void RemoveFromRetryQueue (Mac48Address address, uint8_t tid, uint16_t seq);
495 
505  void RemoveFromRetryQueue (Mac48Address address, uint8_t tid, uint16_t startSeq, uint16_t endSeq);
506 
514 
521  std::list<Bar> m_bars;
522 
530 
535 };
536 
537 } //namespace ns3
538 
539 #endif /* BLOCK_ACK_MANAGER_H */
ns3::BlockAckManager::GetBlockAckReqHeader
CtrlBAckRequestHeader GetBlockAckReqHeader(Mac48Address recipient, uint8_t tid) const
Definition: block-ack-manager.cc:656
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::BlockAckManager::GetNBufferedPackets
uint32_t GetNBufferedPackets(Mac48Address recipient, uint8_t tid) const
Definition: block-ack-manager.cc:365
ns3::BlockAckManager::SwitchToBlockAckIfNeeded
bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
Definition: block-ack-manager.cc:787
ns3::BlockAckManager::CreateAgreement
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported=true)
Definition: block-ack-manager.cc:122
ns3::BlockAckManager::HasPackets
bool HasPackets(void)
Returns true if there are packets that need of retransmission or at least a BAR is scheduled.
Definition: block-ack-manager.cc:358
ns3::BlockAckManager::NotifyAgreementReset
void NotifyAgreementReset(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:767
ns3::Bar
BlockAckRequest frame information.
Definition: block-ack-manager.h:49
block-ack-type.h
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::BlockAckManager::operator=
BlockAckManager & operator=(const BlockAckManager &block)
assignment operator
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::BlockAckManager::SetTxOkCallback
void SetTxOkCallback(TxOk callback)
Definition: block-ack-manager.cc:922
ns3::BlockAckManager::DestroyAgreement
void DestroyAgreement(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:158
ns3::Bar::bar
Ptr< const WifiMacQueueItem > bar
BlockAckRequest or MU-BAR Trigger Frame.
Definition: block-ack-manager.h:59
ns3::BlockAckManager::m_retryPackets
Ptr< WifiMacQueue > m_retryPackets
This list contains all iterators to stored packets that need to be retransmitted.
Definition: block-ack-manager.h:520
ns3::BlockAckManager::Agreements
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > > Agreements
typedef for a map between MAC address and block ack agreement.
Definition: block-ack-manager.h:466
ns3::CtrlBAckRequestHeader
Headers for BlockAckRequest.
Definition: ctrl-headers.h:49
ns3::BlockAckManager::InsertInRetryQueue
void InsertInRetryQueue(Ptr< WifiMacQueueItem > mpdu)
Definition: block-ack-manager.cc:934
ns3::BlockAckManager::DiscardOutstandingMpdus
void DiscardOutstandingMpdus(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:582
ns3::BlockAckManager::SetQueue
void SetQueue(const Ptr< WifiMacQueue > queue)
Definition: block-ack-manager.cc:780
ns3::BlockAckManager::TxOk
Callback< void, Ptr< const WifiMacQueueItem > > TxOk
typedef for a callback to invoke when an MPDU is successfully ack'ed.
Definition: block-ack-manager.h:368
ns3::BlockAckManager::NeedBarRetransmission
bool NeedBarRetransmission(uint8_t tid, Mac48Address recipient)
This function returns true if a block ack agreement is established with the given recipient for the g...
Definition: block-ack-manager.cc:804
ns3::BlockAckManager
Manages all block ack agreements for an originator station.
Definition: block-ack-manager.h:70
ns3::BlockAckManager::NotifyMissedBlockAck
void NotifyMissedBlockAck(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:564
ns3::BlockAckManager::AgreementsCI
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::const_iterator AgreementsCI
typedef for a const iterator for Agreements.
Definition: block-ack-manager.h:476
ns3::MgtAddBaRequestHeader
Implement the header for management frames of type Add Block Ack request.
Definition: mgt-headers.h:991
ns3::BlockAckManager::NotifyAgreementEstablished
void NotifyAgreementEstablished(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
Definition: block-ack-manager.cc:726
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::BlockAckManager::UpdateAgreement
void UpdateAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient, uint16_t startingSeq)
Definition: block-ack-manager.cc:192
ns3::BlockAckManager::RemoveOldPackets
void RemoveOldPackets(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
Remove packets from the retransmit queue and from the queue of outstanding packets that become old af...
Definition: block-ack-manager.cc:862
ns3::BlockAckManager::GetBar
Ptr< const WifiMacQueueItem > GetBar(bool remove=true, uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast())
Returns the next BlockAckRequest or MU-BAR Trigger Frame to send, if any.
Definition: block-ack-manager.cc:283
wifi-mac-queue-item.h
ns3::BlockAckManager::PacketQueueI
std::list< Ptr< WifiMacQueueItem > >::iterator PacketQueueI
typedef for an iterator for PacketQueue.
Definition: block-ack-manager.h:457
ns3::BlockAckManager::NotifyAgreementNoReply
void NotifyAgreementNoReply(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:753
ns3::BlockAckManager::m_unblockPackets
Callback< void, Mac48Address, uint8_t > m_unblockPackets
unblock packets callback
Definition: block-ack-manager.h:527
ns3::BlockAckManager::BlockAckManager
BlockAckManager(const BlockAckManager &)
type conversion operator
ns3::BlockAckManager::m_bars
std::list< Bar > m_bars
list of BARs
Definition: block-ack-manager.h:521
ns3::Bar::skipIfNoDataQueued
bool skipIfNoDataQueued
do not send if there is no data queued (unused if MU-BAR)
Definition: block-ack-manager.h:61
ns3::BlockAckManager::ExistsAgreementInState
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state) const
Definition: block-ack-manager.cc:95
ns3::BlockAckManager::ExistsAgreement
bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const
Definition: block-ack-manager.cc:88
wifi-mac-header.h
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::BlockAckManager::RemoveFromRetryQueue
void RemoveFromRetryQueue(Mac48Address address, uint8_t tid, uint16_t seq)
Remove an item from retransmission queue.
Definition: block-ack-manager.cc:827
ns3::BlockAckManager::SetUnblockDestinationCallback
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set unblock destination callback.
Definition: block-ack-manager.cc:915
ns3::Mac48Address::GetBroadcast
static Mac48Address GetBroadcast(void)
Definition: mac48-address.cc:170
originator-block-ack-agreement.h
ns3::BlockAckReqType
The different BlockAckRequest variants.
Definition: block-ack-type.h:75
ns3::BlockAckManager::~BlockAckManager
~BlockAckManager()
Definition: block-ack-manager.cc:72
ns3::BlockAckManager::PacketQueueCI
std::list< Ptr< WifiMacQueueItem > >::const_iterator PacketQueueCI
typedef for a const iterator for PacketQueue.
Definition: block-ack-manager.h:461
ns3::BlockAckManager::m_blockAckInactivityTimeout
Callback< void, Mac48Address, uint8_t, bool > m_blockAckInactivityTimeout
BlockAck inactivity timeout callback.
Definition: block-ack-manager.h:525
ns3::BlockAckManager::SetBlockAckInactivityCallback
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
Set block ack inactivity callback.
Definition: block-ack-manager.cc:901
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::BlockAckManager::DoDispose
void DoDispose() override
Destructor implementation.
Definition: block-ack-manager.cc:78
ns3::OriginatorBlockAckAgreement::State
State
Represents the state for this agreement.
Definition: originator-block-ack-agreement.h:102
wifi-tx-vector.h
ns3::BlockAckType
The different BlockAck variants.
Definition: block-ack-type.h:34
ns3::BlockAckManager::m_blockPackets
Callback< void, Mac48Address, uint8_t > m_blockPackets
block packets callback
Definition: block-ack-manager.h:526
first.address
address
Definition: first.py:44
ns3::BlockAckManager::SetTxFailedCallback
void SetTxFailedCallback(TxFailed callback)
Definition: block-ack-manager.cc:928
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::BlockAckManager::GetBlockAckReqType
BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const
This function returns the type of Block Acks sent to the recipient.
Definition: block-ack-manager.cc:990
ns3::BlockAckManager::GetRecipientBufferSize
uint16_t GetRecipientBufferSize(Mac48Address recipient, uint8_t tid) const
This function returns the buffer size negotiated with the recipient.
Definition: block-ack-manager.cc:978
ns3::MgtAddBaResponseHeader
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1123
ns3::BlockAckManager::NotifyGotAck
void NotifyGotAck(Ptr< const WifiMacQueueItem > mpdu)
Invoked upon receipt of an Ack frame after the transmission of a QoS data frame sent under an establi...
Definition: block-ack-manager.cc:396
ns3::BlockAckManager::StorePacket
void StorePacket(Ptr< WifiMacQueueItem > mpdu)
Definition: block-ack-manager.cc:238
ns3::BlockAckManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: block-ack-manager.cc:51
ns3::Bar::Bar
Bar()
Definition: block-ack-manager.cc:35
ns3::BlockAckManager::TxFailed
Callback< void, Ptr< const WifiMacQueueItem > > TxFailed
typedef for a callback to invoke when an MPDU is negatively ack'ed.
Definition: block-ack-manager.h:372
ns3::BlockAckManager::PacketQueue
std::list< Ptr< WifiMacQueueItem > > PacketQueue
typedef for a list of WifiMacQueueItem.
Definition: block-ack-manager.h:453
ns3::BlockAckManager::m_txOkCallback
TxOk m_txOkCallback
transmit OK callback
Definition: block-ack-manager.h:528
ns3::BlockAckManager::SetBlockAckThreshold
void SetBlockAckThreshold(uint8_t nPackets)
Definition: block-ack-manager.cc:389
ns3::BlockAckManager::BlockAckManager
BlockAckManager()
Definition: block-ack-manager.cc:65
ns3::BlockAckManager::NotifyGotBlockAck
std::pair< uint16_t, uint16_t > NotifyGotBlockAck(const CtrlBAckResponseHeader &blockAck, Mac48Address recipient, const std::set< uint8_t > &tids, size_t index=0)
Definition: block-ack-manager.cc:458
ns3::BlockAckManager::m_agreementState
TracedCallback< Time, Mac48Address, uint8_t, OriginatorBlockAckAgreement::State > m_agreementState
The trace source fired when a state transition occurred.
Definition: block-ack-manager.h:534
ns3::BlockAckManager::NotifyDiscardedMpdu
void NotifyDiscardedMpdu(Ptr< const WifiMacQueueItem > mpdu)
Definition: block-ack-manager.cc:605
ns3::BlockAckManager::SetBlockDestinationCallback
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set block destination callback.
Definition: block-ack-manager.cc:908
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::BlockAckManager::GetBlockAckType
BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const
This function returns the type of Block Acks sent by the recipient.
Definition: block-ack-manager.cc:998
ns3::Bar::tid
uint8_t tid
TID (unused if MU-BAR)
Definition: block-ack-manager.h:60
ns3::BlockAckManager::GetRetransmitQueue
Ptr< WifiMacQueue > GetRetransmitQueue(void)
Definition: block-ack-manager.cc:232
ns3::BlockAckManager::m_txFailedCallback
TxFailed m_txFailedCallback
transmit failed callback
Definition: block-ack-manager.h:529
ns3::BlockAckManager::m_blockAckThreshold
uint8_t m_blockAckThreshold
block ack threshold
Definition: block-ack-manager.h:523
ns3::BlockAckManager::ScheduleBar
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
Definition: block-ack-manager.cc:670
ns3::BlockAckManager::GetOriginatorStartingSequence
uint16_t GetOriginatorStartingSequence(Mac48Address recipient, uint8_t tid) const
This function returns the starting sequence number of the transmit window.
Definition: block-ack-manager.cc:1006
ns3::BlockAckManager::AgreementsI
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::iterator AgreementsI
typedef for an iterator for Agreements.
Definition: block-ack-manager.h:471
ns3::BlockAckManager::m_queue
Ptr< WifiMacQueue > m_queue
queue
Definition: block-ack-manager.h:524
ns3::BlockAckManager::NotifyAgreementRejected
void NotifyAgreementRejected(Mac48Address recipient, uint8_t tid)
Definition: block-ack-manager.cc:740
ns3::BlockAckManager::NotifyMissedAck
void NotifyMissedAck(Ptr< WifiMacQueueItem > mpdu)
Invoked upon missed reception of an Ack frame after the transmission of a QoS data frame sent under a...
Definition: block-ack-manager.cc:426
ns3::BlockAckManager::InactivityTimeout
void InactivityTimeout(Mac48Address recipient, uint8_t tid)
Inactivity timeout function.
Definition: block-ack-manager.cc:719
ns3::BlockAckManager::AgreementStateTracedCallback
void(* AgreementStateTracedCallback)(Time now, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
TracedCallback signature for state changes.
Definition: block-ack-manager.h:392
ns3::CtrlBAckResponseHeader
Headers for BlockAck response.
Definition: ctrl-headers.h:202
ns3::BlockAckManager::m_agreements
Agreements m_agreements
This data structure contains, for each block ack agreement (recipient, TID), a set of packets for whi...
Definition: block-ack-manager.h:513