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
33namespace ns3 {
34
35class MgtAddBaResponseHeader;
36class MgtAddBaRequestHeader;
37class CtrlBAckResponseHeader;
38class CtrlBAckRequestHeader;
39class WifiMacQueue;
40class WifiMode;
41class Packet;
42
48struct Bar
49{
50 Bar ();
60 uint8_t tid;
62};
63
64
69class BlockAckManager : public Object
70{
71private:
80
84 enum MpduStatus : uint8_t
85 {
89 };
90
91public:
96 static TypeId GetTypeId (void);
97
100
110 bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const;
121 bool ExistsAgreementInState (Mac48Address recipient, uint8_t tid,
131 void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported = true);
139 void DestroyAgreement (Mac48Address recipient, uint8_t tid);
147 void UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient,
148 uint16_t startingSeq);
168 Ptr<const WifiMacQueueItem> GetBar (bool remove = true, uint8_t tid = 8,
204 std::pair<uint16_t,uint16_t> NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck,
205 Mac48Address recipient, const std::set<uint8_t>& tids,
206 size_t index = 0);
215 void NotifyMissedBlockAck (Mac48Address recipient, uint8_t tid);
225 uint32_t GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const;
234 void NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
243 void NotifyAgreementRejected (Mac48Address recipient, uint8_t tid);
252 void NotifyAgreementNoReply (Mac48Address recipient, uint8_t tid);
259 void NotifyAgreementReset (Mac48Address recipient, uint8_t tid);
266 void SetBlockAckThreshold (uint8_t nPackets);
267
271 void SetQueue (const Ptr<WifiMacQueue> queue);
272
288
302 bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
313 bool NeedBarRetransmission (uint8_t tid, Mac48Address recipient);
322 uint16_t GetRecipientBufferSize (Mac48Address recipient, uint8_t tid) const;
331 BlockAckReqType GetBlockAckReqType (Mac48Address recipient, uint8_t tid) const;
340 BlockAckType GetBlockAckType (Mac48Address recipient, uint8_t tid) const;
349 uint16_t GetOriginatorStartingSequence (Mac48Address recipient, uint8_t tid) const;
350
363
368 void SetTxOkCallback (TxOk callback);
373 void SetTxFailedCallback (TxFailed callback);
378
387 typedef void (* AgreementStateTracedCallback)(Time now, Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state);
388
400
409 CtrlBAckRequestHeader GetBlockAckReqHeader (Mac48Address recipient, uint8_t tid) const;
410
420 void ScheduleBar (Ptr<const WifiMacQueueItem> bar, bool skipIfNoDataQueued = false);
421
422protected:
423 void DoDispose () override;
424
425private:
431 void InactivityTimeout (Mac48Address recipient, uint8_t tid);
432
436 typedef std::list<Ptr<WifiMacQueueItem>> PacketQueue;
440 typedef std::list<Ptr<WifiMacQueueItem>>::iterator PacketQueueI;
444 typedef std::list<Ptr<WifiMacQueueItem>>::const_iterator PacketQueueCI;
448 typedef std::map<std::pair<Mac48Address, uint8_t>,
449 std::pair<OriginatorBlockAckAgreement, PacketQueue> > Agreements;
453 typedef std::map<std::pair<Mac48Address, uint8_t>,
454 std::pair<OriginatorBlockAckAgreement, PacketQueue> >::iterator AgreementsI;
458 typedef std::map<std::pair<Mac48Address, uint8_t>,
459 std::pair<OriginatorBlockAckAgreement, PacketQueue> >::const_iterator AgreementsCI;
460
476 const AgreementsI& it, const Time& now);
477
485
486 std::list<Bar> m_bars;
487
496
501};
502
503} //namespace ns3
504
505#endif /* BLOCK_ACK_MANAGER_H */
Manages all block ack agreements for an originator station.
void StorePacket(Ptr< WifiMacQueueItem > mpdu)
void ScheduleBar(Ptr< const WifiMacQueueItem > bar, bool skipIfNoDataQueued=false)
void SetTxFailedCallback(TxFailed callback)
Callback< void, Ptr< const WifiMacQueueItem > > TxOk
typedef for a callback to invoke when an MPDU is successfully ack'ed.
void NotifyAgreementRejected(Mac48Address recipient, uint8_t tid)
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
void SetBlockAckThreshold(uint8_t nPackets)
DroppedOldMpdu m_droppedOldMpduCallback
the dropped MPDU callback
std::list< Ptr< WifiMacQueueItem > > PacketQueue
typedef for a list of WifiMacQueueItem.
void NotifyAgreementEstablished(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
void SetDroppedOldMpduCallback(DroppedOldMpdu callback)
void DestroyAgreement(Mac48Address recipient, uint8_t tid)
void NotifyDiscardedMpdu(Ptr< const WifiMacQueueItem > mpdu)
BlockAckManager & operator=(const BlockAckManager &block)
assignment operator
Callback< void, Ptr< const WifiMacQueueItem > > DroppedOldMpdu
typedef for a callback to invoke when an MPDU is dropped.
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...
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)
void NotifyMissedAck(Ptr< WifiMacQueueItem > mpdu)
Invoked upon missed reception of an Ack frame after the transmission of a QoS data frame sent under a...
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)
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.
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.
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.
static TypeId GetTypeId(void)
Get the type ID.
Callback< void, Ptr< const WifiMacQueueItem > > TxFailed
typedef for a callback to invoke when an MPDU is negatively ack'ed.
Agreements m_agreements
This data structure contains, for each block ack agreement (recipient, TID), a set of packets for whi...
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported=true)
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set block destination callback.
BlockAckManager(const BlockAckManager &)
type conversion operator
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > > Agreements
typedef for a map between MAC address and block ack agreement.
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
Set block ack inactivity callback.
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, OriginatorBlockAckAgreement::State state) const
Callback< void, Mac48Address, uint8_t, bool > m_blockAckInactivityTimeout
BlockAck inactivity timeout callback.
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
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
std::list< Ptr< WifiMacQueueItem > >::iterator PacketQueueI
typedef for an iterator for PacketQueue.
PacketQueueI HandleInFlightMpdu(PacketQueueI mpduIt, MpduStatus status, const AgreementsI &it, const Time &now)
Handle the given in flight MPDU based on its given status.
std::list< Ptr< WifiMacQueueItem > >::const_iterator PacketQueueCI
typedef for a const iterator for PacketQueue.
Callback template class.
Definition: callback.h:1279
Headers for BlockAckRequest.
Definition: ctrl-headers.h:49
Headers for BlockAck response.
Definition: ctrl-headers.h:202
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
Implement the header for management frames of type Add Block Ack request.
Definition: mgt-headers.h:1018
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1150
A base class which provides memory management and object aggregation.
Definition: object.h:88
State
Represents the state for this agreement.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
BlockAckRequest frame information.
uint8_t tid
TID (unused if MU-BAR)
bool skipIfNoDataQueued
do not send if there is no data queued (unused if MU-BAR)
Ptr< const WifiMacQueueItem > bar
BlockAckRequest or MU-BAR Trigger Frame.
The different BlockAckRequest variants.
The different BlockAck variants.