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 * 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: Mirko Banchi <mk.banchi@gmail.com>
18 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19 */
20#ifndef ORIGINATOR_BLOCK_ACK_AGREEMENT_H
21#define ORIGINATOR_BLOCK_ACK_AGREEMENT_H
22
23#include "block-ack-agreement.h"
24#include "block-ack-window.h"
25
27
28namespace ns3
29{
30
31class WifiMpdu;
32
33/**
34 * \ingroup wifi
35 * Maintains the state and information about transmitted MPDUs with Ack Policy set to Block Ack
36 * for an originator station. The state diagram is as follows:
37 *
38 \verbatim
39 /------------\ send ADDBARequest ----------------
40 | START |------------------>| PENDING |-------
41 \------------/ ---------------- \
42 ^ receive / | \
43 | ADDBAResponse / | \
44 | (failure) v | \
45 | --------------- | --------------------->
46 ---------------- | | REJECTED | | receive ADDBAResponse (success) |
47 ESTABLISHED | | --------------- | no -------------------->
48 ---------------- | receive ^ | ADDBAResponse / | ADDBAResponse \
49 | / | (failure) \ v / | ---------------- /
50 |-------------------------| NO_REPLY |---------
51 Reset after timeout ----------------
52 \endverbatim
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
99 enum State
100 {
106 };
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 private:
197 /**
198 * Advance the transmit window so that the starting sequence number is the
199 * nearest unacknowledged MPDU.
200 */
201 void AdvanceTxWindow();
202
203 State m_state; ///< state
204 BlockAckWindow m_txWindow; ///< originator's transmit window
205};
206
207} // namespace ns3
208
209#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
Definition: mac48-address.h:46
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.
bool IsEstablished() const
Check if the current state of this agreement is ESTABLISHED.
void SetState(State state)
Set the current state.
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.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.