A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
block-ack-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009, 2010 MIRKO BANCHI
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mirko Banchi <mk.banchi@gmail.com>
7 */
8
9#ifndef BLOCK_ACK_MANAGER_H
10#define BLOCK_ACK_MANAGER_H
11
12#include "block-ack-type.h"
13#include "gcr-manager.h"
16#include "wifi-mac-header.h"
17#include "wifi-mpdu.h"
18#include "wifi-tx-vector.h"
19
20#include "ns3/nstime.h"
21#include "ns3/object.h"
22#include "ns3/traced-callback.h"
23
24#include <map>
25#include <optional>
26
27namespace ns3
28{
29
34class WifiMacQueue;
35class MacRxMiddle;
36
37/**
38 * @brief Manages all block ack agreements for an originator station.
39 * @ingroup wifi
40 */
41class BlockAckManager : public Object
42{
43 private:
44 /**
45 * Enumeration for the statuses of a buffered MPDU
46 */
53
54 public:
55 /**
56 * @brief Get the type ID.
57 * @return the object TypeId
58 */
59 static TypeId GetTypeId();
60
62 ~BlockAckManager() override;
63
64 // Delete copy constructor and assignment operator to avoid misuse
67
68 /// optional const reference to OriginatorBlockAckAgreement
70 std::optional<std::reference_wrapper<const OriginatorBlockAckAgreement>>;
71 /// optional const reference to RecipientBlockAckAgreement
73 std::optional<std::reference_wrapper<const RecipientBlockAckAgreement>>;
74
75 /**
76 * @param recipient MAC address of the recipient
77 * @param tid Traffic ID
78 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
79 *
80 * @return a const reference to the block ack agreement with the given recipient, if it exists
81 *
82 * Check if we are the originator of an existing block ack agreement with the given recipient.
83 */
85 const Mac48Address& recipient,
86 uint8_t tid,
87 std::optional<Mac48Address> gcrGroupAddr = std::nullopt) const;
88
89 /**
90 * @param originator MAC address of the originator
91 * @param tid Traffic ID
92 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
93 *
94 * @return a const reference to the block ack agreement with the given originator, if it exists
95 *
96 * Check if we are the recipient of an existing block ack agreement with the given originator.
97 */
99 const Mac48Address& originator,
100 uint8_t tid,
101 std::optional<Mac48Address> gcrGroupAddr = std::nullopt) const;
102
103 /**
104 * @param reqHdr Relative Add block ack request (action frame).
105 * @param recipient Address of peer station involved in block ack mechanism.
106 *
107 * Creates a new originator block ack agreement in pending state. When a ADDBA response
108 * with a successful status code is received, the relative agreement becomes established.
109 */
111 const Mac48Address& recipient);
112 /**
113 * @param recipient Address of peer station involved in block ack mechanism.
114 * @param tid traffic ID of transmitted packet.
115 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
116 *
117 * Invoked when a recipient reject a block ack agreement or when a DELBA frame
118 * is Received/Transmitted.
119 */
120 void DestroyOriginatorAgreement(const Mac48Address& recipient,
121 uint8_t tid,
122 std::optional<Mac48Address> gcrGroupAddr);
123 /**
124 * @param respHdr Relative Add block ack response (action frame).
125 * @param recipient Address of peer station involved in block ack mechanism.
126 * @param startingSeq the updated starting sequence number
127 *
128 * Invoked upon receipt of a ADDBA response frame from <i>recipient</i>.
129 */
131 const Mac48Address& recipient,
132 uint16_t startingSeq);
133
134 /**
135 * @param respHdr Add block ack response from originator (action
136 * frame).
137 * @param originator Address of peer station involved in block ack
138 * mechanism.
139 * @param startingSeq Sequence number of the first MPDU of all
140 * packets for which block ack was negotiated.
141 * @param rxMiddle the MAC RX Middle on this station
142 *
143 * This function is typically invoked only by ns3::WifiMac
144 * when the STA (which may be non-AP in ESS, or in an IBSS) has
145 * received an ADDBA Request frame and is transmitting an ADDBA
146 * Response frame. At this point the frame exchange manager must
147 * allocate buffers to collect all correctly received packets belonging
148 * to the category for which block ack was negotiated.
149 */
151 const Mac48Address& originator,
152 uint16_t startingSeq,
153 Ptr<MacRxMiddle> rxMiddle);
154 /**
155 * Destroy a recipient Block Ack agreement.
156 *
157 * @param originator the originator MAC address
158 * @param tid the TID associated with the Block Ack agreement
159 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
160 */
161 void DestroyRecipientAgreement(const Mac48Address& originator,
162 uint8_t tid,
163 std::optional<Mac48Address> gcrGroupAddr);
164
165 /**
166 * @param mpdu MPDU to store.
167 *
168 * Stores <i>mpdu</i> for a possible future retransmission. Retransmission occurs
169 * if the packet, in a Block Ack frame, is indicated by recipient as not received.
170 */
171 void StorePacket(Ptr<WifiMpdu> mpdu);
172
173 /**
174 * @param mpdu groupcast MPDU to store.
175 * @param members intended recipients for the groupcast MPDU.
176 *
177 * Stores <i>mpdu</i> for a possible future retransmission. Retransmission occurs
178 * if the packet, in a GCR Block Ack frame, is indicated by recipient as not received.
179 */
180 void StoreGcrPacket(Ptr<WifiMpdu> mpdu, const GcrManager::GcrMembers& members);
181
182 /**
183 * Invoked upon receipt of an Ack frame on the given link after the transmission of a
184 * QoS data frame sent under an established block ack agreement. Remove the acknowledged
185 * frame from the outstanding packets and update the starting sequence number of the
186 * transmit window, if needed.
187 *
188 * @param linkId the ID of the given link
189 * @param mpdu The acknowledged MPDU.
190 */
191 void NotifyGotAck(uint8_t linkId, Ptr<const WifiMpdu> mpdu);
192 /**
193 * Invoked upon missed reception of an Ack frame on the given link after the
194 * transmission of a QoS data frame sent under an established block ack agreement.
195 * Remove the acknowledged frame from the outstanding packets and insert it in the
196 * retransmission queue.
197 *
198 * @param linkId the ID of the given link
199 * @param mpdu The unacknowledged MPDU.
200 */
201 void NotifyMissedAck(uint8_t linkId, Ptr<WifiMpdu> mpdu);
202 /**
203 * @param linkId the ID of the given link
204 * @param blockAck The received BlockAck frame.
205 * @param recipient Sender of BlockAck frame.
206 * @param tids the set of TIDs the acknowledged MPDUs belong to
207 * @param index the index of the Per AID TID Info subfield, in case of Multi-STA
208 * Block Ack, or 0, otherwise
209 * @return a pair of values indicating the number of successfully received MPDUs
210 * and the number of failed MPDUs
211 *
212 * Invoked upon receipt of a Block Ack frame on the given link. Typically, this function
213 * is called by the frame exchange manager. Performs a check on which MPDUs, previously sent
214 * with Ack Policy set to Block Ack, were correctly received by the recipient.
215 * An acknowledged MPDU is removed from the buffer, retransmitted otherwise.
216 * Note that <i>tids</i> is only used if <i>blockAck</i> is a Multi-STA Block Ack
217 * using All-ack context.
218 */
219 std::pair<uint16_t, uint16_t> NotifyGotBlockAck(uint8_t linkId,
220 const CtrlBAckResponseHeader& blockAck,
221 const Mac48Address& recipient,
222 const std::set<uint8_t>& tids,
223 size_t index = 0);
224
225 /**
226 * @param linkId the ID of the given link
227 * @param blockAck The received BlockAck frame.
228 * @param recipient Sender of BlockAck frame.
229 * @param members the list of member STAs for that GCR group
230 * @return a pair of values indicating the number of successfully received MPDUs
231 * and the number of failed MPDUs if GCR Block Ack frames for all member STAs
232 * have been received.
233 *
234 * Invoked upon receipt of a GCR Block Ack frame on the given link. Typically, this function
235 * is called by the frame exchange manager. Stores the received Block Ack response for each
236 * GCR member STA. Once all responses have been received, it performs a check on which MPDUs,
237 * previously sent with Ack Policy set to Block Ack, were correctly received by the recipient.
238 * An acknowledged MPDU is removed from the buffer, retransmitted otherwise.
239 */
240 std::optional<std::pair<uint16_t, uint16_t>> NotifyGotGcrBlockAck(
241 uint8_t linkId,
242 const CtrlBAckResponseHeader& blockAck,
243 const Mac48Address& recipient,
244 const GcrManager::GcrMembers& members);
245
246 /**
247 * @param linkId the ID of the given link
248 * @param recipient Sender of the expected BlockAck frame.
249 * @param tid Traffic ID.
250 *
251 * Invoked upon missed reception of a block ack frame on the given link. Typically, this
252 * function is called by ns3::QosTxop object. Performs a check on which MPDUs, previously
253 * sent with ack policy set to Block Ack, should be placed in the retransmission queue.
254 */
255 void NotifyMissedBlockAck(uint8_t linkId, const Mac48Address& recipient, uint8_t tid);
256 /**
257 * @param originator MAC address of the sender of the Block Ack Request
258 * @param tid Traffic ID
259 * @param startingSeq the starting sequence number in the Block Ack Request
260 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack Request frame)
261 *
262 * Perform required actions upon receiving a Block Ack Request frame.
263 */
264 void NotifyGotBlockAckRequest(const Mac48Address& originator,
265 uint8_t tid,
266 uint16_t startingSeq,
267 std::optional<Mac48Address> gcrGroupAddr = std::nullopt);
268
269 /**
270 * @param mpdu the received MPDU
271 *
272 * Perform required actions upon receiving an MPDU.
273 */
275 /**
276 * @param recipient Address of peer station involved in block ack mechanism.
277 * @param tid Traffic ID.
278 *
279 * @return the number of packets buffered for a specified agreement
280 *
281 * Returns the number of packets buffered for a specified agreement. This methods doesn't return
282 * the number of buffered MPDUs but the number of buffered MSDUs.
283 */
284 uint32_t GetNBufferedPackets(const Mac48Address& recipient, uint8_t tid) const;
285 /**
286 * @param recipient Address of peer station involved in block ack mechanism.
287 * @param tid Traffic ID of transmitted packet.
288 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
289 *
290 * Marks an originator agreement as rejected. This happens if <i>recipient</i> station reject
291 * block ack setup by an ADDBA Response frame with a failure status code. For now we assume
292 * that every QoS station accepts a block ack setup.
293 */
295 uint8_t tid,
296 std::optional<Mac48Address> gcrGroupAddr);
297 /**
298 * @param recipient Address of peer station involved in block ack mechanism.
299 * @param tid Traffic ID of transmitted packet.
300 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
301 *
302 * Marks an originator agreement after not receiving response to ADDBA request. During this
303 * state any packets in queue will be transmitted using normal MPDU. This also unblocks
304 * recipient address.
305 */
307 uint8_t tid,
308 std::optional<Mac48Address> gcrGroupAddr);
309 /**
310 * @param recipient Address of peer station involved in block ack mechanism.
311 * @param tid Traffic ID of transmitted packet.
312 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
313 *
314 * Set Originator BA agreement to a transitory state to reset it after not receiving response
315 * to ADDBA request.
316 */
317 void NotifyOriginatorAgreementReset(const Mac48Address& recipient,
318 uint8_t tid,
319 std::optional<Mac48Address> gcrGroupAddr);
320 /**
321 * @param nPackets Minimum number of packets for use of block ack.
322 *
323 * Upon receipt of a BlockAck frame, if total number of packets (packets in WifiMacQueue
324 * and buffered packets) is greater of <i>nPackets</i>, they are transmitted using block ack
325 * mechanism.
326 */
327 void SetBlockAckThreshold(uint8_t nPackets);
328
329 /**
330 * @param queue The WifiMacQueue object.
331 */
332 void SetQueue(const Ptr<WifiMacQueue> queue);
333
334 /**
335 * Set block ack inactivity callback
336 * @param callback the block ack inactivity callback function
337 */
339 Callback<void, Mac48Address, uint8_t, bool, std::optional<Mac48Address>> callback);
340 /**
341 * Set block destination callback
342 * @param callback the block destination callback
343 */
345 /**
346 * Set unblock destination callback
347 * @param callback the unblock destination callback
348 */
350
351 /**
352 * This function returns true if a block ack agreement is established with the
353 * given recipient for the given TID and there is at least an outstanding MPDU
354 * for such agreement whose lifetime is not expired.
355 *
356 * @param tid Traffic ID
357 * @param recipient MAC address of the recipient
358 *
359 * @returns true if BAR retransmission needed
360 */
361 bool NeedBarRetransmission(uint8_t tid, const Mac48Address& recipient);
362
363 /**
364 * This function returns true if a GCR block ack agreement is established with the given
365 * recipient, for the given TID, for the given GCR group address and there is at least an
366 * outstanding MPDU for such agreement whose lifetime is not expired.
367 *
368 * @param gcrGroupAddress the GCR group address
369 * @param tid Traffic ID
370 * @param recipient MAC address of the recipient
371 *
372 * @returns true if BAR retransmission needed
373 */
374 bool NeedGcrBarRetransmission(const Mac48Address& gcrGroupAddress,
375 const Mac48Address& recipient,
376 uint8_t tid) const;
377
378 /**
379 * This function returns the buffer size negotiated with the recipient.
380 *
381 * @param tid Traffic ID
382 * @param recipient MAC address of the recipient
383 *
384 * @returns the buffer size negotiated with the recipient
385 */
386 uint16_t GetRecipientBufferSize(const Mac48Address& recipient, uint8_t tid) const;
387 /**
388 * This function returns the starting sequence number of the transmit window.
389 *
390 * @param tid Traffic ID
391 * @param recipient MAC address of the recipient
392 *
393 * @returns the starting sequence number of the transmit window (WinStartO)
394 */
395 uint16_t GetOriginatorStartingSequence(const Mac48Address& recipient, uint8_t tid) const;
396
397 /**
398 * typedef for a callback to invoke when an MPDU is successfully ack'ed.
399 */
401 /**
402 * typedef for a callback to invoke when an MPDU is negatively ack'ed.
403 */
405 /**
406 * typedef for a callback to invoke when an MPDU is dropped.
407 */
409
410 /**
411 * @param callback the callback to invoke when a
412 * packet transmission was completed successfully.
413 */
414 void SetTxOkCallback(TxOk callback);
415 /**
416 * @param callback the callback to invoke when a
417 * packet transmission was completed unsuccessfuly.
418 */
419 void SetTxFailedCallback(TxFailed callback);
420 /**
421 * @param callback the callback to invoke when an old MPDU is dropped
422 */
424
425 /**
426 * TracedCallback signature for state changes.
427 *
428 * @param [in] now Time when the \pname{state} changed.
429 * @param [in] recipient MAC address of the recipient.
430 * @param [in] tid the TID.
431 * @param [in] state The state.
432 */
434 const Mac48Address& recipient,
435 uint8_t tid,
437
438 /**
439 * @param mpdu the discarded frame
440 *
441 * Notify the block ack manager that an MPDU has been discarded, e.g., because
442 * the MSDU lifetime expired. If there is an established block ack agreement,
443 * make the transmit window advance beyond the discarded frame. This also
444 * involves (i) the removal of frames that consequently become old from the
445 * retransmit queue and from the queue of the block ack agreement, and (ii) the
446 * scheduling of a BlockAckRequest.
447 */
449
450 /**
451 * @param recipient the recipient
452 * @param tid the TID
453 * @param gcrGroupAddr the GCR Group Address (only if the Block Ack Request is being used for
454 * the GCR service)
455 * @return the BlockAckRequest header for the established BA agreement
456 *
457 * Get the BlockAckRequest header for the established BA agreement
458 * (<i>recipient</i>,<i>tid</i>).
459 */
461 const Mac48Address& recipient,
462 uint8_t tid,
463 std::optional<Mac48Address> gcrGroupAddr = std::nullopt) const;
464
465 /**
466 * @param reqHdr the BlockAckRequest header
467 * @param hdr the 802.11 MAC header
468 *
469 * Enqueue the given BlockAckRequest into the queue storing the next BAR
470 * frames to transmit. If a BAR for the same recipient and TID is already present
471 * in the queue, it is replaced by the new one. If the given BAR is retransmitted,
472 * it is placed at the head of the queue, otherwise at the tail.
473 */
474 void ScheduleBar(const CtrlBAckRequestHeader& reqHdr, const WifiMacHeader& hdr);
475
476 /// agreement key typedef (MAC address and TID)
477 using AgreementKey = std::pair<Mac48Address, uint8_t>;
478
479 /**
480 * @return the list of BA agreements (identified by the recipient and TID pair) for which a BAR
481 * shall only be sent if there are queued data frames belonging to those agreements
482 */
483 const std::list<AgreementKey>& GetSendBarIfDataQueuedList() const;
484 /**
485 * Add the given (recipient, TID) pair to the list of BA agreements for which a BAR
486 * shall only be sent if there are queued data frames belonging to those agreements
487 *
488 * @param recipient the recipient
489 * @param tid the TID
490 */
491 void AddToSendBarIfDataQueuedList(const Mac48Address& recipient, uint8_t tid);
492 /**
493 * Remove the given (recipient, TID) pair from the list of BA agreements for which a BAR
494 * shall only be sent if there are queued data frames belonging to those agreements
495 *
496 * @param recipient the recipient
497 * @param tid the TID
498 */
499 void RemoveFromSendBarIfDataQueuedList(const Mac48Address& recipient, uint8_t tid);
500
501 /**
502 * This function returns the minimum buffer size from ADDBA Response frames sent by all members
503 * of a group address <i>groupAddress</i> for a given TID <i>tid</i>.
504 *
505 * @param groupAddress the group address
506 * @param tid the traffic ID.
507 *
508 * @return the GCR buffer size.
509 */
510 uint16_t GetGcrBufferSize(const Mac48Address& groupAddress, uint8_t tid) const;
511
512 /**
513 * This function returns the starting sequence number of the transmit window for a given GCR
514 * Block Ack agreement established with all members of a group address <i>groupAddress</i> for a
515 * given TID <i>tid</i>.
516 *
517 * @param groupAddress the group address
518 * @param tid Traffic ID
519 *
520 * @returns the starting sequence number of the transmit window (WinStartO)
521 */
522 uint16_t GetGcrStartingSequence(const Mac48Address& groupAddress, uint8_t tid) const;
523
524 /**
525 * Check if a GCR Block Ack agreement has been successfully established with all members of
526 * the group.
527 *
528 * @param gcrGroupAddress the GCR Group Address.
529 * @param tid the traffic ID.
530 * @param members members of the group.
531 * @return true if a GCR Block Ack agreement has been successfully established with all members
532 * of the group, false otherwise.
533 */
534 bool IsGcrAgreementEstablished(const Mac48Address& gcrGroupAddress,
535 uint8_t tid,
536 const GcrManager::GcrMembers& members) const;
537
538 /**
539 * Notify the block ack manager about the last groupcast MPDU transmitted with the GCR-UR
540 * service. If there is an established block ack agreement, it makes the transmit window
541 * advance beyond the transmitted MPDU.
542 *
543 * @param mpdu the groupcast MPDU
544 * @param recipients the list of recipients for the groupcast MPDU
545 */
547
548 protected:
549 void DoDispose() override;
550
551 private:
552 /**
553 * Inactivity timeout function for a Block Ack agreement
554 * @param recipient the recipient MAC address
555 * @param tid Traffic ID
556 * @param gcrGroupAddr the GCR Group Address (only if it a GCR Block Ack agreement)
557 */
558 void InactivityTimeout(const Mac48Address& recipient,
559 uint8_t tid,
560 std::optional<Mac48Address> gcrGroupAddr);
561
562 /**
563 * @param mpdu MPDU to store.
564 * @param recipient intended recipient for the stored MPDU.
565 * @param gcrGroupAddr the GCR Group Address (only if MPDU is transmitted using the GCR service)
566 *
567 * Stores <i>mpdu</i> for a possible future retransmission.
568 */
570 const Mac48Address& recipient,
571 std::optional<Mac48Address> gcrGroupAddr = std::nullopt);
572
573 /**
574 * typedef for a list of WifiMpdu.
575 */
576 using PacketQueue = std::list<Ptr<WifiMpdu>>;
577 /**
578 * typedef for an iterator for PacketQueue.
579 */
580 using PacketQueueI = std::list<Ptr<WifiMpdu>>::iterator;
581
582 /// AgreementKey-indexed map of originator block ack agreements
584 std::multimap<AgreementKey, std::pair<OriginatorBlockAckAgreement, PacketQueue>>;
585 /// An iterator for originator block ack agreements
586 using OriginatorAgreementsI = OriginatorAgreements::iterator;
587 /// A const iterator for originator block ack agreements
588 using OriginatorAgreementsCI = OriginatorAgreements::const_iterator;
589
590 /// AgreementKey-indexed map of recipient block ack agreements
591 using RecipientAgreements = std::multimap<AgreementKey, RecipientBlockAckAgreement>;
592 /// An iterator for recipient block ack agreements
593 using RecipientAgreementsI = RecipientAgreements::iterator;
594 /// A const iterator for recipient block ack agreements
595 using RecipientAgreementsCI = RecipientAgreements::const_iterator;
596
597 /**
598 * @param recipient MAC address of the recipient
599 * @param tid Traffic ID
600 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
601 *
602 * @return an iterator to the block ack agreement
603 */
605 const Mac48Address& recipient,
606 uint8_t tid,
607 std::optional<Mac48Address> gcrGroupAddr = std::nullopt);
608
609 /**
610 * @param recipient MAC address of the recipient
611 * @param tid Traffic ID
612 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
613 *
614 * @return a const iterator to the block ack agreement
615 */
617 const Mac48Address& recipient,
618 uint8_t tid,
619 std::optional<Mac48Address> gcrGroupAddr = std::nullopt) const;
620
621 /**
622 * @param originator MAC address of the originator
623 * @param tid Traffic ID
624 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
625 *
626 * @return an iterator to the block ack agreement
627 */
629 const Mac48Address& originator,
630 uint8_t tid,
631 std::optional<Mac48Address> gcrGroupAddr = std::nullopt);
632
633 /**
634 * @param originator MAC address of the originator
635 * @param tid Traffic ID
636 * @param gcrGroupAddr the GCR Group Address (only if it is a GCR Block Ack agreement)
637 *
638 * @return a const iterator to the block ack agreement
639 */
641 const Mac48Address& originator,
642 uint8_t tid,
643 std::optional<Mac48Address> gcrGroupAddr = std::nullopt) const;
644
645 /**
646 * Handle the given in flight MPDU based on its given status. If the status is
647 * ACKNOWLEDGED, the MPDU is removed from both the EDCA queue and the queue of
648 * in flight MPDUs. If the status is TO_RETRANSMIT, the MPDU is only removed
649 * from the queue of in flight MPDUs. Note that the MPDU is removed from both
650 * queues (independently of the status) if the MPDU is not stored in the EDCA
651 * queue, is an old packet or its lifetime expired.
652 *
653 * @param linkId the ID of the link on which the MPDU has been transmitted
654 * @param mpduIt an iterator pointing to the MPDU in the queue of in flight MPDUs
655 * @param status the status of the in flight MPDU
656 * @param it iterator pointing to the Block Ack agreement
657 * @param now the current time
658 * @return an iterator pointing to the next MPDU in the queue of in flight MPDUs
659 */
660 PacketQueueI HandleInFlightMpdu(uint8_t linkId,
661 PacketQueueI mpduIt,
662 MpduStatus status,
663 const OriginatorAgreementsI& it,
664 const Time& now);
665
666 /**
667 * Handle discarded MPDU by making the transmit window advance beyond the discarded frame.
668 * This also involves (i) the removal of frames that consequently become old from the
669 * retransmit queue and from the queue of the block ack agreement, and (ii) the
670 * scheduling of a BlockAckRequest.
671 *
672 * @param mpdu the discarded MPDU
673 * @param iter an iterator to the corresponding agreement
674 */
676
677 /**
678 * This data structure contains, for each originator block ack agreement (recipient, TID),
679 * a set of packets for which an ack by block ack is requested.
680 * Every packet or fragment indicated as correctly received in BlockAck frame is
681 * erased from this data structure. Pushed back in retransmission queue otherwise.
682 */
684 RecipientAgreements m_recipientAgreements; //!< Recipient Block Ack agreements
685
686 std::list<AgreementKey> m_sendBarIfDataQueued; ///< list of BA agreements for which a BAR shall
687 ///< only be sent if data is queued
688
689 /// List of received GCR BlockAck frames indexed by originator
690 using GcrBlockAcks = std::map<Mac48Address, CtrlBAckResponseHeader>;
691 std::map<Mac48Address /* GCR group address */, GcrBlockAcks>
692 m_gcrBlockAcks; ///< received GCR Block ACKs
693
694 uint8_t m_blockAckThreshold; ///< block ack threshold
697 m_blockAckInactivityTimeout; ///< BlockAck inactivity timeout callback
700 TxOk m_txOkCallback; ///< transmit OK callback
701 TxFailed m_txFailedCallback; ///< transmit failed callback
702 DroppedOldMpdu m_droppedOldMpduCallback; ///< the dropped MPDU callback
703
704 /**
705 * The trace source fired when a state transition occurred.
706 */
709};
710
711} // namespace ns3
712
713#endif /* BLOCK_ACK_MANAGER_H */
std::optional< std::pair< uint16_t, uint16_t > > NotifyGotGcrBlockAck(uint8_t linkId, const CtrlBAckResponseHeader &blockAck, const Mac48Address &recipient, const GcrManager::GcrMembers &members)
void SetTxFailedCallback(TxFailed callback)
std::pair< Mac48Address, uint8_t > AgreementKey
agreement key typedef (MAC address and TID)
void UpdateOriginatorAgreement(const MgtAddBaResponseHeader &respHdr, const Mac48Address &recipient, uint16_t startingSeq)
Callback< void, Mac48Address, uint8_t > m_unblockPackets
unblock packets callback
OriginatorAgreements::iterator OriginatorAgreementsI
An iterator for originator block ack agreements.
void SetQueue(const Ptr< WifiMacQueue > queue)
void SetTxOkCallback(TxOk callback)
std::map< Mac48Address, CtrlBAckResponseHeader > GcrBlockAcks
List of received GCR BlockAck frames indexed by originator.
OriginatorAgreementsI GetOriginatorBaAgreement(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
CtrlBAckRequestHeader GetBlockAckReqHeader(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr=std::nullopt) const
void NotifyOriginatorAgreementNoReply(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
uint8_t m_blockAckThreshold
block ack threshold
void NotifyLastGcrUrTx(Ptr< const WifiMpdu > mpdu, const GcrManager::GcrMembers &recipients)
Notify the block ack manager about the last groupcast MPDU transmitted with the GCR-UR service.
RecipientAgreements m_recipientAgreements
Recipient Block Ack agreements.
static TypeId GetTypeId()
Get the type ID.
TracedCallback< Time, Mac48Address, uint8_t, OriginatorBlockAckAgreement::State > m_originatorAgreementState
The trace source fired when a state transition occurred.
void SetBlockAckThreshold(uint8_t nPackets)
DroppedOldMpdu m_droppedOldMpduCallback
the dropped MPDU callback
std::list< Ptr< WifiMpdu > > PacketQueue
typedef for a list of WifiMpdu.
void SetDroppedOldMpduCallback(DroppedOldMpdu callback)
std::multimap< AgreementKey, RecipientBlockAckAgreement > RecipientAgreements
AgreementKey-indexed map of recipient block ack agreements.
TxFailed m_txFailedCallback
transmit failed callback
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set unblock destination callback.
std::optional< std::reference_wrapper< const OriginatorBlockAckAgreement > > OriginatorAgreementOptConstRef
optional const reference to OriginatorBlockAckAgreement
Ptr< WifiMacQueue > m_queue
queue
RecipientAgreements::iterator RecipientAgreementsI
An iterator for recipient block ack agreements.
uint16_t GetRecipientBufferSize(const Mac48Address &recipient, uint8_t tid) const
This function returns the buffer size negotiated with the recipient.
void NotifyOriginatorAgreementRejected(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
void CreateOriginatorAgreement(const MgtAddBaRequestHeader &reqHdr, const Mac48Address &recipient)
void CreateRecipientAgreement(const MgtAddBaResponseHeader &respHdr, const Mac48Address &originator, uint16_t startingSeq, Ptr< MacRxMiddle > rxMiddle)
Callback< void, Mac48Address, uint8_t, bool, std::optional< Mac48Address > > m_blockAckInactivityTimeout
BlockAck inactivity timeout callback.
OriginatorAgreements::const_iterator OriginatorAgreementsCI
A const iterator for originator block ack agreements.
void DestroyOriginatorAgreement(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
bool NeedGcrBarRetransmission(const Mac48Address &gcrGroupAddress, const Mac48Address &recipient, uint8_t tid) const
This function returns true if a GCR block ack agreement is established with the given recipient,...
void NotifyMissedBlockAck(uint8_t linkId, const Mac48Address &recipient, uint8_t tid)
OriginatorAgreements m_originatorAgreements
This data structure contains, for each originator block ack agreement (recipient, TID),...
void StorePacket(Ptr< WifiMpdu > mpdu)
void RemoveFromSendBarIfDataQueuedList(const Mac48Address &recipient, uint8_t tid)
Remove the given (recipient, TID) pair from the list of BA agreements for which a BAR shall only be s...
BlockAckManager & operator=(const BlockAckManager &)=delete
void NotifyGotAck(uint8_t linkId, Ptr< const WifiMpdu > mpdu)
Invoked upon receipt of an Ack frame on the given link after the transmission of a QoS data frame sen...
void AddToSendBarIfDataQueuedList(const Mac48Address &recipient, uint8_t tid)
Add the given (recipient, TID) pair to the list of BA agreements for which a BAR shall only be sent i...
void NotifyDiscardedMpdu(Ptr< const WifiMpdu > mpdu)
bool IsGcrAgreementEstablished(const Mac48Address &gcrGroupAddress, uint8_t tid, const GcrManager::GcrMembers &members) const
Check if a GCR Block Ack agreement has been successfully established with all members of the group.
void NotifyGotMpdu(Ptr< const WifiMpdu > mpdu)
void HandleDiscardedMpdu(Ptr< const WifiMpdu > mpdu, OriginatorAgreementsI iter)
Handle discarded MPDU by making the transmit window advance beyond the discarded frame.
Callback< void, Ptr< const WifiMpdu > > TxFailed
typedef for a callback to invoke when an MPDU is negatively ack'ed.
bool NeedBarRetransmission(uint8_t tid, const Mac48Address &recipient)
This function returns true if a block ack agreement is established with the given recipient for the g...
Callback< void, Ptr< const WifiMpdu > > TxOk
typedef for a callback to invoke when an MPDU is successfully ack'ed.
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
Set block destination callback.
void NotifyOriginatorAgreementReset(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
std::list< AgreementKey > m_sendBarIfDataQueued
list of BA agreements for which a BAR shall only be sent if data is queued
void DestroyRecipientAgreement(const Mac48Address &originator, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
Destroy a recipient Block Ack agreement.
uint32_t GetNBufferedPackets(const Mac48Address &recipient, uint8_t tid) const
PacketQueueI HandleInFlightMpdu(uint8_t linkId, PacketQueueI mpduIt, MpduStatus status, const OriginatorAgreementsI &it, const Time &now)
Handle the given in flight MPDU based on its given status.
std::list< Ptr< WifiMpdu > >::iterator PacketQueueI
typedef for an iterator for PacketQueue.
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool, std::optional< Mac48Address > > callback)
Set block ack inactivity callback.
OriginatorAgreementOptConstRef GetAgreementAsOriginator(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr=std::nullopt) const
RecipientAgreements::const_iterator RecipientAgreementsCI
A const iterator for recipient block ack agreements.
uint16_t GetOriginatorStartingSequence(const Mac48Address &recipient, uint8_t tid) const
This function returns the starting sequence number of the transmit window.
void NotifyGotBlockAckRequest(const Mac48Address &originator, uint8_t tid, uint16_t startingSeq, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
uint16_t GetGcrStartingSequence(const Mac48Address &groupAddress, uint8_t tid) const
This function returns the starting sequence number of the transmit window for a given GCR Block Ack a...
BlockAckManager(const BlockAckManager &)=delete
Callback< void, Ptr< const WifiMpdu > > DroppedOldMpdu
typedef for a callback to invoke when an MPDU is dropped.
uint16_t GetGcrBufferSize(const Mac48Address &groupAddress, uint8_t tid) const
This function returns the minimum buffer size from ADDBA Response frames sent by all members of a gro...
TxOk m_txOkCallback
transmit OK callback
MpduStatus
Enumeration for the statuses of a buffered MPDU.
void(* AgreementStateTracedCallback)(Time now, const Mac48Address &recipient, uint8_t tid, OriginatorBlockAckAgreement::State state)
TracedCallback signature for state changes.
std::pair< uint16_t, uint16_t > NotifyGotBlockAck(uint8_t linkId, const CtrlBAckResponseHeader &blockAck, const Mac48Address &recipient, const std::set< uint8_t > &tids, size_t index=0)
void DoDispose() override
Destructor implementation.
std::multimap< AgreementKey, std::pair< OriginatorBlockAckAgreement, PacketQueue > > OriginatorAgreements
AgreementKey-indexed map of originator block ack agreements.
std::optional< std::reference_wrapper< const RecipientBlockAckAgreement > > RecipientAgreementOptConstRef
optional const reference to RecipientBlockAckAgreement
void ScheduleBar(const CtrlBAckRequestHeader &reqHdr, const WifiMacHeader &hdr)
void InactivityTimeout(const Mac48Address &recipient, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr)
Inactivity timeout function for a Block Ack agreement.
Callback< void, Mac48Address, uint8_t > m_blockPackets
block packets callback
void DoStorePacket(Ptr< WifiMpdu > mpdu, const Mac48Address &recipient, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
void StoreGcrPacket(Ptr< WifiMpdu > mpdu, const GcrManager::GcrMembers &members)
RecipientAgreementsI GetRecipientBaAgreement(const Mac48Address &originator, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
RecipientAgreementOptConstRef GetAgreementAsRecipient(const Mac48Address &originator, uint8_t tid, std::optional< Mac48Address > gcrGroupAddr=std::nullopt) const
const std::list< AgreementKey > & GetSendBarIfDataQueuedList() const
std::map< Mac48Address, GcrBlockAcks > m_gcrBlockAcks
received GCR Block ACKs
void NotifyMissedAck(uint8_t linkId, Ptr< WifiMpdu > mpdu)
Invoked upon missed reception of an Ack frame on the given link after the transmission of a QoS data ...
Callback template class.
Definition callback.h:422
Headers for BlockAckRequest.
Headers for BlockAck response.
std::unordered_set< Mac48Address, WifiAddressHash > GcrMembers
MAC addresses of member STAs of a GCR group.
an EUI-48 address
This class handles duplicate detection and recomposition of fragments.
Implement the header for management frames of type Add Block Ack request.
Implement the header for management frames of type Add Block Ack response.
Object()
Constructor.
Definition object.cc:96
State
Represents the state for this agreement.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Implements the IEEE 802.11 MAC header.
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
Every class exported by the ns3 library is enclosed in the ns3 namespace.