LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 MIRKO BANCHI | 3 * Copyright (c) 2009 MIRKO BANCHI |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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· | 6 * it under the terms of the GNU General Public License version 2 as· |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mirko Banchi <mk.banchi@gmail.com> | 18 * Author: Mirko Banchi <mk.banchi@gmail.com> |
19 */ | 19 */ |
20 #ifndef BLOCK_ACK_AGREEMENT_H | 20 #ifndef BLOCK_ACK_AGREEMENT_H |
21 #define BLOCK_ACK_AGREEMENT_H | 21 #define BLOCK_ACK_AGREEMENT_H |
22 | 22 |
23 #include "ns3/mac48-address.h" | 23 #include "ns3/mac48-address.h" |
24 #include "ns3/event-id.h" | 24 #include "ns3/event-id.h" |
25 | 25 |
26 namespace ns3 { | 26 namespace ns3 { |
27 /** | 27 /** |
28 * \brief Mantains the state and informations for a block ack agreement. | 28 * \brief Mantains informations for a block ack agreement. |
29 */ | 29 */ |
30 class BlockAckAgreement· | 30 class BlockAckAgreement· |
31 { | 31 { |
32 friend class BlockAckManager; | |
33 friend class MacLow; | 32 friend class MacLow; |
34 public: | 33 public: |
35 /** | |
36 * represents the state for this agreement. | |
37 * | |
38 * PENDING: | |
39 * If an agreement is in PENDING state it means that an ADDBARequest frame
was sent to | |
40 * recipient in order to setup the block ack and the originator is waiting
for the relative | |
41 * ADDBAResponse frame. | |
42 *·· | |
43 * ESTABLISHED: | |
44 * The block ack is active and all packets relative to this agreement are t
rasmitted | |
45 * with ack policy set to block ack. | |
46 *·· | |
47 * INACTIVE: | |
48 * In our implementation, block ack tear-down happens only if an inactivity
timeout occurs | |
49 * so we could have an active block ack but a number of packets that doesn'
t reach the value of | |
50 * m_blockAckThreshold (see ns3::BlocAckManager). In these conditions the a
greement becomes | |
51 * INACTIVE until that the number of packets reaches the value of m_blockAc
kThreshold again. | |
52 * | |
53 * UNSUCCESSFUL (not used for now): | |
54 * The agremeent's state becomes UNSUCCESSFUL if: | |
55 *····· | |
56 * - its previous state was PENDING and an ADDBAResponse frame wasn't recei
ved from | |
57 * recipient station within an interval of time defined by m_bAckSetupTim
eout attribute | |
58 * in ns3::WifiMac. | |
59 * - an ADDBAResponse frame is received from recipient and the Status Code
field is set | |
60 * to failure. | |
61 *···· | |
62 * In both cases for station addressed by m_peer and for TID m_tid block ac
k mechanism won't be used. | |
63 */ | |
64 enum State { | |
65 PENDING, | |
66 ESTABLISHED, | |
67 INACTIVE, | |
68 UNSUCCESSFUL | |
69 }; | |
70 | |
71 BlockAckAgreement (); | 34 BlockAckAgreement (); |
72 BlockAckAgreement (Mac48Address peer, uint8_t tid); | 35 BlockAckAgreement (Mac48Address peer, uint8_t tid); |
73 ~BlockAckAgreement (); | 36 ~BlockAckAgreement (); |
74 void SetTid (uint8_t tid); | |
75 void SetPeer (Mac48Address peer); | |
76 void SetBufferSize (uint16_t bufferSize); | 37 void SetBufferSize (uint16_t bufferSize); |
77 void SetTimeout (uint16_t timeout); | 38 void SetTimeout (uint16_t timeout); |
78 void SetStartingSequence (uint16_t seq); | 39 void SetStartingSequence (uint16_t seq); |
79 void SetImmediateBlockAck (void); | 40 void SetImmediateBlockAck (void); |
80 void SetDelayedBlockAck (void); | 41 void SetDelayedBlockAck (void); |
81 void SetAmsduSupport (bool supported); | 42 void SetAmsduSupport (bool supported); |
82 void SetState (enum State state); | |
83 | 43 |
84 uint8_t GetTid (void) const; | 44 uint8_t GetTid (void) const; |
85 Mac48Address GetPeer (void) const; | 45 Mac48Address GetPeer (void) const; |
86 uint16_t GetBufferSize (void) const; | 46 uint16_t GetBufferSize (void) const; |
87 uint16_t GetTimeout (void) const; | 47 uint16_t GetTimeout (void) const; |
88 uint16_t GetStartingSequence (void) const; | 48 uint16_t GetStartingSequence (void) const; |
89 uint16_t GetStartingSequenceControl (void) const; | 49 uint16_t GetStartingSequenceControl (void) const; |
90 bool IsImmediateBlockAck (void) const; | 50 bool IsImmediateBlockAck (void) const; |
91 bool IsAmsduSupported (void) const; | 51 bool IsAmsduSupported (void) const; |
92 bool IsPending (void) const; | |
93 bool IsEstablished (void) const; | |
94 bool IsInactive (void) const; | |
95 bool IsUnsuccessful (void) const; | |
96 | 52 |
97 /** | 53 protected: |
98 * Notifies a packet's transmission with ack policy Block Ack. | |
99 */ | |
100 void NotifyMpduTransmission (void); | |
101 /** | |
102 * Returns true if all packets for which a block ack was negotiated have been
transmitted so | |
103 * a block ack request is needed in order to acknowledge them. | |
104 */ | |
105 bool NeedBlockAckRequest (void) const; | |
106 void CompleteExchange (void); | |
107 | |
108 /** Two agreements are considered equals if have same tid and same peer */ | |
109 bool operator== (BlockAckAgreement const &agreement); | |
110 | |
111 private: | |
112 · | 54 · |
113 Mac48Address m_peer; | 55 Mac48Address m_peer; |
114 uint8_t m_amsduSupported; | 56 uint8_t m_amsduSupported; |
115 uint8_t m_blockAckPolicy; /* represents type of block ack: immediate or delaye
d */ | 57 uint8_t m_blockAckPolicy; /* represents type of block ack: immediate or delaye
d */ |
116 uint8_t m_tid; | 58 uint8_t m_tid; |
117 uint16_t m_bufferSize; | 59 uint16_t m_bufferSize; |
118 uint16_t m_timeout; | 60 uint16_t m_timeout; |
119 uint16_t m_startingSeq; | 61 uint16_t m_startingSeq; |
120 enum State m_state; | 62 ·· |
121 | |
122 uint8_t m_sentMpdus; | |
123 EventId m_inactivityEvent; | 63 EventId m_inactivityEvent; |
124 }; | 64 }; |
125 | |
126 bool operator< (BlockAckAgreement const &agreement1, BlockAckAgreement const &ag
reement2); | |
127 | 65 |
128 } //namespace ns3 | 66 } //namespace ns3 |
129 | 67 |
130 #endif /* BLOCK_ACK_AGREEMENT_H */ | 68 #endif /* BLOCK_ACK_AGREEMENT_H */ |
LEFT | RIGHT |