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 * See also OriginatorBlockAckAgreement::State
54 */
56{
57 /// allow BlockAckManager class access
58 friend class BlockAckManager;
59 /// allow OriginatorBlockAckWindowTest class access
60 friend class ::OriginatorBlockAckWindowTest;
61
62 public:
63 /**
64 * Constructor
65 *
66 * \param recipient MAC address
67 * \param tid Traffic ID
68 */
69 OriginatorBlockAckAgreement(Mac48Address recipient, uint8_t tid);
71
72 /**
73 * Represents the state for this agreement.
74 *
75 * PENDING:
76 * If an agreement is in PENDING state it means that an ADDBARequest frame was sent to
77 * recipient in order to setup the block ack and the originator is waiting for the relative
78 * ADDBAResponse frame.
79 *
80 * ESTABLISHED:
81 * The block ack is active and all packets relative to this agreement are transmitted
82 * with Ack Policy set to Block Ack.
83 *
84 * NO_REPLY
85 * No reply after an ADDBA request. In this state the originator will send the rest of
86 * packets in queue using normal MPDU.
87 *
88 * RESET
89 * A transient state to mark the agreement for reinitialization after failed ADDBA request.
90 * Since it is a temporary state, it is not included in the state diagram above. In this
91 * state the next transmission will be treated as if the BA agreement is not created yet.
92 *
93 * REJECTED (not used for now):
94 * The agreement's state becomes REJECTED if an ADDBAResponse frame is received from
95 * recipient and the Status Code field is set to failure.
96 */
97 /// State enumeration
106
107 /**
108 * Set the current state.
109 *
110 * \param state to set
111 */
112 void SetState(State state);
113 /**
114 * Check if the current state of this agreement is PENDING.
115 *
116 * \return true if the current state of this agreement is PENDING,
117 * false otherwise
118 */
119 bool IsPending() const;
120 /**
121 * Check if the current state of this agreement is ESTABLISHED.
122 *
123 * \return true if the current state of this agreement is ESTABLISHED,
124 * false otherwise
125 */
126 bool IsEstablished() const;
127 /**
128 * Check if the current state of this agreement is NO_REPLY.
129 *
130 * \return true if the current state of this agreement is NO_REPLY,
131 * false otherwise
132 */
133 bool IsNoReply() const;
134 /**
135 * Check if the current state of this agreement is RESET.
136 *
137 * \return true if the current state of this agreement is RESET,
138 * false otherwise
139 */
140 bool IsReset() const;
141 /**
142 * Check if the current state of this agreement is REJECTED.
143 *
144 * \return true if the current state of this agreement is REJECTED,
145 * false otherwise
146 */
147 bool IsRejected() const;
148
149 /**
150 * Return the starting sequence number of the transmit window, if a transmit
151 * window has been initialized. Otherwise, return the starting sequence number
152 * stored by the BlockAckAgreement base class.
153 *
154 * \return the starting sequence number.
155 */
156 uint16_t GetStartingSequence() const override;
157
158 /**
159 * Get the distance between the current starting sequence number and the
160 * given sequence number.
161 *
162 * \param seqNumber the given sequence number
163 * \return the distance of the given sequence number from the current winstart
164 */
165 std::size_t GetDistance(uint16_t seqNumber) const;
166
167 /**
168 * Initialize the originator's transmit window by setting its size and starting
169 * sequence number equal to the values stored by the BlockAckAgreement base class.
170 */
171 void InitTxWindow();
172
173 /**
174 * Advance the transmit window so as to include the transmitted MPDU, if the
175 * latter is not an old packet and is beyond the current transmit window.
176 *
177 * \param mpdu the transmitted MPDU
178 */
180 /**
181 * Record that the given MPDU has been acknowledged and advance the transmit
182 * window if possible.
183 *
184 * \param mpdu the acknowledged MPDU
185 */
187 /**
188 * Advance the transmit window beyond the MPDU that has been reported to
189 * be discarded.
190 *
191 * \param mpdu the discarded MPDU
192 */
194
195 /**
196 * Check whether all the MPDUs in the TX window other than the given ones have been already
197 * acknowledged.
198 *
199 * \param seqNumbers the sequence numbers of the given MPDUs
200 * \return whether all the MPDUs in the TX window other than the given ones have been already
201 * acknowledged
202 */
203 bool AllAckedMpdusInTxWindow(const std::set<uint16_t>& seqNumbers) const;
204
205 private:
206 /**
207 * Advance the transmit window so that the starting sequence number is the
208 * nearest unacknowledged MPDU.
209 */
210 void AdvanceTxWindow();
211
212 State m_state; ///< state
213 BlockAckWindow m_txWindow; ///< originator's transmit window
214};
215
216} // namespace ns3
217
218#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.