A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
recipient-block-ack-agreement.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8#ifndef RECIPIENT_BLOCK_ACK_AGREEMENT_H
9#define RECIPIENT_BLOCK_ACK_AGREEMENT_H
10
11#include "block-ack-agreement.h"
12#include "block-ack-window.h"
13
14#include <map>
15
16namespace ns3
17{
18
19class WifiMpdu;
20class MacRxMiddle;
21class CtrlBAckResponseHeader;
22
23/**
24 * \ingroup wifi
25 * Maintains the scoreboard and the receive reordering buffer used by a recipient
26 * of a Block Ack agreement.
27 */
29{
30 public:
31 /**
32 * Constructor
33 *
34 * \param originator MAC address
35 * \param amsduSupported whether A-MSDU support is enabled
36 * \param tid Traffic ID
37 * \param bufferSize the buffer size (in number of MPDUs)
38 * \param timeout the timeout value
39 * \param startingSeq the starting sequence number
40 * \param htSupported whether HT support is enabled
41 */
43 bool amsduSupported,
44 uint8_t tid,
45 uint16_t bufferSize,
46 uint16_t timeout,
47 uint16_t startingSeq,
48 bool htSupported);
50
51 /**
52 * Set the MAC RX Middle to use.
53 *
54 * \param rxMiddle the MAC RX Middle to use
55 */
56 void SetMacRxMiddle(const Ptr<MacRxMiddle> rxMiddle);
57
58 /**
59 * Update both the scoreboard and the receive reordering buffer upon reception
60 * of the given MPDU.
61 *
62 * \param mpdu the received MPDU
63 */
65 /**
66 * Update both the scoreboard and the receive reordering buffer upon reception
67 * of a Block Ack Request.
68 *
69 * \param startingSequenceNumber the starting sequence number included in the
70 * received Block Ack Request
71 */
72 void NotifyReceivedBar(uint16_t startingSequenceNumber);
73 /**
74 * Set the Starting Sequence Number subfield of the Block Ack Starting Sequence
75 * Control subfield of the Block Ack frame and fill the block ack bitmap.
76 * For Multi-STA Block Acks, <i>index</i> identifies the Per AID TID Info
77 * subfield whose bitmap has to be filled.
78 *
79 * \param blockAckHeader the block ack header
80 * \param index the index of the Per AID TID Info subfield (Multi-STA Block Ack only)
81 */
82 void FillBlockAckBitmap(CtrlBAckResponseHeader* blockAckHeader, std::size_t index = 0) const;
83 /**
84 * This is called when a Block Ack agreement is destroyed to flush the
85 * received packets.
86 */
87 void Flush();
88
89 private:
90 /**
91 * Pass MSDUs or A-MSDUs up to the next MAC process if they are stored in
92 * the buffer in order of increasing value of the Sequence Number subfield
93 * starting with the MSDU or A-MSDU that has SN=WinStartB.
94 * Set WinStartB to the value of the Sequence Number subfield of the last
95 * MSDU or A-MSDU that was passed up to the next MAC process plus one.
96 */
98
99 /**
100 * Pass any complete MSDUs or A-MSDUs stored in the buffer with Sequence Number
101 * subfield values that are lower than the new value of WinStartB up to the next
102 * MAC process in order of increasing Sequence Number subfield value.
103 *
104 * \param newWinStartB the new value of WinStartB
105 */
106 void PassBufferedMpdusWithSeqNumberLessThan(uint16_t newWinStartB);
107
108 /// The key of a buffered MPDU is the pair (MPDU sequence number, pointer to WinStartB)
109 typedef std::pair<uint16_t, uint16_t*> Key;
110
111 /// Comparison functor used to sort the buffered MPDUs
112 struct Compare
113 {
114 /**
115 * Functional operator for sorting the buffered MPDUs.
116 *
117 * \param a the key of first buffered MPDU (\see Key)
118 * \param b the key of second buffered MPDU (\see Key)
119 * \return true if first key is smaller than second
120 */
121 bool operator()(const Key& a, const Key& b) const;
122 };
123
124 BlockAckWindow m_scoreboard; ///< recipient's scoreboard
125 uint16_t m_winStartB; ///< starting SN for the reordering buffer
126 std::size_t m_winSizeB; ///< size of the receive reordering buffer
127 std::map<Key, Ptr<const WifiMpdu>, Compare>
128 m_bufferedMpdus; ///< buffered MPDUs sorted by Seq Number
129 Ptr<MacRxMiddle> m_rxMiddle; ///< the MAC RX Middle on this station
130};
131
132} // namespace ns3
133
134#endif /* RECIPIENT_BLOCK_ACK_AGREEMENT_H */
Maintains information for a block ack agreement.
Block ack window.
Headers for BlockAck response.
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
Maintains the scoreboard and the receive reordering buffer used by a recipient of a Block Ack agreeme...
Ptr< MacRxMiddle > m_rxMiddle
the MAC RX Middle on this station
void PassBufferedMpdusWithSeqNumberLessThan(uint16_t newWinStartB)
Pass any complete MSDUs or A-MSDUs stored in the buffer with Sequence Number subfield values that are...
BlockAckWindow m_scoreboard
recipient's scoreboard
void NotifyReceivedBar(uint16_t startingSequenceNumber)
Update both the scoreboard and the receive reordering buffer upon reception of a Block Ack Request.
void Flush()
This is called when a Block Ack agreement is destroyed to flush the received packets.
void FillBlockAckBitmap(CtrlBAckResponseHeader *blockAckHeader, std::size_t index=0) const
Set the Starting Sequence Number subfield of the Block Ack Starting Sequence Control subfield of the ...
void PassBufferedMpdusUntilFirstLost()
Pass MSDUs or A-MSDUs up to the next MAC process if they are stored in the buffer in order of increas...
std::pair< uint16_t, uint16_t * > Key
The key of a buffered MPDU is the pair (MPDU sequence number, pointer to WinStartB)
void NotifyReceivedMpdu(Ptr< const WifiMpdu > mpdu)
Update both the scoreboard and the receive reordering buffer upon reception of the given MPDU.
RecipientBlockAckAgreement(Mac48Address originator, bool amsduSupported, uint8_t tid, uint16_t bufferSize, uint16_t timeout, uint16_t startingSeq, bool htSupported)
Constructor.
std::map< Key, Ptr< const WifiMpdu >, Compare > m_bufferedMpdus
buffered MPDUs sorted by Seq Number
uint16_t m_winStartB
starting SN for the reordering buffer
std::size_t m_winSizeB
size of the receive reordering buffer
void SetMacRxMiddle(const Ptr< MacRxMiddle > rxMiddle)
Set the MAC RX Middle to use.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout
Comparison functor used to sort the buffered MPDUs.
bool operator()(const Key &a, const Key &b) const
Functional operator for sorting the buffered MPDUs.