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_MANAGER_H | 20 #ifndef BLOCK_ACK_MANAGER_H |
21 #define BLOCK_ACK_MANAGER_H | 21 #define BLOCK_ACK_MANAGER_H |
22 | 22 |
23 #include <map> | 23 #include <map> |
24 #include <list> | 24 #include <list> |
25 #include <deque> | 25 #include <deque> |
26 | 26 |
27 #include "ns3/packet.h" | 27 #include "ns3/packet.h" |
28 | 28 |
29 #include "wifi-mac-header.h" | 29 #include "wifi-mac-header.h" |
30 #include "block-ack-agreement.h" | 30 #include "originator-block-ack-agreement.h" |
31 #include "ctrl-headers.h" | 31 #include "ctrl-headers.h" |
32 #include "qos-utils.h" | 32 #include "qos-utils.h" |
33 | 33 |
34 using namespace std; | 34 using namespace std; |
35 | 35 |
36 namespace ns3 { | 36 namespace ns3 { |
37 | 37 |
38 class MgtAddBaResponseHeader; | 38 class MgtAddBaResponseHeader; |
39 class MgtAddBaRequestHeader; | 39 class MgtAddBaRequestHeader; |
40 class MgtDelBaHeader; | 40 class MgtDelBaHeader; |
41 class MacTxMiddle; | 41 class MacTxMiddle; |
42 class WifiMacQueue; | 42 class WifiMacQueue; |
| 43 |
| 44 struct Bar { |
| 45 Bar (); |
| 46 Bar (Ptr<const Packet> packet, |
| 47 Mac48Address recipient, |
| 48 uint8_t tid, |
| 49 bool immediate); |
| 50 Ptr<const Packet> bar; |
| 51 Mac48Address recipient; |
| 52 uint8_t tid; |
| 53 bool immediate; |
| 54 }; |
43 | 55 |
44 /** | 56 /** |
45 * \brief Manages all block ack agreements for an originator station. | 57 * \brief Manages all block ack agreements for an originator station. |
46 */ | 58 */ |
47 class BlockAckManager | 59 class BlockAckManager |
48 { | 60 { |
49 public: | 61 public: |
50 BlockAckManager (); | 62 BlockAckManager (); |
51 ~BlockAckManager (); | 63 ~BlockAckManager (); |
52 /** | 64 /** |
53 * \param recipient Address of peer station involved in block ack mechanism. | 65 * \param recipient Address of peer station involved in block ack mechanism. |
54 * \param tid Traffic ID. | 66 * \param tid Traffic ID. |
55 * | 67 * |
56 * Checks if a block ack agreement exists with station addressed by· | 68 * Checks if a block ack agreement exists with station addressed by· |
57 * <i>recipient</i> for tid <i>tid</i>. | 69 * <i>recipient</i> for tid <i>tid</i>. |
58 */ | 70 */ |
59 bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const; | 71 bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const; |
60 /** | 72 /** |
61 * \param recipient Address of peer station involved in block ack mechanism. | 73 * \param recipient Address of peer station involved in block ack mechanism. |
62 * \param tid Traffic ID. | 74 * \param tid Traffic ID. |
63 * \param state The state for block ack agreement | 75 * \param state The state for block ack agreement |
64 | 76 |
65 * Checks if a block ack agreement with a state equals to <i>state</i> exists
with | 77 * Checks if a block ack agreement with a state equals to <i>state</i> exists
with |
66 * station addressed by <i>recipient</i> for tid <i>tid</i>. | 78 * station addressed by <i>recipient</i> for tid <i>tid</i>. |
67 */ | 79 */ |
68 bool ExistsAgreementInState (Mac48Address recipient, uint8_t tid,· | 80 bool ExistsAgreementInState (Mac48Address recipient, uint8_t tid,· |
69 enum BlockAckAgreement::State state) const; | 81 enum OriginatorBlockAckAgreement::State state) co
nst; |
70 /**· | 82 /**· |
71 * \param reqHdr Relative Add block ack request (action frame). | 83 * \param reqHdr Relative Add block ack request (action frame). |
72 * \param recipient Address of peer station involved in block ack mechanism. | 84 * \param recipient Address of peer station involved in block ack mechanism. |
73 * | 85 * |
74 * Creates a new block ack agreement in pending state. When a ADDBA response· | 86 * Creates a new block ack agreement in pending state. When a ADDBA response· |
75 * with a successful status code is received, the relative agreement becomes e
stablished.· | 87 * with a successful status code is received, the relative agreement becomes e
stablished.· |
76 */ | 88 */ |
77 void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipi
ent); | 89 void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipi
ent); |
78 /**· | 90 /**· |
79 * \param recipient Address of peer station involved in block ack mechanism. | 91 * \param recipient Address of peer station involved in block ack mechanism. |
(...skipping 18 matching lines...) Expand all Loading... |
98 * if the packet, in a block ack frame, is indicated by recipient as not recei
ved. | 110 * if the packet, in a block ack frame, is indicated by recipient as not recei
ved. |
99 */ | 111 */ |
100 void StorePacket (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tSt
amp); | 112 void StorePacket (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tSt
amp); |
101 /** | 113 /** |
102 * \param hdr 802.11 header of returned packet (if exists). | 114 * \param hdr 802.11 header of returned packet (if exists). |
103 * | 115 * |
104 * This methods returns a packet (if exists) indicated as not received in | 116 * This methods returns a packet (if exists) indicated as not received in |
105 * corresponding block ack bitmap. | 117 * corresponding block ack bitmap. |
106 */ | 118 */ |
107 Ptr<const Packet> GetNextPacket (WifiMacHeader &hdr); | 119 Ptr<const Packet> GetNextPacket (WifiMacHeader &hdr); |
| 120 bool HasBar (struct Bar &bar); |
108 /** | 121 /** |
109 * Returns true if there are packets that need of retransmission or at least a | 122 * Returns true if there are packets that need of retransmission or at least a |
110 * BAR is sheduled. Returns false othewise. | 123 * BAR is sheduled. Returns false othewise. |
111 */ | 124 */ |
112 bool HasPackets (void) const; | 125 bool HasPackets (void) const; |
113 /** | 126 /** |
114 * \param blockAck The received block ack frame. | 127 * \param blockAck The received block ack frame. |
115 * \param recipient Sender of block ack frame. | 128 * \param recipient Sender of block ack frame. |
116 * | 129 * |
117 * Invoked upon receipt of a block ack frame. Typically, this function, is cal
led | 130 * Invoked upon receipt of a block ack frame. Typically, this function, is cal
led |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 * by an ADDBAResponse frame with a failure status code. FOr now we assume tha
t every QoS station accepts | 165 * by an ADDBAResponse frame with a failure status code. FOr now we assume tha
t every QoS station accepts |
153 * a block ack setup. | 166 * a block ack setup. |
154 */ | 167 */ |
155 void NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t tid); | 168 void NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t tid); |
156 /** | 169 /** |
157 * \param recipient Address of peer station involved in block ack mechanism. | 170 * \param recipient Address of peer station involved in block ack mechanism. |
158 * \param tid Traffic ID of transmitted packet. | 171 * \param tid Traffic ID of transmitted packet. |
159 * | 172 * |
160 * This methods is typically invoked by ns3::EdcaTxopN object every time that
a MPDU | 173 * This methods is typically invoked by ns3::EdcaTxopN object every time that
a MPDU |
161 * with ack policy subfield in Qos Control field set to Block Ack is transmitt
ed. | 174 * with ack policy subfield in Qos Control field set to Block Ack is transmitt
ed. |
162 * Is also invoked in trasmission of A-MSDUs many times as number of MSDU ther
e are | 175 */ |
163 * in the aggregated packet. Returns a block ack request packet if a Block ack
request | 176 void NotifyMpduTransmission (Mac48Address recipient, uint8_t tid); |
164 * is needed, 0 otherwise. | |
165 */ | |
166 Ptr<Packet> NotifyMpduTransmission (Mac48Address recipient, uint8_t tid); | |
167 /** | 177 /** |
168 * \param nPackets Minimum number of packets for use of block ack. | 178 * \param nPackets Minimum number of packets for use of block ack. |
169 * | 179 * |
170 * Upon receipt of a block ack frame, if total number of packets (packets in W
ifiMacQueue | 180 * Upon receipt of a block ack frame, if total number of packets (packets in W
ifiMacQueue |
171 * and buffered packets) is greater of <i>nPackets</i>, they are transmitted u
sing block ack mechanism.··· | 181 * and buffered packets) is greater of <i>nPackets</i>, they are transmitted u
sing block ack mechanism.··· |
172 */ | 182 */ |
173 void SetBlockAckThreshold (uint8_t nPackets); | 183 void SetBlockAckThreshold (uint8_t nPackets); |
174 /** | 184 /** |
175 * \param queue The WifiMacQueue object. | 185 * \param queue The WifiMacQueue object. |
176 */ | 186 */ |
(...skipping 27 matching lines...) Expand all Loading... |
204 /** | 214 /** |
205 * \param maxDelay Max delay for a buffered packet. | 215 * \param maxDelay Max delay for a buffered packet. |
206 *· | 216 *· |
207 * This method is always called by ns3::WifiMacQueue object and sets max delay
equals | 217 * This method is always called by ns3::WifiMacQueue object and sets max delay
equals |
208 * to ns3:WifiMacQueue delay value. | 218 * to ns3:WifiMacQueue delay value. |
209 */ | 219 */ |
210 void SetMaxPacketDelay (Time maxDelay); | 220 void SetMaxPacketDelay (Time maxDelay); |
211 /** | 221 /** |
212 */ | 222 */ |
213 void SetBlockAckInactivityCallback (Callback<void, Mac48Address, uint8_t, bool
> callback); | 223 void SetBlockAckInactivityCallback (Callback<void, Mac48Address, uint8_t, bool
> callback); |
214 void SetBlockPacketCallback (Callback<void, Mac48Address, uint8_t> callback); | 224 void SetBlockDestinationCallback (Callback<void, Mac48Address, uint8_t> callba
ck); |
215 void SetUnblockPacketCallback (Callback<void, Mac48Address, uint8_t> callback)
; | 225 void SetUnblockDestinationCallback (Callback<void, Mac48Address, uint8_t> call
back); |
216 /** | 226 /** |
217 * Checks if there are in the queue other packets that could be send under blo
ck ack. | 227 * Checks if there are in the queue other packets that could be send under blo
ck ack. |
218 * If yes adds this packets in current block ack exchange and realative agreem
ent becomes established. | 228 * If yes adds these packets in current block ack exchange. |
219 * However, number of packets exchanged in the current block ack, will not exc
eed· | 229 * However, number of packets exchanged in the current block ack, will not exc
eed· |
220 * the value of BufferSize in the corresponding BlockAckAgreement object. | 230 * the value of BufferSize in the corresponding OriginatorBlockAckAgreement ob
ject. |
221 */ | 231 */ |
222 bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t s
tartingSeq); | 232 bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t s
tartingSeq); |
223 private: | 233 private: |
224 /** | 234 /** |
225 * Checks if all packets, for which a block ack agreement was established or r
efreshed, | 235 * Checks if all packets, for which a block ack agreement was established or r
efreshed, |
226 * have been transmitted. If yes, adds a pair in m_bAckReqs to indicate that· | 236 * have been transmitted. If yes, adds a pair in m_bAckReqs to indicate that· |
227 * at next channel access a block ack request (for established agreement | 237 * at next channel access a block ack request (for established agreement |
228 * <i>recipient</i>,<i>tid</i>) is needed. | 238 * <i>recipient</i>,<i>tid</i>) is needed. |
229 */ | 239 */ |
230 Ptr<Packet> ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t tid); | 240 Ptr<Packet> ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t tid); |
231 /** | 241 /** |
232 * This method removes packets whose lifetime was exceded. | 242 * This method removes packets whose lifetime was exceded. |
233 */ | 243 */ |
234 void CleanupBuffers (void); | 244 void CleanupBuffers (void); |
235 void InactivityTimeout (Mac48Address, uint8_t); | 245 void InactivityTimeout (Mac48Address, uint8_t); |
236 | 246 |
237 struct Item; | 247 struct Item; |
238 typedef std::list<Item> PacketQueue; | 248 typedef std::list<Item> PacketQueue; |
239 typedef std::list<Item>::iterator PacketQueueI; | 249 typedef std::list<Item>::iterator PacketQueueI; |
240 typedef std::list<Item>::const_iterator PacketQueueCI; | 250 typedef std::list<Item>::const_iterator PacketQueueCI; |
241 ·· | 251 ·· |
242 typedef std::map<std::pair<Mac48Address, uint8_t>,· | 252 typedef std::map<std::pair<Mac48Address, uint8_t>,· |
243 std::pair<BlockAckAgreement, PacketQueue> > Agreements; | 253 std::pair<OriginatorBlockAckAgreement, PacketQueue> > Agreements; |
244 typedef std::map<std::pair<Mac48Address, uint8_t>,· | 254 typedef std::map<std::pair<Mac48Address, uint8_t>,· |
245 std::pair<BlockAckAgreement, PacketQueue> >::iterator AgreementsI; | 255 std::pair<OriginatorBlockAckAgreement, PacketQueue> >::iterator Ag
reementsI; |
246 typedef std::map<std::pair<Mac48Address, uint8_t>,· | 256 typedef std::map<std::pair<Mac48Address, uint8_t>,· |
247 std::pair<BlockAckAgreement, PacketQueue> >::const_iterator Agreem
entsCI; | 257 std::pair<OriginatorBlockAckAgreement, PacketQueue> >::const_itera
tor AgreementsCI; |
248 | 258 |
249 struct Item { | 259 struct Item { |
250 Item (); | 260 Item (); |
251 Item (Ptr<const Packet> packet, | 261 Item (Ptr<const Packet> packet, |
252 const WifiMacHeader &hdr, | 262 const WifiMacHeader &hdr, |
253 Time tStamp); | 263 Time tStamp); |
254 Ptr<const Packet> packet; | 264 Ptr<const Packet> packet; |
255 WifiMacHeader hdr; | 265 WifiMacHeader hdr; |
256 Time timestamp; | 266 Time timestamp; |
257 }; | 267 }; |
258 ·· | 268 ·· |
259 /** | 269 /** |
260 * This data structure contains, for each block ack agreement (recipient, tid)
, a set of packets | 270 * This data structure contains, for each block ack agreement (recipient, tid)
, a set of packets |
261 * for which an ack by block ack is requested. | 271 * for which an ack by block ack is requested. |
262 * Every packet or fragment indicated as correctly received in block ack frame
is· | 272 * Every packet or fragment indicated as correctly received in block ack frame
is· |
263 * erased from this data structure. Pushed back in retransmission queue otherw
ise. | 273 * erased from this data structure. Pushed back in retransmission queue otherw
ise. |
264 */ | 274 */ |
265 Agreements m_agreements; | 275 Agreements m_agreements; |
266 /** | 276 /** |
267 * This list contains all iterators to stored packets that need to be retransm
itted. | 277 * This list contains all iterators to stored packets that need to be retransm
itted. |
268 * A packet needs retransmission if it's indicated as not correctly recevied i
n a block ack | 278 * A packet needs retransmission if it's indicated as not correctly recevied i
n a block ack |
269 * frame. | 279 * frame. |
270 */ | 280 */ |
271 std::list<PacketQueueI> m_retryPackets; | 281 std::list<PacketQueueI> m_retryPackets; |
272 /**· | 282 std::list<Bar> m_bars; |
273 * This data structure is used to keep track of all BlockAckReqs. | 283 ·· |
274 */ | |
275 //std::deque<std::pair<Item, bool> > m_bars; | |
276 | |
277 uint8_t m_blockAckThreshold; | 284 uint8_t m_blockAckThreshold; |
278 enum BlockAckType m_blockAckType; | 285 enum BlockAckType m_blockAckType; |
279 Time m_maxDelay; | 286 Time m_maxDelay; |
280 MacTxMiddle* m_txMiddle; | 287 MacTxMiddle* m_txMiddle; |
| 288 Mac48Address m_address; |
281 Ptr<WifiMacQueue> m_queue; | 289 Ptr<WifiMacQueue> m_queue; |
282 Callback<void, Mac48Address, uint8_t, bool> m_blockAckInactivityTimeout; | 290 Callback<void, Mac48Address, uint8_t, bool> m_blockAckInactivityTimeout; |
283 Callback<void, Mac48Address, uint8_t> m_blockPackets; | 291 Callback<void, Mac48Address, uint8_t> m_blockPackets; |
284 Callback<void, Mac48Address, uint8_t> m_unblockPackets; | 292 Callback<void, Mac48Address, uint8_t> m_unblockPackets; |
285 }; | 293 }; |
286 | 294 |
287 } //namespace ns3 | 295 } //namespace ns3 |
288 | 296 |
289 #endif /* BLOCK_ACK_MANAGER_H */ | 297 #endif /* BLOCK_ACK_MANAGER_H */ |
LEFT | RIGHT |