Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(232)

Side by Side Diff: src/devices/wifi/block-ack-manager.h

Issue 144050: Full Compressed Block Ack support
Patch Set: first review Created 14 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2009 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"
30 #include "block-ack-agreement.h"
31 #include "ctrl-headers.h"
32 #include "qos-utils.h"
33
34 using namespace std;
35
36 namespace ns3 {
37
38 class MgtAddBaResponseHeader;
39 class MgtAddBaRequestHeader;
40 class MgtDelBaHeader;
41 class EdcaTxopN;
42 class WifiMacQueue;
43 /**
44 * \brief Manages all block ack agreements for an originator station.
45 */
46 class BlockAckManager
47 {
48 public:
49 BlockAckManager ();
50 ~BlockAckManager ();
51 /**
52 * \param recipient Address of peer station involved in block ack mechanism.
53 * \param tid Traffic ID.
54 *
55 * Checks if a block ack agreement exists with station addressed by·
56 * <i>recipient</i> for tid <i>tid</i>.
57 */
58 bool ExistsAgreement (Mac48Address recipient, uint8_t tid) const;
59 /**
60 * \param recipient Address of peer station involved in block ack mechanism.
61 * \param tid Traffic ID.
62 *
63 * Checks if an established block ack agreement exists with station addressed by·
64 * <i>recipient</i> for tid <i>tid</i>. A block ack agreement becomes establis hed
65 * upon receipt of an ADDBA response frame from <i>recipient</i> station.
66 * All MPDUs for which a block ack agreement in established state exists, are
67 * transmitted with ack policy subfield in Qos control field set to Block Ack.
68 */
69 bool ExistsEstablishedAgreement (Mac48Address recipient, uint8_t tid) const;
70 /**
71 * \param recipient Address of peer station involved in block ack mechanism.
72 * \param tid Traffic ID.
73 *
74 * Checks if a pending block ack agreement exists with station addressed by·
75 * <i>recipient</i> for tid <i>tid</i>. A block ack agreement is in pending
76 * state when an ADDBA response frame hasn't been received yet.
77 */
78 bool ExistsPendingAgreement (Mac48Address recipient, uint8_t tid) const;
79 /**
80 * \param recipient Address of peer station involved in block ack mechanism.
81 * \param tid Traffic ID.
82 *
83 * Checks if an inactive block ack agreement exists with station addressed by·
84 * <i>recipient</i> for tid <i>tid</i>. A block ack agreement becomes inactive
85 * if there are in transmission buffer and in WifiMacQueue only few MSDUs.
86 *However the agreement is not teared down.
87 */
88 bool ExistsInactiveAgreement (Mac48Address recipient, uint8_t tid) const;
89 /**
90 * \param recipient Address of peer station involved in block ack mechanism.
91 * \param tid Traffic ID.
92 *
93 * Checks if an unsuccessful block ack agreement exists with station addressed by·
94 * <i>recipient</i> for tid <i>tid</i>. For packets belonging to this agreeeme nt
95 * block ack won't be used.
96 */
97 bool ExistsUnsuccessfulAgreement (Mac48Address recipient, uint8_t tid) const;
98 /**·
99 * \param reqHdr Relative Add block ack request (action frame).
100 * \param recipient Address of peer station involved in block ack mechanism.
101 *
102 * Creates a new block ack agreement in pending state. When a ADDBA response·
103 * with a successful status code is received, the relative agreement becomes e stablished.·
104 */
105 void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipi ent);
106 /**·
107 * \param recipient Address of peer station involved in block ack mechanism.
108 * \param tid Tid Traffic id of transmitted packet.
109 *
110 * Invoked when a recipient reject a block ack agreement or when a Delba frame
111 * is Received/Trasmitted.
112 */
113 void DestroyAgreement (Mac48Address recipient, uint8_t tid);
114 /**
115 * \param respHdr Relative Add block ack response (action frame).
116 * \param recipient Address of peer station involved in block ack mechanism.
117 *
118 * Invoked upon receipt of a ADDBA response frame from <i>recipient</i>.
119 */
120 void UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address reci pient);
121 /**
122 * \param packet Packet to store.
123 * \param hdr 802.11 header for packet.
124 *
125 * Stores <i>packet</i> for a possible future retransmission. Retransmission o ccurs
126 * if the packet, in a block ack frame, is indicated by recipient as not recei ved.
127 */
128 void StorePacket (Ptr<const Packet> packet, const WifiMacHeader &hdr, Time tSt amp);
129 /**
130 * \param hdr 802.11 header of returned packet (if exists).
131 *
132 * This methods returns a packet (if exists) indicated as not received in
133 * corresponding block ack bitmap.
134 */
135 Ptr<const Packet> GetNextPacket (WifiMacHeader &hdr);
136 /**
137 * Returns true if there are packets that need of retransmission or at least a
138 * BAR is sheduled. Returns false othewise.
139 */
140 bool HasPackets (void) const;
141 /**
142 * If all packets for which a block ack was negotiated have been transmitted
143 * a block ack request is needed.
144 */
145 void GetNextBlockAckRequest (Ptr<const Packet> &req, WifiMacHeader &hdr, bool &immediate);
146 /**
147 * Returns true if all packets for which a block ack agreement was negotiated or refreshed
148 * have been transmitted.
149 */
150 bool IsBlockAckReqNeeded (void) const;
151 /**
152 * \param blockAck The received block ack frame.
153 * \param recipient Sender of block ack frame.
154 *
155 * Invoked upon receipt of a block ack frame. Typically, this function, is cal led
156 * by ns3::EdcaTxopN object. Performs a check on which MPDUs, previously sent
157 * with ack policy set to Block Ack, were correctly received by the recipient.·······
158 * An acknowldeged MPDU is removed from the buffer, retransmitted otherwise.··
159 */
160 void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipie nt);
161 /**
162 * \param recipient Address of peer station involved in block ack mechanism.
163 * \param tid Traffic ID.
164 *
165 * Returns number of packets buffered for a specified agreement. This methods doesn't return·
166 * number of buffered MPDUs but number of buffered MSDUs.
167 */
168 uint32_t GetNPacketsForAgreement (Mac48Address recipient, uint8_t tid) const;
169 /**
170 * \param recipient Address of peer station involved in block ack mechanism.
171 * \param tid Traffic ID.
172 *
173 * Returns number of packets for a specific agreeemnt that need retransmission .
174 * This methods doesn't return number of MPDUs that need retransmission but nu mber MSDUs.
175 */
176 uint32_t GetNRetryPacketsForAgreement (Mac48Address recipient, uint8_t tid) co nst;
177 /**
178 * \param recipient Address of peer station involved in block ack mechanism.
179 * \param tid Traffic ID of transmitted packet.
180 *
181 * Puts corresponding agreement in established state and updates number of pac kets
182 * and starting sequence field. Invoked typically after a block ack refresh.··
183 */
184 void NotifyEstablishedAgreement (Mac48Address recipient, uint8_t tid, uint16_t startingSeq);
185 /**
186 * \param recipient Address of peer station involved in block ack mechanism.
187 * \param tid Traffic ID of transmitted packet.
188 *
189 * Marks an agreement as unsuccessful. This happens if <i>recipient</i> statio n reject block ack setup
190 * by an ADDBAResponse frame with a failure status code. FOr now we assume tha t every QoS station accepts
191 * a block ack setup.
192 */
193 void NotifyUnsuccessfulAgreement (Mac48Address recipient, uint8_t tid);
194 /**
195 * \param recipient Address of peer station involved in block ack mechanism.
196 * \param tid Traffic ID of transmitted packet.
197 *
198 * This methods is typically invoked by ns3::EdcaTxopN object every time that a MPDU
199 * with ack policy subfield in Qos Control field set to Block Ack is transmitt ed.
200 * Is also invoked in trasmission of A-MSDUs many times as number of MSDU ther e are
201 * in the aggregated packet.
202 */
203 void NotifyMpduTransmission (Mac48Address recipient, uint8_t tid);
204 /**
205 * \param nPackets Minimum number of packets for use of block ack.
206 *
207 * Upon receipt of a block ack frame, if total number of packets (packets in W ifiMacQueue
208 * and buffered packets) is greater of <i>nPackets</i>, they are transmitted u sing block ack mechanism.···
209 */
210 void SetBlockAckThreshold (uint8_t nPackets);
211 /**
212 * \param queue The WifiMacQueue object.
213 */
214 void SetQueue (Ptr<WifiMacQueue> queue);
215 /**
216 * \param edca The EdcaTxopN object owner of this manager.
217 */
218 void SetEdca (Ptr<EdcaTxopN> edca);
219 /**
220 * \param bAckType Type of block ack
221 *
222 * See ctrl-headers.h for more details.
223 */
224 void SetBlockAckType (enum BlockAckType bAckType);
225 /**
226 * \param recipient Address of station involved in block ack mechanism.
227 * \param tid Traffic ID.
228 *
229 * This method is invoked by EdcaTxopN object upon receipt of a DELBA frame
230 * from recipient. The relative block ack agreement is destroied.
231 */
232 void TearDownBlockAck (Mac48Address recipient, uint8_t tid);
233 /**
234 * \param recipient Address of station involved in block ack mechanism.
235 * \param tid Traffic ID.
236 * \param sequence Starting sequence
237 *
238 * This method is typically invoked by ns3::EdcaTxopN object in order to refre sh block.
239 */
240 void RefreshBlockAck (Mac48Address recipient, uint8_t tid, uint16_t sequence);
241 /**
242 * \param Sequence number of the packet which fragment is part of.
243 *
244 * Returns true if another fragment with sequence number <i>sequenceNumber</i> is scheduled
245 * for retransmission.
246 */
247 bool HasOtherFragments (uint16_t sequenceNumber) const;
248 /**
249 * Returns size of the next packet that needs retransmission.
250 */
251 uint32_t GetNextPacketSize (void) const;
252 /**
253 * \param maxDelay Max delay for a buffered packet.
254 *·
255 * This method is always called by ns3::WifiMacQueue object and sets max delay equals
256 * to ns3:WifiMacQueue delay value.
257 */
258 void SetMaxPacketDelay (Time maxDelay);
259
260 private:
261 /* Invoked to verify if the number of packets in trasmission queue reaches m_b lockAckThreshold.·
262 * This function is invoked after reception of block ack frame and only if all stored packets
263 * for relative agreement was correctly received by recipient.
264 */
and.kirill 2009/11/10 17:15:26 Please, fix all comments. Doxygen requires /** ...
265 bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid);
266 /* Checks if there are in the queue other packets that could be send under blo ck ack.
267 * If yes adds this packets in current block ack exchange and realative agreem ent becomes established.
268 * However, number of packets exchanged in the current block ack, will not exc eed·
269 * the value of BufferSize in the corresponding BlockAckAgreement object.
270 */
271 bool SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid, uint16_t s tartingSeq);
272 /* Checks if all packets, for which a block ack agreement was established or r efreshed,
273 * have been transmitted. If yes, adds a pair in m_bAckReqs to indicate that·
274 * at next channel access a block ack request (for established agreement
275 * <i>recipient</i>,<i>tid</i>) is needed.
276 */
277 void ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t tid);
278 /* Schedules the transmission of a DELBA frame. */
279 void ScheduleDelBaFrame (Mac48Address recipient, uint8_t tid);
280 /* Clears the BAR queue removing BlockAckReqs having tid and address1 equal to·······
281 * <i>tid</i> and <i>recipient</i> respectively. Is typically invoked upon rec eipt of
282 * of a DELBA frame from <i>recipient</i>.
283 */
284 void RemoveScheduledBar (Mac48Address recipient, uint8_t tid);
285 /*
286 * This method removes packets whose lifetime was exceded.
287 */
288 void CleanupBuffers (void);
289
290 struct Item;
291 typedef std::list<Item> PacketQueue;
292 typedef std::list<Item>::iterator PacketQueueI;
293 typedef std::list<Item>::const_iterator PacketQueueCI;
294 ··
295 typedef std::map<std::pair<Mac48Address, uint8_t>,·
296 std::pair<BlockAckAgreement, PacketQueue> > Agreements;
297 typedef std::map<std::pair<Mac48Address, uint8_t>,·
298 std::pair<BlockAckAgreement, PacketQueue> >::iterator AgreementsI;
299 typedef std::map<std::pair<Mac48Address, uint8_t>,·
300 std::pair<BlockAckAgreement, PacketQueue> >::const_iterator Agreem entsCI;
301
302 struct Item {
303 Item ();
304 Item (Ptr<const Packet> packet,
305 const WifiMacHeader &hdr,
306 Time tStamp);
307 Ptr<const Packet> packet;
308 WifiMacHeader hdr;
309 Time timestamp;
310 };
311 ··
312 /* This data structure contains, for each block ack agreement (recipient, tid) , a set of packets
313 * for which an ack by block ack is requested.
314 * Every packet or fragment indicated as correctly received in block ack frame is·
315 * erased from this data structure. Pushed back in retransmission queue otherw ise.
316 */
317 Agreements m_agreements;
318 /* This list contains all iterators to stored packets that need to be retransm itted.
319 * A packet needs retransmission if it's indicated as not correctly recevied i n a block ack
320 * frame.
321 */
322 std::list<PacketQueueI> m_retryPackets;
323 /*·
324 * This data structure is used to keep track of all BlockAckReqs.
325 */
326 std::deque<std::pair<Item, bool> > m_bars;
327
328 Ptr<WifiMacQueue> m_queue;
329 Ptr<EdcaTxopN> m_edca;
330 ··
331 uint8_t m_blockAckThreshold;
332 enum BlockAckType m_blockAckType;
333 Time m_maxDelay;
334
335 };
336
337 } //namespace ns3
338
339 #endif /* BLOCK_ACK_MANAGER_H */
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b