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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19#ifndef RECIPIENT_BLOCK_ACK_AGREEMENT_H
20#define RECIPIENT_BLOCK_ACK_AGREEMENT_H
21
22#include "block-ack-agreement.h"
23#include "block-ack-window.h"
24
25#include <map>
26
27namespace ns3
28{
29
30class WifiMpdu;
31class MacRxMiddle;
32class CtrlBAckResponseHeader;
33
34/**
35 * \ingroup wifi
36 * Maintains the scoreboard and the receive reordering buffer used by a recipient
37 * of a Block Ack agreement.
38 */
40{
41 public:
42 /**
43 * Constructor
44 *
45 * \param originator MAC address
46 * \param amsduSupported whether A-MSDU support is enabled
47 * \param tid Traffic ID
48 * \param bufferSize the buffer size (in number of MPDUs)
49 * \param timeout the timeout value
50 * \param startingSeq the starting sequence number
51 * \param htSupported whether HT support is enabled
52 */
54 bool amsduSupported,
55 uint8_t tid,
56 uint16_t bufferSize,
57 uint16_t timeout,
58 uint16_t startingSeq,
59 bool htSupported);
61
62 /**
63 * Set the MAC RX Middle to use.
64 *
65 * \param rxMiddle the MAC RX Middle to use
66 */
67 void SetMacRxMiddle(const Ptr<MacRxMiddle> rxMiddle);
68
69 /**
70 * Update both the scoreboard and the receive reordering buffer upon reception
71 * of the given MPDU.
72 *
73 * \param mpdu the received MPDU
74 */
76 /**
77 * Update both the scoreboard and the receive reordering buffer upon reception
78 * of a Block Ack Request.
79 *
80 * \param startingSequenceNumber the starting sequence number included in the
81 * received Block Ack Request
82 */
83 void NotifyReceivedBar(uint16_t startingSequenceNumber);
84 /**
85 * Set the Starting Sequence Number subfield of the Block Ack Starting Sequence
86 * Control subfield of the Block Ack frame and fill the block ack bitmap.
87 * For Multi-STA Block Acks, <i>index</i> identifies the Per AID TID Info
88 * subfield whose bitmap has to be filled.
89 *
90 * \param blockAckHeader the block ack header
91 * \param index the index of the Per AID TID Info subfield (Multi-STA Block Ack only)
92 */
93 void FillBlockAckBitmap(CtrlBAckResponseHeader* blockAckHeader, std::size_t index = 0) const;
94 /**
95 * This is called when a Block Ack agreement is destroyed to flush the
96 * received packets.
97 */
98 void Flush();
99
100 private:
101 /**
102 * Pass MSDUs or A-MSDUs up to the next MAC process if they are stored in
103 * the buffer in order of increasing value of the Sequence Number subfield
104 * starting with the MSDU or A-MSDU that has SN=WinStartB.
105 * Set WinStartB to the value of the Sequence Number subfield of the last
106 * MSDU or A-MSDU that was passed up to the next MAC process plus one.
107 */
109
110 /**
111 * Pass any complete MSDUs or A-MSDUs stored in the buffer with Sequence Number
112 * subfield values that are lower than the new value of WinStartB up to the next
113 * MAC process in order of increasing Sequence Number subfield value.
114 *
115 * \param newWinStartB the new value of WinStartB
116 */
117 void PassBufferedMpdusWithSeqNumberLessThan(uint16_t newWinStartB);
118
119 /// The key of a buffered MPDU is the pair (MPDU sequence number, pointer to WinStartB)
120 typedef std::pair<uint16_t, uint16_t*> Key;
121
122 /// Comparison functor used to sort the buffered MPDUs
123 struct Compare
124 {
125 /**
126 * Functional operator for sorting the buffered MPDUs.
127 *
128 * \param a the key of first buffered MPDU (\see Key)
129 * \param b the key of second buffered MPDU (\see Key)
130 * \return true if first key is smaller than second
131 */
132 bool operator()(const Key& a, const Key& b) const;
133 };
134
135 BlockAckWindow m_scoreboard; ///< recipient's scoreboard
136 uint16_t m_winStartB; ///< starting SN for the reordering buffer
137 std::size_t m_winSizeB; ///< size of the receive reordering buffer
138 std::map<Key, Ptr<const WifiMpdu>, Compare>
139 m_bufferedMpdus; ///< buffered MPDUs sorted by Seq Number
140 Ptr<MacRxMiddle> m_rxMiddle; ///< the MAC RX Middle on this station
141};
142
143} // namespace ns3
144
145#endif /* RECIPIENT_BLOCK_ACK_AGREEMENT_H */
Maintains information for a block ack agreement.
Block ack window.
Headers for BlockAck response.
Definition: ctrl-headers.h:203
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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.
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.