A Discrete-Event Network Simulator
API
block-ack-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009, 2010 MIRKO BANCHI
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mirko Banchi <mk.banchi@gmail.com>
18 */
19
20#ifndef BLOCK_ACK_MANAGER_H
21#define BLOCK_ACK_MANAGER_H
22
23#include "block-ack-type.h"
25#include "wifi-mac-header.h"
26#include "wifi-mpdu.h"
27#include "wifi-tx-vector.h"
28
29#include "ns3/nstime.h"
30#include "ns3/object.h"
31#include "ns3/traced-callback.h"
32
33#include <map>
34
35namespace ns3
36{
37
38class MgtAddBaResponseHeader;
39class MgtAddBaRequestHeader;
40class CtrlBAckResponseHeader;
41class CtrlBAckRequestHeader;
42class WifiMacQueue;
43class WifiMode;
44class Packet;
45
51struct Bar
52{
53 Bar();
61 Bar(Ptr<const WifiMpdu> bar, uint8_t tid, bool skipIfNoDataQueued = false);
63 uint8_t tid;
65};
66
71class BlockAckManager : public Object
72{
73 private:
77 enum MpduStatus : uint8_t
78 {
82 };
83
84 public:
89 static TypeId GetTypeId();
90
92 ~BlockAckManager() override;
93
94 // Delete copy constructor and assignment operator to avoid misuse
97
103 void SetBlockAckManagerMap(const std::map<AcIndex, Ptr<BlockAckManager>>& bamMap);
113 bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const;
125 uint8_t tid,
135 void CreateAgreement(const MgtAddBaRequestHeader* reqHdr,
136 Mac48Address recipient,
137 bool htSupported = true);
145 void DestroyAgreement(Mac48Address recipient, uint8_t tid);
153 void UpdateAgreement(const MgtAddBaResponseHeader* respHdr,
154 Mac48Address recipient,
155 uint16_t startingSeq);
162 void StorePacket(Ptr<WifiMpdu> mpdu);
175 Ptr<const WifiMpdu> GetBar(bool remove = true,
176 uint8_t tid = 8,
212 std::pair<uint16_t, uint16_t> NotifyGotBlockAck(const CtrlBAckResponseHeader& blockAck,
213 Mac48Address recipient,
214 const std::set<uint8_t>& tids,
215 size_t index = 0);
224 void NotifyMissedBlockAck(Mac48Address recipient, uint8_t tid);
234 uint32_t GetNBufferedPackets(Mac48Address recipient, uint8_t tid) const;
243 void NotifyAgreementEstablished(Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
252 void NotifyAgreementRejected(Mac48Address recipient, uint8_t tid);
261 void NotifyAgreementNoReply(Mac48Address recipient, uint8_t tid);
269 void NotifyAgreementReset(Mac48Address recipient, uint8_t tid);
277 void SetBlockAckThreshold(uint8_t nPackets);
278
282 void SetQueue(const Ptr<WifiMacQueue> queue);
283
299
313 bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
324 bool NeedBarRetransmission(uint8_t tid, Mac48Address recipient);
333 uint16_t GetRecipientBufferSize(Mac48Address recipient, uint8_t tid) const;
342 BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const;
351 BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const;
360 uint16_t GetOriginatorStartingSequence(Mac48Address recipient, uint8_t tid) const;
361
374
379 void SetTxOkCallback(TxOk callback);
384 void SetTxFailedCallback(TxFailed callback);
389
399 Mac48Address recipient,
400 uint8_t tid,
402
414
423 CtrlBAckRequestHeader GetBlockAckReqHeader(Mac48Address recipient, uint8_t tid) const;
424
434 void ScheduleBar(Ptr<const WifiMpdu> bar, bool skipIfNoDataQueued = false);
435
436 protected:
437 void DoDispose() override;
438
439 private:
445 void InactivityTimeout(Mac48Address recipient, uint8_t tid);
446
450 typedef std::list<Ptr<WifiMpdu>> PacketQueue;
454 typedef std::list<Ptr<WifiMpdu>>::iterator PacketQueueI;
458 typedef std::list<Ptr<WifiMpdu>>::const_iterator PacketQueueCI;
462 typedef std::map<std::pair<Mac48Address, uint8_t>,
463 std::pair<OriginatorBlockAckAgreement, PacketQueue>>
468 typedef std::map<std::pair<Mac48Address, uint8_t>,
469 std::pair<OriginatorBlockAckAgreement, PacketQueue>>::iterator AgreementsI;
473 typedef std::map<std::pair<Mac48Address, uint8_t>,
474 std::pair<OriginatorBlockAckAgreement, PacketQueue>>::const_iterator
476
492 MpduStatus status,
493 const AgreementsI& it,
494 const Time& now);
495
503
504 std::list<Bar> m_bars;
505
506 std::map<AcIndex, Ptr<BlockAckManager>> m_bamMap;
516
522};
523
524} // namespace ns3
525
526#endif /* BLOCK_ACK_MANAGER_H */
Manages all block ack agreements for an originator station.
void SetTxFailedCallback(TxFailed callback)
void NotifyAgreementRejected(Mac48Address recipient, uint8_t tid)
std::map< AcIndex, Ptr< BlockAckManager > > m_bamMap
AC-indexed map of all Block Ack Managers.
CtrlBAckRequestHeader GetBlockAckReqHeader(Mac48Address recipient, uint8_t tid) const
Callback< void, Mac48Address, uint8_t > m_unblockPackets
unblock packets callback
void SetQueue(const Ptr< WifiMacQueue > queue)
void SetTxOkCallback(TxOk callback)
bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
uint8_t m_blockAckThreshold
block ack threshold
std::list< Ptr< WifiMpdu > > PacketQueue
typedef for a list of WifiMpdu.
static TypeId GetTypeId()
Get the type ID.
void SetBlockAckThreshold(uint8_t nPackets)
DroppedOldMpdu m_droppedOldMpduCallback
the dropped MPDU callback
void NotifyAgreementEstablished(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
void SetDroppedOldMpduCallback(DroppedOldMpdu callback)
void DestroyAgreement(Mac48Address recipient, uint8_t tid)
void NotifyGotAck(Ptr< const WifiMpdu > mpdu)
Invoked upon receipt of an Ack frame after the transmission of a QoS data frame sent under an establi...
TxFailed m_txFailedCallback
transmit failed callback
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set unblock destination callback.
Ptr< WifiMacQueue > m_queue
queue
std::pair< uint16_t, uint16_t > NotifyGotBlockAck(const CtrlBAckResponseHeader &blockAck, Mac48Address recipient, const std::set< uint8_t > &tids, size_t index=0)
BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const
This function returns the type of Block Acks sent to the recipient.
void NotifyAgreementReset(Mac48Address recipient, uint8_t tid)
TracedCallback< Time, Mac48Address, uint8_t, OriginatorBlockAckAgreement::State > m_agreementState
The trace source fired when a state transition occurred.
void UpdateAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient, uint16_t startingSeq)
uint16_t GetRecipientBufferSize(Mac48Address recipient, uint8_t tid) const
This function returns the buffer size negotiated with the recipient.
void(* AgreementStateTracedCallback)(Time now, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
TracedCallback signature for state changes.
void InactivityTimeout(Mac48Address recipient, uint8_t tid)
Inactivity timeout function.
void SetBlockAckManagerMap(const std::map< AcIndex, Ptr< BlockAckManager > > &bamMap)
Provide information about all the Block Ack Managers installed on this device.
bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const
void NotifyAgreementNoReply(Mac48Address recipient, uint8_t tid)
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...
BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const
This function returns the type of Block Acks sent by the recipient.
std::list< Ptr< WifiMpdu > >::const_iterator PacketQueueCI
typedef for a const iterator for PacketQueue.
void StorePacket(Ptr< WifiMpdu > mpdu)
BlockAckManager & operator=(const BlockAckManager &)=delete
void NotifyDiscardedMpdu(Ptr< const WifiMpdu > mpdu)
Agreements m_agreements
This data structure contains, for each block ack agreement (recipient, TID), a set of packets for whi...
void ScheduleBar(Ptr< const WifiMpdu > bar, bool skipIfNoDataQueued=false)
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported=true)
Callback< void, Ptr< const WifiMpdu > > TxFailed
typedef for a callback to invoke when an MPDU is negatively ack'ed.
Callback< void, Ptr< const WifiMpdu > > TxOk
typedef for a callback to invoke when an MPDU is successfully ack'ed.
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set block destination callback.
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > > Agreements
typedef for a map between MAC address and block ack agreement.
std::list< Ptr< WifiMpdu > >::iterator PacketQueueI
typedef for an iterator for PacketQueue.
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
Set block ack inactivity callback.
BlockAckManager(const BlockAckManager &)=delete
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state) const
Callback< void, Mac48Address, uint8_t, bool > m_blockAckInactivityTimeout
BlockAck inactivity timeout callback.
Callback< void, Ptr< const WifiMpdu > > DroppedOldMpdu
typedef for a callback to invoke when an MPDU is dropped.
Ptr< const WifiMpdu > 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.
TxOk m_txOkCallback
transmit OK callback
MpduStatus
Enumeration for the statuses of a buffered MPDU.
void NotifyMissedBlockAck(Mac48Address recipient, uint8_t tid)
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::const_iterator AgreementsCI
typedef for a const iterator for Agreements.
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::iterator AgreementsI
typedef for an iterator for Agreements.
void DoDispose() override
Destructor implementation.
uint32_t GetNBufferedPackets(Mac48Address recipient, uint8_t tid) const
void NotifyMissedAck(Ptr< WifiMpdu > mpdu)
Invoked upon missed reception of an Ack frame after the transmission of a QoS data frame sent under a...
Callback< void, Mac48Address, uint8_t > m_blockPackets
block packets callback
uint16_t GetOriginatorStartingSequence(Mac48Address recipient, uint8_t tid) const
This function returns the starting sequence number of the transmit window.
std::list< Bar > m_bars
list of BARs
PacketQueueI HandleInFlightMpdu(PacketQueueI mpduIt, MpduStatus status, const AgreementsI &it, const Time &now)
Handle the given in flight MPDU based on its given status.
Callback template class.
Definition: callback.h:443
Headers for BlockAckRequest.
Definition: ctrl-headers.h:51
Headers for BlockAck response.
Definition: ctrl-headers.h:202
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
Implement the header for management frames of type Add Block Ack request.
Definition: mgt-headers.h:1476
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1607
A base class which provides memory management and object aggregation.
Definition: object.h:89
State
Represents the state for this agreement.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:60
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:74
Every class exported by the ns3 library is enclosed in the ns3 namespace.
BlockAckRequest frame information.
Ptr< const WifiMpdu > bar
BlockAckRequest or MU-BAR Trigger Frame.
uint8_t tid
TID (unused if MU-BAR)
bool skipIfNoDataQueued
do not send if there is no data queued (unused if MU-BAR)
The different BlockAckRequest variants.
The different BlockAck variants.