A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ht-frame-exchange-manager.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
9#ifndef HT_FRAME_EXCHANGE_MANAGER_H
10#define HT_FRAME_EXCHANGE_MANAGER_H
11
12#include "ns3/mpdu-aggregator.h"
13#include "ns3/msdu-aggregator.h"
14#include "ns3/qos-frame-exchange-manager.h"
15#include "ns3/wifi-psdu.h"
16
18
19namespace ns3
20{
21
22class MgtAddBaResponseHeader;
23class RecipientBlockAckAgreement;
24
25/**
26 * \ingroup wifi
27 *
28 * HtFrameExchangeManager handles the frame exchange sequences
29 * for HT stations.
30 */
32{
33 public:
34 /// allow AmpduAggregationTest class access
35 friend class ::AmpduAggregationTest;
36
37 /**
38 * \brief Get the type ID.
39 * \return the object TypeId
40 */
41 static TypeId GetTypeId();
43 ~HtFrameExchangeManager() override;
44
45 bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame) override;
46 void SetWifiMac(const Ptr<WifiMac> mac) override;
47 void CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledgment) const override;
48
49 /**
50 * Returns the aggregator used to construct A-MSDU subframes.
51 *
52 * \return the aggregator used to construct A-MSDU subframes.
53 */
55 /**
56 * Returns the aggregator used to construct A-MPDU subframes.
57 *
58 * \return the aggregator used to construct A-MPDU subframes.
59 */
61
62 /**
63 * Check if the PSDU obtained by aggregating the given MPDU to the PSDU specified
64 * by the given TX parameters meets the constraints on the maximum A-MPDU size
65 * and its transmission time does not exceed the given PPDU duration limit (if
66 * different than Time::Min()).
67 *
68 * \param mpdu the given MPDU
69 * \param txParams the TX parameters
70 * \param ppduDurationLimit the constraint on the PPDU transmission time
71 * \return true if the size and time constraints are met, false otherwise
72 */
74 const WifiTxParameters& txParams,
75 Time ppduDurationLimit) const override;
76
77 /**
78 * Check whether an A-MPDU of the given size meets the constraint on the maximum
79 * size for A-MPDUs sent to the given receiver, belonging to the given TID and
80 * transmitted using the given modulation class.
81 *
82 * \param ampduSize the size in bytes of the A-MPDU.
83 * \param receiver the address of the station that is the receiver of the A-MPDU
84 * \param tid the TID of the A-MPDU
85 * \param modulation the modulation class used to transmit the A-MPDU
86 * \return true if the constraint on the max A-MPDU size is met.
87 */
88 virtual bool IsWithinAmpduSizeLimit(uint32_t ampduSize,
89 Mac48Address receiver,
90 uint8_t tid,
91 WifiModulationClass modulation) const;
92
93 /**
94 * Check if aggregating an MSDU to the current MPDU (as specified by the given
95 * TX parameters) does not violate the size and time constraints, while taking
96 * into account the possibly updated protection and acknowledgment methods. If
97 * size and time constraints are met, the TX parameters are modified with the
98 * updated protection and acknowledgment methods.
99 *
100 * \param msdu the given MSDU
101 * \param txParams the TX parameters
102 * \param availableTime the constraint on the TX time of the PSDU, if different
103 * than Time::Min()
104 * \return true if aggregating an MSDU to the current PSDU does not violate the
105 * size and time constraints
106 */
107 virtual bool TryAggregateMsdu(Ptr<const WifiMpdu> msdu,
108 WifiTxParameters& txParams,
109 Time availableTime) const;
110
111 /**
112 * Check if the PSDU obtained by aggregating the given MSDU to the PSDU specified
113 * by the given TX parameters meets the constraints on the maximum A-MSDU size
114 * and its transmission time does not exceed the given PPDU duration limit (if
115 * different than Time::Min()).
116 *
117 * \param msdu the given MSDU
118 * \param txParams the TX parameters
119 * \param ppduDurationLimit the constraint on the PPDU transmission time
120 * \return true if the size and time constraints are met, false otherwise
121 */
123 const WifiTxParameters& txParams,
124 Time ppduDurationLimit) const;
125
126 /**
127 * This method can be called to accept a received ADDBA Request. An
128 * ADDBA Response will be constructed and queued for transmission.
129 *
130 * \param reqHdr the received ADDBA Request header.
131 * \param originator the MAC address of the originator.
132 */
133 void SendAddBaResponse(const MgtAddBaRequestHeader& reqHdr, Mac48Address originator);
134
135 /**
136 * Sends DELBA frame to cancel a block ack agreement with STA
137 * addressed by <i>addr</i> for TID <i>tid</i>.
138 *
139 * \param addr address of the recipient.
140 * \param tid traffic ID.
141 * \param byOriginator flag to indicate whether this is set by the originator.
142 */
143 void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator);
144
145 /**
146 * Get the next BlockAckRequest or MU-BAR Trigger Frame to send, if any. If TID and recipient
147 * address are given, then only return a BlockAckRequest, if any, addressed to that recipient
148 * and for the given TID.
149 *
150 * \param ac the AC whose queue is searched for BlockAckRequest or Trigger Frames
151 * \param optTid the TID (optional)
152 * \param optAddress the recipient of the BAR (optional)
153 *
154 * \return the next BAR or Trigger Frame to be sent, if any
155 */
157 std::optional<uint8_t> optTid = std::nullopt,
158 std::optional<Mac48Address> optAddress = std::nullopt);
159
160 protected:
161 void DoDispose() override;
162
164 RxSignalInfo rxSignalInfo,
165 const WifiTxVector& txVector,
166 bool inAmpdu) override;
168 const RxSignalInfo& rxSignalInfo,
169 const WifiTxVector& txVector,
170 const std::vector<bool>& perMpduStatus) override;
171 void NotifyReceivedNormalAck(Ptr<WifiMpdu> mpdu) override;
172 void NotifyPacketDiscarded(Ptr<const WifiMpdu> mpdu) override;
173 void RetransmitMpduAfterMissedAck(Ptr<WifiMpdu> mpdu) const override;
174 void ReleaseSequenceNumbers(Ptr<const WifiPsdu> psdu) const override;
175 void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector) override;
176 void FinalizeMacHeader(Ptr<const WifiPsdu> psdu) override;
177 void CtsTimeout(Ptr<WifiMpdu> rts, const WifiTxVector& txVector) override;
178 void TransmissionSucceeded() override;
179 void ProtectionCompleted() override;
180
181 /**
182 * Process a received management action frame that relates to Block Ack agreement.
183 *
184 * \param mpdu the MPDU carrying the received management action frame
185 * \param txVector the TXVECTOR used to transmit the management action frame
186 */
187 void ReceiveMgtAction(Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector);
188
189 /**
190 * Get a PSDU containing the given MPDU
191 *
192 * \param mpdu the given MPDU
193 * \param txVector the TXVECTOR to use to send the MPDU
194 * \return a PSDU containing the given MPDU
195 */
196 virtual Ptr<WifiPsdu> GetWifiPsdu(Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector) const;
197
198 /**
199 * Get the Block Ack Manager handling the given TID.
200 *
201 * \param tid the given TID
202 * \return the Block Ack Manager handling the given TID
203 */
204 Ptr<BlockAckManager> GetBaManager(uint8_t tid) const;
205
206 /**
207 * Compute how to set the Duration/ID field of PSDUs that do not include fragments.
208 *
209 * \param txDuration the duration of the PSDU transmission
210 * \param txParams the TX parameters used to send the PSDU
211 * \return the value for the Duration/ID field
212 */
213 virtual Time GetPsduDurationId(Time txDuration, const WifiTxParameters& txParams) const;
214
215 /**
216 * Send a PSDU (A-MPDU or BlockAckReq frame) requesting a BlockAck frame or
217 * a BlockAckReq frame followed by a BlockAck frame for the acknowledgment.
218 * Note that <i>txParams</i> is moved to m_txParams and hence is left in an
219 * undefined state.
220 *
221 * \param psdu the PSDU to send
222 * \param txParams the TX parameters to use to transmit the PSDU
223 */
225
226 /**
227 * Notify the transmission of the given PSDU to the EDCAF associated with the
228 * AC the PSDU belongs to.
229 *
230 * \param psdu the PSDU to transmit
231 */
232 virtual void NotifyTxToEdca(Ptr<const WifiPsdu> psdu) const;
233
234 /**
235 * Forward a PSDU down to the PHY layer. Also, notify the Block Ack Manager
236 * of the transmission of the constituent MPDUs.
237 *
238 * \param psdu the PSDU to forward down
239 * \param txVector the TXVECTOR used to transmit the MPDU
240 */
241 virtual void ForwardPsduDown(Ptr<const WifiPsdu> psdu, WifiTxVector& txVector);
242
243 /**
244 * Dequeue the MPDUs of the given PSDU from the queue in which they are stored.
245 *
246 * \param psdu the given PSDU
247 */
249
250 /**
251 * If the given MPDU contains a BlockAckReq frame (the duration of which plus the response
252 * fits within the given available time, if the latter is not Time::Min() and this is not
253 * the initial frame of a TXOP), transmit the frame and return true. Otherwise, return false.
254 *
255 * \param mpdu the given MPDU
256 * \param availableTime the amount of time allowed for the frame exchange. Equals
257 * Time::Min() in case the TXOP limit is null
258 * \param initialFrame true if the frame being transmitted is the initial frame
259 * of the TXOP. This is used to determine whether the TXOP
260 * limit can be exceeded
261 * \return true if frame is transmitted, false otherwise
262 */
263 virtual bool SendMpduFromBaManager(Ptr<WifiMpdu> mpdu, Time availableTime, bool initialFrame);
264
265 /**
266 * Given a non-broadcast QoS data frame, prepare the PSDU to transmit by attempting
267 * A-MSDU and A-MPDU aggregation (if enabled), while making sure that the frame
268 * exchange (possibly including protection and acknowledgment) is completed within
269 * the given available time.
270 *
271 * \param peekedItem the given non-broadcast QoS data frame
272 * \param availableTime the amount of time allowed for the frame exchange. Equals
273 * Time::Min() in case the TXOP limit is null
274 * \param initialFrame true if the frame being transmitted is the initial frame
275 * of the TXOP. This is used to determine whether the TXOP
276 * limit can be exceeded
277 * \return true if frame is transmitted, false otherwise
278 */
279 virtual bool SendDataFrame(Ptr<WifiMpdu> peekedItem, Time availableTime, bool initialFrame);
280
281 /**
282 * A Block Ack agreement needs to be established with the given recipient for the
283 * given TID if it does not already exist (or exists and is in state RESET) and:
284 *
285 * - the number of packets in the queue reaches the BlockAckThreshold value OR
286 * - MPDU aggregation is enabled and there is more than one packet in the queue OR
287 * - the station is a VHT station
288 *
289 * \param recipient address of the recipient.
290 * \param tid traffic ID.
291 * \return true if a Block Ack agreement needs to be established, false otherwise.
292 */
293 virtual bool NeedSetupBlockAck(Mac48Address recipient, uint8_t tid);
294
295 /**
296 * Sends an ADDBA Request to establish a block ack agreement with STA
297 * addressed by <i>recipient</i> for TID <i>tid</i>.
298 *
299 * \param recipient address of the recipient.
300 * \param tid traffic ID.
301 * \param startingSeq the BA agreement starting sequence number
302 * \param timeout timeout value.
303 * \param immediateBAck flag to indicate whether immediate BlockAck is used.
304 * \param availableTime the amount of time allowed for the frame exchange. Equals
305 * Time::Min() in case the TXOP limit is null
306 * \return true if ADDBA Request frame is transmitted, false otherwise
307 */
308 bool SendAddBaRequest(Mac48Address recipient,
309 uint8_t tid,
310 uint16_t startingSeq,
311 uint16_t timeout,
312 bool immediateBAck,
313 Time availableTime);
314
315 /**
316 * Create a BlockAck frame with header equal to <i>blockAck</i> and start its transmission.
317 *
318 * \param agreement the agreement the Block Ack response belongs to
319 * \param durationId the Duration/ID of the frame soliciting this Block Ack response
320 * \param blockAckTxVector the transmit vector for the Block Ack response
321 * \param rxSnr the receive SNR
322 */
323 void SendBlockAck(const RecipientBlockAckAgreement& agreement,
324 Time durationId,
325 WifiTxVector& blockAckTxVector,
326 double rxSnr);
327
328 /**
329 * Called when the BlockAck timeout expires.
330 *
331 * \param psdu the PSDU (BlockAckReq or A-MPDU) that solicited a BlockAck response
332 * \param txVector the TXVECTOR used to send the PSDU that solicited a BlockAck response
333 */
334 virtual void BlockAckTimeout(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector);
335
336 /**
337 * Take necessary actions when a BlockAck is missed, such as scheduling a
338 * BlockAckReq frame or the retransmission of the unacknowledged frames.
339 *
340 * \param psdu the PSDU (BlockAckReq or A-MPDU) that solicited a BlockAck response
341 * \param txVector the TXVECTOR used to send the PSDU that solicited a BlockAck response
342 * \param[out] resetCw true if we shall stop retransmitting the PSDU
343 */
344 virtual void MissedBlockAck(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector, bool& resetCw);
345
346 /// agreement key typedef (MAC address and TID)
347 typedef std::pair<Mac48Address, uint8_t> AgreementKey;
348
349 Ptr<MsduAggregator> m_msduAggregator; //!< A-MSDU aggregator
350 Ptr<MpduAggregator> m_mpduAggregator; //!< A-MPDU aggregator
351
352 /// pending ADDBA_RESPONSE frames indexed by agreement key
353 std::map<AgreementKey, Ptr<WifiMpdu>> m_pendingAddBaResp;
354
355 private:
356 /**
357 * Send the current PSDU, which can be acknowledged by a BlockAck frame or
358 * followed by a BlockAckReq frame and a BlockAck frame.
359 */
360 void SendPsdu();
361
362 Ptr<WifiPsdu> m_psdu; //!< the A-MPDU being transmitted
363 WifiTxParameters m_txParams; //!< the TX parameters for the current frame
364};
365
366} // namespace ns3
367
368#endif /* HT_FRAME_EXCHANGE_MANAGER_H */
Ampdu Aggregation Test.
HtFrameExchangeManager handles the frame exchange sequences for HT stations.
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
void ReceiveMpdu(Ptr< const WifiMpdu > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu) override
This method handles the reception of an MPDU (possibly included in an A-MPDU)
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
Sends DELBA frame to cancel a block ack agreement with STA addressed by addr for TID tid.
std::map< AgreementKey, Ptr< WifiMpdu > > m_pendingAddBaResp
pending ADDBA_RESPONSE frames indexed by agreement key
void SendAddBaResponse(const MgtAddBaRequestHeader &reqHdr, Mac48Address originator)
This method can be called to accept a received ADDBA Request.
void CtsTimeout(Ptr< WifiMpdu > rts, const WifiTxVector &txVector) override
Called when the CTS timeout expires.
Ptr< WifiPsdu > m_psdu
the A-MPDU being transmitted
Ptr< BlockAckManager > GetBaManager(uint8_t tid) const
Get the Block Ack Manager handling the given TID.
virtual Ptr< WifiPsdu > GetWifiPsdu(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector) const
Get a PSDU containing the given MPDU.
virtual void BlockAckTimeout(Ptr< WifiPsdu > psdu, const WifiTxVector &txVector)
Called when the BlockAck timeout expires.
Ptr< WifiMpdu > GetBar(AcIndex ac, std::optional< uint8_t > optTid=std::nullopt, std::optional< Mac48Address > optAddress=std::nullopt)
Get the next BlockAckRequest or MU-BAR Trigger Frame to send, if any.
virtual Time GetPsduDurationId(Time txDuration, const WifiTxParameters &txParams) const
Compute how to set the Duration/ID field of PSDUs that do not include fragments.
virtual bool NeedSetupBlockAck(Mac48Address recipient, uint8_t tid)
A Block Ack agreement needs to be established with the given recipient for the given TID if it does n...
void FinalizeMacHeader(Ptr< const WifiPsdu > psdu) override
Finalize the MAC header of the MPDUs in the given PSDU before transmission.
void TransmissionSucceeded() override
Take necessary actions upon a transmission success.
virtual bool SendMpduFromBaManager(Ptr< WifiMpdu > mpdu, Time availableTime, bool initialFrame)
If the given MPDU contains a BlockAckReq frame (the duration of which plus the response fits within t...
Ptr< MpduAggregator > GetMpduAggregator() const
Returns the aggregator used to construct A-MPDU subframes.
virtual bool IsWithinLimitsIfAggregateMsdu(Ptr< const WifiMpdu > msdu, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check if the PSDU obtained by aggregating the given MSDU to the PSDU specified by the given TX parame...
virtual bool IsWithinAmpduSizeLimit(uint32_t ampduSize, Mac48Address receiver, uint8_t tid, WifiModulationClass modulation) const
Check whether an A-MPDU of the given size meets the constraint on the maximum size for A-MPDUs sent t...
void SetWifiMac(const Ptr< WifiMac > mac) override
Set the MAC layer to use.
void ProtectionCompleted() override
Transmit prepared frame upon successful protection mechanism.
void ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector) override
Forward an MPDU down to the PHY layer.
Ptr< MsduAggregator > GetMsduAggregator() const
Returns the aggregator used to construct A-MSDU subframes.
void SendPsduWithProtection(Ptr< WifiPsdu > psdu, WifiTxParameters &txParams)
Send a PSDU (A-MPDU or BlockAckReq frame) requesting a BlockAck frame or a BlockAckReq frame followed...
void NotifyReceivedNormalAck(Ptr< WifiMpdu > mpdu) override
Notify other components that an MPDU was acknowledged.
void EndReceiveAmpdu(Ptr< const WifiPsdu > psdu, const RxSignalInfo &rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &perMpduStatus) override
This method is called when the reception of an A-MPDU including multiple MPDUs is completed.
void RetransmitMpduAfterMissedAck(Ptr< WifiMpdu > mpdu) const override
Retransmit an MPDU that was not acknowledged.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
bool StartFrameExchange(Ptr< QosTxop > edca, Time availableTime, bool initialFrame) override
Start a frame exchange (including protection frames and acknowledgment frames as needed) that fits wi...
WifiTxParameters m_txParams
the TX parameters for the current frame
bool IsWithinLimitsIfAddMpdu(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams, Time ppduDurationLimit) const override
Check if the PSDU obtained by aggregating the given MPDU to the PSDU specified by the given TX parame...
void SendPsdu()
Send the current PSDU, which can be acknowledged by a BlockAck frame or followed by a BlockAckReq fra...
bool SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startingSeq, uint16_t timeout, bool immediateBAck, Time availableTime)
Sends an ADDBA Request to establish a block ack agreement with STA addressed by recipient for TID tid...
void ReceiveMgtAction(Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector)
Process a received management action frame that relates to Block Ack agreement.
virtual bool TryAggregateMsdu(Ptr< const WifiMpdu > msdu, WifiTxParameters &txParams, Time availableTime) const
Check if aggregating an MSDU to the current MPDU (as specified by the given TX parameters) does not v...
virtual void NotifyTxToEdca(Ptr< const WifiPsdu > psdu) const
Notify the transmission of the given PSDU to the EDCAF associated with the AC the PSDU belongs to.
virtual bool SendDataFrame(Ptr< WifiMpdu > peekedItem, Time availableTime, bool initialFrame)
Given a non-broadcast QoS data frame, prepare the PSDU to transmit by attempting A-MSDU and A-MPDU ag...
void NotifyPacketDiscarded(Ptr< const WifiMpdu > mpdu) override
Pass the given MPDU, discarded because of the max retry limit was reached, to the MPDU dropped callba...
virtual void ForwardPsduDown(Ptr< const WifiPsdu > psdu, WifiTxVector &txVector)
Forward a PSDU down to the PHY layer.
void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const override
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
void DequeuePsdu(Ptr< const WifiPsdu > psdu)
Dequeue the MPDUs of the given PSDU from the queue in which they are stored.
void ReleaseSequenceNumbers(Ptr< const WifiPsdu > psdu) const override
Make the sequence numbers of MPDUs included in the given PSDU available again if the MPDUs have never...
virtual void MissedBlockAck(Ptr< WifiPsdu > psdu, const WifiTxVector &txVector, bool &resetCw)
Take necessary actions when a BlockAck is missed, such as scheduling a BlockAckReq frame or the retra...
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
std::pair< Mac48Address, uint8_t > AgreementKey
agreement key typedef (MAC address and TID)
void SendBlockAck(const RecipientBlockAckAgreement &agreement, Time durationId, WifiTxVector &blockAckTxVector, double rxSnr)
Create a BlockAck frame with header equal to blockAck and start its transmission.
an EUI-48 address
Implement the header for management frames of type Add Block Ack request.
Smart pointer class similar to boost::intrusive_ptr.
QosFrameExchangeManager handles the frame exchange sequences for QoS stations.
Maintains the scoreboard and the receive reordering buffer used by a recipient of a Block Ack agreeme...
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Time timeout
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:72
WifiAcknowledgment is an abstract base struct.