79 * For more details see section 9.1.3.1 in 802.11 standard. |
82 * For more details see section 9.1.3.1 in 802.11 standard. |
80 */ |
83 */ |
81 class EdcaTxopN : public Dcf |
84 class EdcaTxopN : public Dcf |
82 { |
85 { |
83 public: |
86 public: |
|
87 /** |
|
88 * typedef for a callback to invoke when a |
|
89 * packet transmission was completed successfully. |
|
90 */ |
84 typedef Callback <void, const WifiMacHeader&> TxOk; |
91 typedef Callback <void, const WifiMacHeader&> TxOk; |
|
92 /** |
|
93 * typedef for a callback to invoke when a |
|
94 * packet transmission was failed. |
|
95 */ |
85 typedef Callback <void, const WifiMacHeader&> TxFailed; |
96 typedef Callback <void, const WifiMacHeader&> TxFailed; |
86 |
97 |
87 static TypeId GetTypeId (void); |
98 static TypeId GetTypeId (void); |
88 EdcaTxopN (); |
99 EdcaTxopN (); |
89 virtual ~EdcaTxopN (); |
100 virtual ~EdcaTxopN (); |
90 void DoDispose (); |
101 void DoDispose (); |
91 |
102 |
|
103 /** |
|
104 * Set MacLow associated with this EdcaTxopN. |
|
105 * |
|
106 * \param low MacLow |
|
107 */ |
92 void SetLow (Ptr<MacLow> low); |
108 void SetLow (Ptr<MacLow> low); |
93 void SetTxMiddle (MacTxMiddle *txMiddle); |
109 void SetTxMiddle (MacTxMiddle *txMiddle); |
|
110 /** |
|
111 * Set DcfManager this EdcaTxopN is associated to. |
|
112 * |
|
113 * \param manager DcfManager |
|
114 */ |
94 void SetManager (DcfManager *manager); |
115 void SetManager (DcfManager *manager); |
|
116 /** |
|
117 * \param callback the callback to invoke when a |
|
118 * packet transmission was completed successfully. |
|
119 */ |
95 void SetTxOkCallback (TxOk callback); |
120 void SetTxOkCallback (TxOk callback); |
|
121 /** |
|
122 * \param callback the callback to invoke when a |
|
123 * packet transmission was completed unsuccessfully. |
|
124 */ |
96 void SetTxFailedCallback (TxFailed callback); |
125 void SetTxFailedCallback (TxFailed callback); |
|
126 /** |
|
127 * Set WifiRemoteStationsManager this EdcaTxopN is associated to. |
|
128 * |
|
129 * \param remoteManager WifiRemoteStationManager |
|
130 */ |
97 void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager); |
131 void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> remoteManager); |
|
132 /** |
|
133 * Set type of station with the given type. |
|
134 * |
|
135 * \param type |
|
136 */ |
98 void SetTypeOfStation (enum TypeOfStation type); |
137 void SetTypeOfStation (enum TypeOfStation type); |
|
138 /** |
|
139 * Return type of station. |
|
140 * |
|
141 * \return type of station |
|
142 */ |
99 enum TypeOfStation GetTypeOfStation (void) const; |
143 enum TypeOfStation GetTypeOfStation (void) const; |
100 |
144 |
|
145 /** |
|
146 * Return the packet queue associated with this EdcaTxopN. |
|
147 * |
|
148 * \return WifiMacQueue |
|
149 */ |
101 Ptr<WifiMacQueue > GetQueue () const; |
150 Ptr<WifiMacQueue > GetQueue () const; |
102 virtual void SetMinCw (uint32_t minCw); |
151 virtual void SetMinCw (uint32_t minCw); |
103 virtual void SetMaxCw (uint32_t maxCw); |
152 virtual void SetMaxCw (uint32_t maxCw); |
104 virtual void SetAifsn (uint32_t aifsn); |
153 virtual void SetAifsn (uint32_t aifsn); |
105 virtual uint32_t GetMinCw (void) const; |
154 virtual uint32_t GetMinCw (void) const; |
106 virtual uint32_t GetMaxCw (void) const; |
155 virtual uint32_t GetMaxCw (void) const; |
107 virtual uint32_t GetAifsn (void) const; |
156 virtual uint32_t GetAifsn (void) const; |
108 |
157 |
|
158 /** |
|
159 * Return the MacLow associated with this EdcaTxopN. |
|
160 * |
|
161 * \return MacLow |
|
162 */ |
109 Ptr<MacLow> Low (void); |
163 Ptr<MacLow> Low (void); |
110 Ptr<MsduAggregator> GetMsduAggregator (void) const; |
164 Ptr<MsduAggregator> GetMsduAggregator (void) const; |
111 |
165 |
112 /* dcf notifications forwarded here */ |
166 /* dcf notifications forwarded here */ |
|
167 /** |
|
168 * Check if the EDCAF requires access. |
|
169 * |
|
170 * \return true if the EDCAF requires access, |
|
171 * false otherwise |
|
172 */ |
113 bool NeedsAccess (void) const; |
173 bool NeedsAccess (void) const; |
|
174 /** |
|
175 * Notify the EDCAF that access has been granted. |
|
176 */ |
114 void NotifyAccessGranted (void); |
177 void NotifyAccessGranted (void); |
|
178 /** |
|
179 * Notify the EDCAF that internal collision has occurred. |
|
180 */ |
115 void NotifyInternalCollision (void); |
181 void NotifyInternalCollision (void); |
|
182 /** |
|
183 * Notify the EDCAF that collision has occurred. |
|
184 */ |
116 void NotifyCollision (void); |
185 void NotifyCollision (void); |
117 /** |
186 /** |
118 * When a channel switching occurs, enqueued packets are removed. |
187 * When a channel switching occurs, enqueued packets are removed. |
119 */ |
188 */ |
120 void NotifyChannelSwitching (void); |
189 void NotifyChannelSwitching (void); |
121 |
190 |
122 /*event handlers*/ |
191 /* Event handlers */ |
|
192 /** |
|
193 * Event handler when a CTS is received. |
|
194 * |
|
195 * \param snr |
|
196 * \param txMode |
|
197 */ |
123 void GotCts (double snr, WifiMode txMode); |
198 void GotCts (double snr, WifiMode txMode); |
|
199 /** |
|
200 * Event handler when a CTS timeout has occurred. |
|
201 */ |
124 void MissedCts (void); |
202 void MissedCts (void); |
|
203 /** |
|
204 * Event handler when an ACK is received. |
|
205 * |
|
206 * \param snr |
|
207 * \param txMode |
|
208 */ |
125 void GotAck (double snr, WifiMode txMode); |
209 void GotAck (double snr, WifiMode txMode); |
|
210 /** |
|
211 * Event handler when a Block ACK is received. |
|
212 * |
|
213 * \param blockAck |
|
214 * \param recipient |
|
215 */ |
126 void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient); |
216 void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient); |
|
217 /** |
|
218 * Event handler when a Block ACK timeout has occurred. |
|
219 */ |
127 void MissedBlockAck (void); |
220 void MissedBlockAck (void); |
128 void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient); |
221 void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient); |
129 void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient); |
222 void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient); |
|
223 /** |
|
224 * Event handler when an ACK is received. |
|
225 */ |
130 void MissedAck (void); |
226 void MissedAck (void); |
|
227 /** |
|
228 * Start transmission for the next fragment. |
|
229 * This is called for fragment only. |
|
230 */ |
131 void StartNext (void); |
231 void StartNext (void); |
|
232 /** |
|
233 * Cancel the transmission. |
|
234 */ |
132 void Cancel (void); |
235 void Cancel (void); |
|
236 /** |
|
237 * Event handler when a transmission that |
|
238 * does not require an ACK has completed. |
|
239 */ |
133 void EndTxNoAck (void); |
240 void EndTxNoAck (void); |
134 |
241 |
|
242 /** |
|
243 * Restart access request if needed. |
|
244 */ |
135 void RestartAccessIfNeeded (void); |
245 void RestartAccessIfNeeded (void); |
|
246 /** |
|
247 * Request access from DCF manager if needed. |
|
248 */ |
136 void StartAccessIfNeeded (void); |
249 void StartAccessIfNeeded (void); |
|
250 /** |
|
251 * Check if the current packet should be sent with a RTS protection. |
|
252 * |
|
253 * \return true if RTS protection should be used, false otherwise |
|
254 */ |
137 bool NeedRts (void); |
255 bool NeedRts (void); |
|
256 /** |
|
257 * Check if RTS should be re-transmitted if CTS was missed. |
|
258 * |
|
259 * \return true if RTS should be re-transmitted, false otherwise |
|
260 */ |
138 bool NeedRtsRetransmission (void); |
261 bool NeedRtsRetransmission (void); |
|
262 /** |
|
263 * Check if DATA should be re-transmitted if ACK was missed. |
|
264 * |
|
265 * \return true if DATA should be re-transmitted, false otherwise |
|
266 */ |
139 bool NeedDataRetransmission (void); |
267 bool NeedDataRetransmission (void); |
|
268 /** |
|
269 * Check if the current packet should be fragmented. |
|
270 * |
|
271 * \return true if the current packet should be fragmented, |
|
272 * false otherwise |
|
273 */ |
140 bool NeedFragmentation (void) const; |
274 bool NeedFragmentation (void) const; |
|
275 /** |
|
276 * Calculate the size of the next fragment. |
|
277 * |
|
278 * \return the size of the next fragment |
|
279 */ |
141 uint32_t GetNextFragmentSize (void); |
280 uint32_t GetNextFragmentSize (void); |
|
281 /** |
|
282 * Calculate the size of the current fragment. |
|
283 * |
|
284 * \return the size of the current fragment |
|
285 */ |
142 uint32_t GetFragmentSize (void); |
286 uint32_t GetFragmentSize (void); |
|
287 /** |
|
288 * Calculate the offset for the current fragment. |
|
289 * |
|
290 * \return the offset for the current fragment |
|
291 */ |
143 uint32_t GetFragmentOffset (void); |
292 uint32_t GetFragmentOffset (void); |
|
293 /** |
|
294 * Check if the curren fragment is the last fragment. |
|
295 * |
|
296 * \return true if the curren fragment is the last fragment, |
|
297 * false otherwise |
|
298 */ |
144 bool IsLastFragment (void) const; |
299 bool IsLastFragment (void) const; |
|
300 /** |
|
301 * Continue to the next fragment. This method simply |
|
302 * increments the internal variable that keep track |
|
303 * of the current fragment number. |
|
304 */ |
145 void NextFragment (void); |
305 void NextFragment (void); |
|
306 /** |
|
307 * Get the next fragment from the packet with |
|
308 * appropriate Wifi header for the fragment. |
|
309 * |
|
310 * \param hdr |
|
311 * \return the fragment with the current fragment number |
|
312 */ |
146 Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr); |
313 Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr); |
147 |
314 |
|
315 /** |
|
316 * Set the access category of this EDCAF. |
|
317 * |
|
318 * \param ac |
|
319 */ |
148 void SetAccessCategory (enum AcIndex ac); |
320 void SetAccessCategory (enum AcIndex ac); |
|
321 /** |
|
322 * \param packet packet to send |
|
323 * \param hdr header of packet to send. |
|
324 * |
|
325 * Store the packet in the internal queue until it |
|
326 * can be sent safely. |
|
327 */ |
149 void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
328 void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
150 void SetMsduAggregator (Ptr<MsduAggregator> aggr); |
329 void SetMsduAggregator (Ptr<MsduAggregator> aggr); |
|
330 /** |
|
331 * \param packet packet to send |
|
332 * \param hdr header of packet to send. |
|
333 * |
|
334 * Store the packet in the front of the internal queue until it |
|
335 * can be sent safely. |
|
336 */ |
151 void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
337 void PushFront (Ptr<const Packet> packet, const WifiMacHeader &hdr); |
|
338 /** |
|
339 * Complete block ACK configuration. |
|
340 */ |
152 void CompleteConfig (void); |
341 void CompleteConfig (void); |
|
342 /** |
|
343 * Set threshold for block ACK mechanism. If number of packets in the |
|
344 * queue reaches the threshold, block ACK mechanism is used. |
|
345 * |
|
346 * \param threshold |
|
347 */ |
153 void SetBlockAckThreshold (uint8_t threshold); |
348 void SetBlockAckThreshold (uint8_t threshold); |
|
349 /** |
|
350 * Return the current threshold for block ACK mechanism. |
|
351 * |
|
352 * \return the current threshold for block ACK mechanism |
|
353 */ |
154 uint8_t GetBlockAckThreshold (void) const; |
354 uint8_t GetBlockAckThreshold (void) const; |
155 void SetBlockAckInactivityTimeout (uint16_t timeout); |
355 void SetBlockAckInactivityTimeout (uint16_t timeout); |
156 void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator); |
356 void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator); |
157 |
357 |
158 /** |
358 /** |
173 * SA = Address2 |
373 * SA = Address2 |
174 * DA = Address3 |
374 * DA = Address3 |
175 * If aggregating sta is an AP |
375 * If aggregating sta is an AP |
176 * SA = Address3 |
376 * SA = Address3 |
177 * DA = Address1 |
377 * DA = Address1 |
|
378 * |
|
379 * \param hdr |
|
380 * \return Mac48Address |
178 */ |
381 */ |
179 Mac48Address MapSrcAddressForAggregation (const WifiMacHeader &hdr); |
382 Mac48Address MapSrcAddressForAggregation (const WifiMacHeader &hdr); |
180 Mac48Address MapDestAddressForAggregation (const WifiMacHeader &hdr); |
383 Mac48Address MapDestAddressForAggregation (const WifiMacHeader &hdr); |
181 EdcaTxopN &operator = (const EdcaTxopN &); |
384 EdcaTxopN &operator = (const EdcaTxopN &); |
182 EdcaTxopN (const EdcaTxopN &); |
385 EdcaTxopN (const EdcaTxopN &); |
183 |
386 |
184 /* If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame |
387 /** |
|
388 * If number of packets in the queue reaches m_blockAckThreshold value, an ADDBARequest frame |
185 * is sent to destination in order to setup a block ack. |
389 * is sent to destination in order to setup a block ack. |
|
390 * |
|
391 * \return true if we tried to set up block ACK, false otherwise |
186 */ |
392 */ |
187 bool SetupBlockAckIfNeeded (); |
393 bool SetupBlockAckIfNeeded (); |
188 /* Sends an ADDBARequest to establish a block ack agreement with sta |
394 /** |
|
395 * Sends an ADDBARequest to establish a block ack agreement with sta |
189 * addressed by <i>recipient</i> for tid <i>tid</i>. |
396 * addressed by <i>recipient</i> for tid <i>tid</i>. |
|
397 * |
|
398 * \param recipient |
|
399 * \param tid |
|
400 * \param startSeq |
|
401 * \param timeout |
|
402 * \param immediateBAck |
190 */ |
403 */ |
191 void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq, |
404 void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startSeq, |
192 uint16_t timeout, bool immediateBAck); |
405 uint16_t timeout, bool immediateBAck); |
193 /* After that all packets, for which a block ack agreement was established, have been |
406 /** |
|
407 * After that all packets, for which a block ack agreement was established, have been |
194 * transmitted, we have to send a block ack request. |
408 * transmitted, we have to send a block ack request. |
|
409 * |
|
410 * \param bar |
195 */ |
411 */ |
196 void SendBlockAckRequest (const struct Bar &bar); |
412 void SendBlockAckRequest (const struct Bar &bar); |
197 /* For now is typically invoked to complete transmission of a packets sent with ack policy |
413 /** |
|
414 * For now is typically invoked to complete transmission of a packets sent with ack policy |
198 * Block Ack: the packet is buffered and dcf is reset. |
415 * Block Ack: the packet is buffered and dcf is reset. |
199 */ |
416 */ |
200 void CompleteTx (void); |
417 void CompleteTx (void); |
201 /* Verifies if dequeued packet has to be transmitted with ack policy Block Ack. This happens |
418 /** |
|
419 * Verifies if dequeued packet has to be transmitted with ack policy Block Ack. This happens |
202 * if an established block ack agreement exists with the receiver. |
420 * if an established block ack agreement exists with the receiver. |
203 */ |
421 */ |
204 void VerifyBlockAck (void); |
422 void VerifyBlockAck (void); |
205 |
423 |
206 AcIndex m_ac; |
424 AcIndex m_ac; |