A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef BLOCK_ACK_MANAGER_H
21 #define BLOCK_ACK_MANAGER_H
22 
23 #include <map>
24 #include <list>
25 #include <deque>
26 
27 #include "ns3/packet.h"
28 
29 #include "wifi-mac-header.h"
31 #include "ctrl-headers.h"
32 #include "qos-utils.h"
33 
34 namespace ns3 {
35 
36 class MgtAddBaResponseHeader;
37 class MgtAddBaRequestHeader;
38 class MgtDelBaHeader;
39 class MacTxMiddle;
40 class WifiMacQueue;
41 
47 struct Bar
48 {
49  Bar ();
50  Bar (Ptr<const Packet> packet,
52  uint8_t tid,
53  bool immediate);
56  uint8_t tid;
57  bool immediate;
58 };
59 
65 {
66 private:
69 
70 public:
71  BlockAckManager ();
80  bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const;
89  bool ExistsAgreementInState (Mac48Address recipient, uint8_t tid,
90  enum OriginatorBlockAckAgreement::State state) const;
98  void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient);
106  void DestroyAgreement (Mac48Address recipient, uint8_t tid);
113  void UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
122  void StorePacket (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tStamp);
130  bool HasBar (struct Bar &bar);
135  bool HasPackets (void) const;
145  void NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient);
153  uint32_t GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const;
161  uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const;
170  void NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
179  void NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t tid);
189  void NotifyMpduTransmission (Mac48Address recipient, uint8_t tid, uint16_t nextSeqNumber);
196  void SetBlockAckThreshold (uint8_t nPackets);
200  void SetQueue (Ptr<WifiMacQueue> queue);
201  void SetTxMiddle (MacTxMiddle* txMiddle);
207  void SetBlockAckType (enum BlockAckType bAckType);
215  void TearDownBlockAck (Mac48Address recipient, uint8_t tid);
223  bool HasOtherFragments (uint16_t sequenceNumber) const;
227  uint32_t GetNextPacketSize (void) const;
234  void SetMaxPacketDelay (Time maxDelay);
246  bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
252  uint16_t GetSeqNumOfNextRetryPacket (Mac48Address recipient, uint8_t tid) const;
253 private:
260  Ptr<Packet> ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t tid);
264  void CleanupBuffers (void);
265  void InactivityTimeout (Mac48Address, uint8_t);
266 
267  struct Item;
268  typedef std::list<Item> PacketQueue;
269  typedef std::list<Item>::iterator PacketQueueI;
270  typedef std::list<Item>::const_iterator PacketQueueCI;
271 
272  typedef std::map<std::pair<Mac48Address, uint8_t>,
273  std::pair<OriginatorBlockAckAgreement, PacketQueue> > Agreements;
274  typedef std::map<std::pair<Mac48Address, uint8_t>,
275  std::pair<OriginatorBlockAckAgreement, PacketQueue> >::iterator AgreementsI;
276  typedef std::map<std::pair<Mac48Address, uint8_t>,
277  std::pair<OriginatorBlockAckAgreement, PacketQueue> >::const_iterator AgreementsCI;
278 
279  struct Item
280  {
281  Item ();
282  Item (Ptr<const Packet> packet,
283  const WifiMacHeader &hdr,
284  Time tStamp);
288  };
289 
302  std::list<PacketQueueI> m_retryPackets;
303  std::list<Bar> m_bars;
304 
314 };
315 
316 } // namespace ns3
317 
318 #endif /* BLOCK_ACK_MANAGER_H */
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > > Agreements
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
Callback template class.
Definition: callback.h:920
std::list< Item > PacketQueue
void NotifyGotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::const_iterator AgreementsCI
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
void StorePacket(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
bool HasBar(struct Bar &bar)
void InactivityTimeout(Mac48Address, uint8_t)
std::map< std::pair< Mac48Address, uint8_t >, std::pair< OriginatorBlockAckAgreement, PacketQueue > >::iterator AgreementsI
void SetBlockAckType(enum BlockAckType bAckType)
bool HasPackets(void) const
BlockAckType
Definition: ctrl-headers.h:27
Block Ack Request.
Ptr< Packet > ScheduleBlockAckReqIfNeeded(Mac48Address recipient, uint8_t tid)
void SetQueue(Ptr< WifiMacQueue > queue)
void NotifyAgreementEstablished(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
void UpdateAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
uint32_t GetNextPacketSize(void) const
uint16_t GetSeqNumOfNextRetryPacket(Mac48Address recipient, uint8_t tid) const
void NotifyAgreementUnsuccessful(Mac48Address recipient, uint8_t tid)
bool HasOtherFragments(uint16_t sequenceNumber) const
std::list< PacketQueueI > m_retryPackets
Headers for Block ack response.
Definition: ctrl-headers.h:102
void SetTxMiddle(MacTxMiddle *txMiddle)
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
void DestroyAgreement(Mac48Address recipient, uint8_t tid)
Mac48Address recipient
Callback< void, Mac48Address, uint8_t, bool > m_blockAckInactivityTimeout
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, enum OriginatorBlockAckAgreement::State state) const
Callback< void, Mac48Address, uint8_t > m_blockPackets
an EUI-48 address
Definition: mac48-address.h:41
Ptr< const Packet > GetNextPacket(WifiMacHeader &hdr)
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
void SetMaxPacketDelay(Time maxDelay)
bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
std::list< Item >::const_iterator PacketQueueCI
BlockAckManager & operator=(const BlockAckManager &)
Callback< void, Mac48Address, uint8_t > m_unblockPackets
uint32_t GetNBufferedPackets(Mac48Address recipient, uint8_t tid) const
std::list< Bar > m_bars
enum BlockAckType m_blockAckType
void SetBlockAckThreshold(uint8_t nPackets)
Ptr< const Packet > bar
Manages all block ack agreements for an originator station.
bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const
Ptr< const Packet > packet
void NotifyMpduTransmission(Mac48Address recipient, uint8_t tid, uint16_t nextSeqNumber)
void TearDownBlockAck(Mac48Address recipient, uint8_t tid)
Ptr< WifiMacQueue > m_queue
std::list< Item >::iterator PacketQueueI