A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
originator-block-ack-agreement.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 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8 */
9#ifndef ORIGINATOR_BLOCK_ACK_AGREEMENT_H
10#define ORIGINATOR_BLOCK_ACK_AGREEMENT_H
11
12#include "block-ack-agreement.h"
13#include "block-ack-window.h"
14
15#include <set>
16
18
19namespace ns3
20{
21
22class WifiMpdu;
23
24/**
25 * @ingroup wifi
26 * Maintains the state and information about transmitted MPDUs with Ack Policy set to Block Ack
27 * for an originator station. The state diagram is as follows:
28 *
29 */
30// clang-format off
31/**
32 * \verbatim
33 /------------\ send ADDBARequest ----------------
34 | START |------------------>| PENDING |-------
35 \------------/ ---------------- \
36 ^ receive / | \
37 | ADDBAResponse / | \
38 | (failure) v | \
39 | --------------- | ---------------------> ----------------
40 | | REJECTED | | receive ADDBAResponse (success) | ESTABLISHED |
41 | --------------- | no --------------------> ----------------
42 | receive ^ | ADDBAResponse /
43 | ADDBAResponse \ | /
44 | (failure) \ v /
45 | ---------------- /
46 |-------------------------| NO_REPLY |---------
47 Reset after timeout ----------------
48 \endverbatim
49*/
50// clang-format on
51
52/**
53 *
54 * See also OriginatorBlockAckAgreement::State
55 */
57{
58 /// allow BlockAckManager class access
59 friend class BlockAckManager;
60 /// allow OriginatorBlockAckWindowTest class access
61 friend class ::OriginatorBlockAckWindowTest;
62
63 public:
64 /**
65 * Constructor
66 *
67 * @param recipient MAC address
68 * @param tid Traffic ID
69 */
70 OriginatorBlockAckAgreement(Mac48Address recipient, uint8_t tid);
72
73 /**
74 * Represents the state for this agreement.
75 *
76 * PENDING:
77 * If an agreement is in PENDING state it means that an ADDBARequest frame was sent to
78 * recipient in order to setup the block ack and the originator is waiting for the relative
79 * ADDBAResponse frame.
80 *
81 * ESTABLISHED:
82 * The block ack is active and all packets relative to this agreement are transmitted
83 * with Ack Policy set to Block Ack.
84 *
85 * NO_REPLY
86 * No reply after an ADDBA request. In this state the originator will send the rest of
87 * packets in queue using normal MPDU.
88 *
89 * RESET
90 * A transient state to mark the agreement for reinitialization after failed ADDBA request.
91 * Since it is a temporary state, it is not included in the state diagram above. In this
92 * state the next transmission will be treated as if the BA agreement is not created yet.
93 *
94 * REJECTED (not used for now):
95 * The agreement's state becomes REJECTED if an ADDBAResponse frame is received from
96 * recipient and the Status Code field is set to failure.
97 */
98 /// State enumeration
107
108 /**
109 * Set the current state.
110 *
111 * @param state to set
112 */
113 void SetState(State state);
114 /**
115 * Check if the current state of this agreement is PENDING.
116 *
117 * @return true if the current state of this agreement is PENDING,
118 * false otherwise
119 */
120 bool IsPending() const;
121 /**
122 * Check if the current state of this agreement is ESTABLISHED.
123 *
124 * @return true if the current state of this agreement is ESTABLISHED,
125 * false otherwise
126 */
127 bool IsEstablished() const;
128 /**
129 * Check if the current state of this agreement is NO_REPLY.
130 *
131 * @return true if the current state of this agreement is NO_REPLY,
132 * false otherwise
133 */
134 bool IsNoReply() const;
135 /**
136 * Check if the current state of this agreement is RESET.
137 *
138 * @return true if the current state of this agreement is RESET,
139 * false otherwise
140 */
141 bool IsReset() const;
142 /**
143 * Check if the current state of this agreement is REJECTED.
144 *
145 * @return true if the current state of this agreement is REJECTED,
146 * false otherwise
147 */
148 bool IsRejected() const;
149
150 /**
151 * Return the starting sequence number of the transmit window, if a transmit
152 * window has been initialized. Otherwise, return the starting sequence number
153 * stored by the BlockAckAgreement base class.
154 *
155 * @return the starting sequence number.
156 */
157 uint16_t GetStartingSequence() const override;
158
159 /**
160 * Get the distance between the current starting sequence number and the
161 * given sequence number.
162 *
163 * @param seqNumber the given sequence number
164 * @return the distance of the given sequence number from the current winstart
165 */
166 std::size_t GetDistance(uint16_t seqNumber) const;
167
168 /**
169 * Initialize the originator's transmit window by setting its size and starting
170 * sequence number equal to the values stored by the BlockAckAgreement base class.
171 */
172 void InitTxWindow();
173
174 /**
175 * Advance the transmit window so as to include the transmitted MPDU, if the
176 * latter is not an old packet and is beyond the current transmit window.
177 *
178 * @param mpdu the transmitted MPDU
179 */
181 /**
182 * Record that the given MPDU has been acknowledged and advance the transmit
183 * window if possible.
184 *
185 * @param mpdu the acknowledged MPDU
186 */
188 /**
189 * Advance the transmit window beyond the MPDU that has been reported to
190 * be discarded.
191 *
192 * @param mpdu the discarded MPDU
193 */
195
196 /**
197 * Check whether all the MPDUs in the TX window other than the given ones have been already
198 * acknowledged.
199 *
200 * @param seqNumbers the sequence numbers of the given MPDUs
201 * @return whether all the MPDUs in the TX window other than the given ones have been already
202 * acknowledged
203 */
204 bool AllAckedMpdusInTxWindow(const std::set<uint16_t>& seqNumbers) const;
205
206 private:
207 /**
208 * Advance the transmit window so that the starting sequence number is the
209 * nearest unacknowledged MPDU.
210 */
211 void AdvanceTxWindow();
212
213 State m_state; ///< state
214 BlockAckWindow m_txWindow; ///< originator's transmit window
215};
216
217} // namespace ns3
218
219#endif /* ORIGINATOR_BLOCK_ACK_AGREEMENT_H */
Test for the originator block ack window.
Maintains information for a block ack agreement.
Manages all block ack agreements for an originator station.
Block ack window.
an EUI-48 address
Maintains the state and information about transmitted MPDUs with Ack Policy set to Block Ack for an o...
void NotifyDiscardedMpdu(Ptr< const WifiMpdu > mpdu)
Advance the transmit window beyond the MPDU that has been reported to be discarded.
uint16_t GetStartingSequence() const override
Return the starting sequence number of the transmit window, if a transmit window has been initialized...
BlockAckWindow m_txWindow
originator's transmit window
void NotifyTransmittedMpdu(Ptr< const WifiMpdu > mpdu)
Advance the transmit window so as to include the transmitted MPDU, if the latter is not an old packet...
void NotifyAckedMpdu(Ptr< const WifiMpdu > mpdu)
Record that the given MPDU has been acknowledged and advance the transmit window if possible.
bool IsPending() const
Check if the current state of this agreement is PENDING.
bool IsReset() const
Check if the current state of this agreement is RESET.
void AdvanceTxWindow()
Advance the transmit window so that the starting sequence number is the nearest unacknowledged MPDU.
OriginatorBlockAckAgreement(Mac48Address recipient, uint8_t tid)
Constructor.
bool IsEstablished() const
Check if the current state of this agreement is ESTABLISHED.
void SetState(State state)
Set the current state.
bool AllAckedMpdusInTxWindow(const std::set< uint16_t > &seqNumbers) const
Check whether all the MPDUs in the TX window other than the given ones have been already acknowledged...
State
Represents the state for this agreement.
std::size_t GetDistance(uint16_t seqNumber) const
Get the distance between the current starting sequence number and the given sequence number.
bool IsNoReply() const
Check if the current state of this agreement is NO_REPLY.
bool IsRejected() const
Check if the current state of this agreement is REJECTED.
void InitTxWindow()
Initialize the originator's transmit window by setting its size and starting sequence number equal to...
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.