A Discrete-Event Network Simulator
API
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  * 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 
20 #ifndef HT_FRAME_EXCHANGE_MANAGER_H
21 #define HT_FRAME_EXCHANGE_MANAGER_H
22 
23 #include "ns3/mpdu-aggregator.h"
24 #include "ns3/msdu-aggregator.h"
25 #include "ns3/qos-frame-exchange-manager.h"
26 #include "ns3/wifi-psdu.h"
27 
30 class HeAggregationTest;
31 
32 namespace ns3
33 {
34 
35 class MgtAddBaResponseHeader;
36 class RecipientBlockAckAgreement;
37 
45 {
46  public:
48  friend class ::AmpduAggregationTest;
50  friend class ::TwoLevelAggregationTest;
52  friend class ::HeAggregationTest;
53 
58  static TypeId GetTypeId();
60  ~HtFrameExchangeManager() override;
61 
62  bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame) override;
63  void SetWifiMac(const Ptr<WifiMac> mac) override;
64  void CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledgment) const override;
65 
78 
91  const WifiTxParameters& txParams,
92  Time ppduDurationLimit) const override;
93 
105  virtual bool IsWithinAmpduSizeLimit(uint32_t ampduSize,
106  Mac48Address receiver,
107  uint8_t tid,
108  WifiModulationClass modulation) const;
109 
124  virtual bool TryAggregateMsdu(Ptr<const WifiMpdu> msdu,
125  WifiTxParameters& txParams,
126  Time availableTime) const;
127 
140  const WifiTxParameters& txParams,
141  Time ppduDurationLimit) const;
142 
150  void SendAddBaResponse(const MgtAddBaRequestHeader* reqHdr, Mac48Address originator);
157  virtual uint16_t GetSupportedBaBufferSize() const;
158 
167  void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator);
168 
181  std::optional<uint8_t> optTid = std::nullopt,
182  std::optional<Mac48Address> optAddress = std::nullopt);
183 
184  protected:
185  void DoDispose() override;
186 
188  RxSignalInfo rxSignalInfo,
189  const WifiTxVector& txVector,
190  bool inAmpdu) override;
192  const RxSignalInfo& rxSignalInfo,
193  const WifiTxVector& txVector,
194  const std::vector<bool>& perMpduStatus) override;
195  void NotifyReceivedNormalAck(Ptr<WifiMpdu> mpdu) override;
196  void NotifyPacketDiscarded(Ptr<const WifiMpdu> mpdu) override;
197  void RetransmitMpduAfterMissedAck(Ptr<WifiMpdu> mpdu) const override;
198  void ReleaseSequenceNumbers(Ptr<const WifiPsdu> psdu) const override;
199  void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector) override;
200  void CtsTimeout(Ptr<WifiMpdu> rts, const WifiTxVector& txVector) override;
201  void TransmissionSucceeded() override;
202 
210  virtual Ptr<WifiPsdu> GetWifiPsdu(Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector) const;
211 
218  Ptr<BlockAckManager> GetBaManager(uint8_t tid) const;
219 
227  virtual Time GetPsduDurationId(Time txDuration, const WifiTxParameters& txParams) const;
228 
239 
246  virtual void NotifyTxToEdca(Ptr<const WifiPsdu> psdu) const;
247 
255  virtual void ForwardPsduDown(Ptr<const WifiPsdu> psdu, WifiTxVector& txVector);
256 
262  void DequeuePsdu(Ptr<const WifiPsdu> psdu);
263 
277  virtual bool SendMpduFromBaManager(Ptr<WifiMpdu> mpdu, Time availableTime, bool initialFrame);
278 
293  virtual bool SendDataFrame(Ptr<WifiMpdu> peekedItem, Time availableTime, bool initialFrame);
294 
307  virtual bool NeedSetupBlockAck(Mac48Address recipient, uint8_t tid);
308 
319  void SendAddBaRequest(Mac48Address recipient,
320  uint8_t tid,
321  uint16_t startingSeq,
322  uint16_t timeout,
323  bool immediateBAck);
324 
333  void SendBlockAck(const RecipientBlockAckAgreement& agreement,
334  Time durationId,
335  WifiTxVector& blockAckTxVector,
336  double rxSnr);
337 
344  virtual void BlockAckTimeout(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector);
345 
354  virtual void MissedBlockAck(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector, bool& resetCw);
355 
357  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
358 
361 
363  std::map<AgreementKey, Ptr<WifiMpdu>> m_pendingAddBaResp;
364 
365  private:
370  void SendPsdu();
371 
374 };
375 
376 } // namespace ns3
377 
378 #endif /* HT_FRAME_EXCHANGE_MANAGER_H */
Ampdu Aggregation Test.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negotiated buffer ...
Two Level 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 SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startingSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBA Request to establish a block ack agreement with STA addressed by recipient for TID tid...
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 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 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...
virtual uint16_t GetSupportedBaBufferSize() const
Get the maximum supported buffer size for a 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
Definition: mac48-address.h:46
Implement the header for management frames of type Add Block Ack request.
Definition: mgt-headers.h:1511
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:105
a unique identifier for an interface.
Definition: type-id.h:60
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:72
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:85
ns3::Time timeout
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:70
WifiAcknowledgment is an abstract base struct.