A Discrete-Event Network Simulator
API
ht-frame-exchange-manager.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Universita' degli Studi di Napoli Federico II
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Stefano Avallone <stavallo@unina.it>
19  */
20 
21 #ifndef HT_FRAME_EXCHANGE_MANAGER_H
22 #define HT_FRAME_EXCHANGE_MANAGER_H
23 
24 #include "ns3/qos-frame-exchange-manager.h"
25 #include "ns3/mpdu-aggregator.h"
26 #include "ns3/msdu-aggregator.h"
27 #include "ns3/wifi-psdu.h"
28 
31 class HeAggregationTest;
32 
33 namespace ns3 {
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 (void);
60  virtual ~HtFrameExchangeManager ();
61 
62  bool StartFrameExchange (Ptr<QosTxop> edca, Time availableTime, bool initialFrame) override;
63  void SetWifiMac (const Ptr<RegularWifiMac> 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, Mac48Address receiver, uint8_t tid,
106  WifiModulationClass modulation) const;
107 
122  virtual bool TryAggregateMsdu (Ptr<const WifiMacQueueItem> msdu, WifiTxParameters& txParams,
123  Time availableTime) const;
124 
137  const WifiTxParameters& txParams,
138  Time ppduDurationLimit) const;
139 
155  void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr,
156  Mac48Address originator, uint16_t startingSeq);
163  void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid);
171  void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr,
172  Mac48Address originator);
179  virtual uint16_t GetSupportedBaBufferSize (void) const;
180 
190  bool GetBaAgreementEstablished (Mac48Address originator, uint8_t tid) const;
191 
199  BlockAckType GetBlockAckType (Mac48Address originator, uint8_t tid) const;
200 
201 protected:
202  void DoDispose () override;
203 
204  void ReceiveMpdu (Ptr<WifiMacQueueItem> mpdu, RxSignalInfo rxSignalInfo,
205  const WifiTxVector& txVector, bool inAmpdu) override;
206  void EndReceiveAmpdu (Ptr<const WifiPsdu> psdu, const RxSignalInfo& rxSignalInfo,
207  const WifiTxVector& txVector, const std::vector<bool>& perMpduStatus) override;
208  void NotifyReceivedNormalAck (Ptr<WifiMacQueueItem> mpdu) override;
210  void RetransmitMpduAfterMissedAck (Ptr<WifiMacQueueItem> mpdu) const override;
211  void RetransmitMpduAfterMissedCts (Ptr<WifiMacQueueItem> mpdu) const override;
212  void ForwardMpduDown (Ptr<WifiMacQueueItem> mpdu, WifiTxVector& txVector) override;
213  void CtsTimeout (Ptr<WifiMacQueueItem> rts, const WifiTxVector& txVector) override;
214  void TransmissionSucceeded (void) override;
215 
223  virtual Ptr<WifiPsdu> GetWifiPsdu (Ptr<WifiMacQueueItem> mpdu, const WifiTxVector& txVector) const;
224 
231  Ptr<BlockAckManager> GetBaManager (uint8_t tid) const;
232 
240  virtual Time GetPsduDurationId (Time txDuration, const WifiTxParameters& txParams) const;
241 
252 
259  virtual void NotifyTxToEdca (Ptr<const WifiPsdu> psdu) const;
260 
268  virtual void ForwardPsduDown (Ptr<const WifiPsdu> psdu, WifiTxVector& txVector);
269 
275  void DequeuePsdu (Ptr<const WifiPsdu> psdu);
276 
291  virtual bool SendMpduFromBaManager (Ptr<QosTxop> edca, Time availableTime, bool initialFrame);
292 
307  virtual bool SendDataFrame (Ptr<const WifiMacQueueItem> peekedItem,
308  Time availableTime, bool initialFrame);
309 
322  virtual bool NeedSetupBlockAck (Mac48Address recipient, uint8_t tid);
323 
334  void SendAddBaRequest (Mac48Address recipient, uint8_t tid, uint16_t startingSeq,
335  uint16_t timeout, bool immediateBAck);
336 
345  void SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator);
346 
355  void SendBlockAck (const RecipientBlockAckAgreement& agreement, Time durationId,
356  WifiTxVector& blockAckTxVector, double rxSnr);
357 
364  virtual void BlockAckTimeout (Ptr<WifiPsdu> psdu, const WifiTxVector& txVector);
365 
374  virtual void MissedBlockAck (Ptr<WifiPsdu> psdu, const WifiTxVector& txVector, bool& resetCw);
375 
377  typedef std::pair<Mac48Address, uint8_t> AgreementKey;
378 
379  std::map<AgreementKey, RecipientBlockAckAgreement> m_agreements;
382 
383 private:
388  void SendPsdu (void);
389 
392 };
393 
394 } //namespace ns3
395 
396 #endif /* HT_FRAME_EXCHANGE_MANAGER_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::HtFrameExchangeManager::CtsTimeout
void CtsTimeout(Ptr< WifiMacQueueItem > rts, const WifiTxVector &txVector) override
Called when the CTS timeout expires.
Definition: ht-frame-exchange-manager.cc:756
ns3::HtFrameExchangeManager::RetransmitMpduAfterMissedCts
void RetransmitMpduAfterMissedCts(Ptr< WifiMacQueueItem > mpdu) const override
Retransmit an MPDU that was not sent because a CTS was not received.
Definition: ht-frame-exchange-manager.cc:653
ns3::HtFrameExchangeManager::MissedBlockAck
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...
Definition: ht-frame-exchange-manager.cc:1150
ns3::HtFrameExchangeManager::GetBlockAckType
BlockAckType GetBlockAckType(Mac48Address originator, uint8_t tid) const
Get the type of BlockAck frames sent to the given originator.
Definition: ht-frame-exchange-manager.cc:1286
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::HtFrameExchangeManager::StartFrameExchange
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...
Definition: ht-frame-exchange-manager.cc:334
ns3::HtFrameExchangeManager::SendMpduFromBaManager
virtual bool SendMpduFromBaManager(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
If the Block Ack Manager associated with the given EDCA has a BlockAckReq frame to transmit (the dura...
Definition: ht-frame-exchange-manager.cc:387
ns3::HtFrameExchangeManager::DoDispose
void DoDispose() override
Destructor implementation.
Definition: ht-frame-exchange-manager.cc:66
ns3::HtFrameExchangeManager::NeedSetupBlockAck
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...
Definition: ht-frame-exchange-manager.cc:104
ns3::HtFrameExchangeManager::IsWithinLimitsIfAggregateMsdu
virtual bool IsWithinLimitsIfAggregateMsdu(Ptr< const WifiMacQueueItem > 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...
Definition: ht-frame-exchange-manager.cc:1080
AmpduAggregationTest
Ampdu Aggregation Test.
Definition: wifi-aggregation-test.cc:57
ns3::HtFrameExchangeManager::SendAddBaRequest
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...
Definition: ht-frame-exchange-manager.cc:131
ns3::HtFrameExchangeManager::SendBlockAck
void SendBlockAck(const RecipientBlockAckAgreement &agreement, Time durationId, WifiTxVector &blockAckTxVector, double rxSnr)
Create a BlockAck frame with header equal to blockAck and start its transmission.
Definition: ht-frame-exchange-manager.cc:1236
ns3::HtFrameExchangeManager::SendPsduWithProtection
void SendPsduWithProtection(Ptr< WifiPsdu > psdu, WifiTxParameters &txParams)
Send a PSDU (A-MPDU or BlockAckReq frame) requesting a BlockAck frame or a BlockAckReq frame followed...
Definition: ht-frame-exchange-manager.cc:706
ns3::MgtAddBaRequestHeader
Implement the header for management frames of type Add Block Ack request.
Definition: mgt-headers.h:1018
ns3::HtFrameExchangeManager::SetWifiMac
void SetWifiMac(const Ptr< RegularWifiMac > mac) override
Set the MAC layer to use.
Definition: ht-frame-exchange-manager.cc:78
ns3::HtFrameExchangeManager::CreateBlockAckAgreement
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: ht-frame-exchange-manager.cc:286
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::HtFrameExchangeManager::ForwardPsduDown
virtual void ForwardPsduDown(Ptr< const WifiPsdu > psdu, WifiTxVector &txVector)
Forward a PSDU down to the PHY layer.
Definition: ht-frame-exchange-manager.cc:923
ns3::HtFrameExchangeManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: ht-frame-exchange-manager.cc:43
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::HtFrameExchangeManager::SendDataFrame
virtual bool SendDataFrame(Ptr< const WifiMacQueueItem > 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...
Definition: ht-frame-exchange-manager.cc:439
third.mac
mac
Definition: third.py:99
ns3::WifiTxParameters
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
Definition: wifi-tx-parameters.h:45
ns3::HtFrameExchangeManager::RetransmitMpduAfterMissedAck
void RetransmitMpduAfterMissedAck(Ptr< WifiMacQueueItem > mpdu) const override
Retransmit an MPDU that was not acknowledged.
Definition: ht-frame-exchange-manager.cc:633
ns3::HtFrameExchangeManager::DestroyBlockAckAgreement
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Destroy a Block Ack agreement.
Definition: ht-frame-exchange-manager.cc:320
ns3::HtFrameExchangeManager::GetBaManager
Ptr< BlockAckManager > GetBaManager(uint8_t tid) const
Get the Block Ack Manager handling the given TID.
Definition: ht-frame-exchange-manager.cc:98
ns3::HtFrameExchangeManager
HtFrameExchangeManager handles the frame exchange sequences for HT stations.
Definition: ht-frame-exchange-manager.h:45
ns3::Ptr< QosTxop >
ns3::HtFrameExchangeManager::m_msduAggregator
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Definition: ht-frame-exchange-manager.h:380
ns3::QosFrameExchangeManager
QosFrameExchangeManager handles the frame exchange sequences for QoS stations.
Definition: qos-frame-exchange-manager.h:37
ns3::HtFrameExchangeManager::TryAggregateMsdu
virtual bool TryAggregateMsdu(Ptr< const WifiMacQueueItem > 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...
Definition: ht-frame-exchange-manager.cc:1005
ns3::HtFrameExchangeManager::m_mpduAggregator
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
Definition: ht-frame-exchange-manager.h:381
ns3::HtFrameExchangeManager::ReceiveMpdu
void ReceiveMpdu(Ptr< WifiMacQueueItem > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu) override
This method handles the reception of an MPDU (possibly included in an A-MPDU)
Definition: ht-frame-exchange-manager.cc:1294
ns3::BlockAckType
The different BlockAck variants.
Definition: block-ack-type.h:34
ns3::HtFrameExchangeManager::NotifyPacketDiscarded
void NotifyPacketDiscarded(Ptr< const WifiMacQueueItem > mpdu) override
Pass the given MPDU, discarded because of the max retry limit was reached, to the MPDU dropped callba...
Definition: ht-frame-exchange-manager.cc:603
HeAggregationTest
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
Definition: wifi-aggregation-test.cc:549
ns3::HtFrameExchangeManager::m_txParams
WifiTxParameters m_txParams
the TX parameters for the current frame
Definition: ht-frame-exchange-manager.h:391
ns3::HtFrameExchangeManager::IsWithinLimitsIfAddMpdu
bool IsWithinLimitsIfAddMpdu(Ptr< const WifiMacQueueItem > 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...
Definition: ht-frame-exchange-manager.cc:939
ns3::RecipientBlockAckAgreement
Maintains the scoreboard and the receive reordering buffer used by a recipient of a Block Ack agreeme...
Definition: recipient-block-ack-agreement.h:40
ns3::HtFrameExchangeManager::~HtFrameExchangeManager
virtual ~HtFrameExchangeManager()
Definition: ht-frame-exchange-manager.cc:60
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::HtFrameExchangeManager::CalculateAcknowledgmentTime
void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const override
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
Definition: ht-frame-exchange-manager.cc:485
TwoLevelAggregationTest
Two Level Aggregation Test.
Definition: wifi-aggregation-test.cc:324
ns3::MgtAddBaResponseHeader
Implement the header for management frames of type Add Block Ack response.
Definition: mgt-headers.h:1150
ns3::HtFrameExchangeManager::GetSupportedBaBufferSize
virtual uint16_t GetSupportedBaBufferSize(void) const
Get the maximum supported buffer size for a Block Ack agreement.
Definition: ht-frame-exchange-manager.cc:243
ns3::HtFrameExchangeManager::IsWithinAmpduSizeLimit
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...
Definition: ht-frame-exchange-manager.cc:982
ns3::HtFrameExchangeManager::GetMpduAggregator
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
Definition: ht-frame-exchange-manager.cc:92
ns3::HtFrameExchangeManager::TransmissionSucceeded
void TransmissionSucceeded(void) override
Take necessary actions upon a transmission success.
Definition: ht-frame-exchange-manager.cc:580
timeout
ns3::Time timeout
Definition: openflow-switch.cc:52
ns3::HtFrameExchangeManager::m_agreements
std::map< AgreementKey, RecipientBlockAckAgreement > m_agreements
agreements
Definition: ht-frame-exchange-manager.h:379
ns3::RxSignalInfo
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:67
ns3::WifiAcknowledgment
WifiAcknowledgment is an abstract base struct.
Definition: wifi-acknowledgment.h:45
ns3::HtFrameExchangeManager::NotifyTxToEdca
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.
Definition: ht-frame-exchange-manager.cc:874
ns3::HtFrameExchangeManager::ForwardMpduDown
void ForwardMpduDown(Ptr< WifiMacQueueItem > mpdu, WifiTxVector &txVector) override
Forward an MPDU down to the PHY layer.
Definition: ht-frame-exchange-manager.cc:516
ns3::HtFrameExchangeManager::m_psdu
Ptr< WifiPsdu > m_psdu
the A-MPDU being transmitted
Definition: ht-frame-exchange-manager.h:390
ns3::HtFrameExchangeManager::AgreementKey
std::pair< Mac48Address, uint8_t > AgreementKey
agreement key typedef (MAC address and TID)
Definition: ht-frame-exchange-manager.h:377
ns3::HtFrameExchangeManager::GetMsduAggregator
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
Definition: ht-frame-exchange-manager.cc:86
ns3::HtFrameExchangeManager::HtFrameExchangeManager
HtFrameExchangeManager()
Definition: ht-frame-exchange-manager.cc:53
ns3::HtFrameExchangeManager::DequeuePsdu
void DequeuePsdu(Ptr< const WifiPsdu > psdu)
Dequeue the MPDUs of the given PSDU from the queue in which they are stored.
Definition: ht-frame-exchange-manager.cc:912
ns3::HtFrameExchangeManager::GetWifiPsdu
virtual Ptr< WifiPsdu > GetWifiPsdu(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector) const
Get a PSDU containing the given MPDU.
Definition: ht-frame-exchange-manager.cc:522
ns3::HtFrameExchangeManager::SendPsdu
void SendPsdu(void)
Send the current PSDU, which can be acknowledged by a BlockAck frame or followed by a BlockAckReq fra...
Definition: ht-frame-exchange-manager.cc:797
ns3::HtFrameExchangeManager::EndReceiveAmpdu
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.
Definition: ht-frame-exchange-manager.cc:1419
ns3::HtFrameExchangeManager::SendAddBaResponse
void SendAddBaResponse(const MgtAddBaRequestHeader *reqHdr, Mac48Address originator)
This method can be called to accept a received ADDBA Request.
Definition: ht-frame-exchange-manager.cc:193
ns3::HtFrameExchangeManager::NotifyReceivedNormalAck
void NotifyReceivedNormalAck(Ptr< WifiMacQueueItem > mpdu) override
Notify other components that an MPDU was acknowledged.
Definition: ht-frame-exchange-manager.cc:528
ns3::HtFrameExchangeManager::GetPsduDurationId
virtual Time GetPsduDurationId(Time txDuration, const WifiTxParameters &txParams) const
Compute how to set the Duration/ID field of PSDUs that do not include fragments.
Definition: ht-frame-exchange-manager.cc:686
ns3::WifiModulationClass
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Definition: wifi-phy-common.h:122
ns3::HtFrameExchangeManager::BlockAckTimeout
virtual void BlockAckTimeout(Ptr< WifiPsdu > psdu, const WifiTxVector &txVector)
Called when the BlockAck timeout expires.
Definition: ht-frame-exchange-manager.cc:1125
ns3::HtFrameExchangeManager::SendDelbaFrame
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.
Definition: ht-frame-exchange-manager.cc:249
ns3::HtFrameExchangeManager::GetBaAgreementEstablished
bool GetBaAgreementEstablished(Mac48Address originator, uint8_t tid) const
Return true if a Block Ack agreement has been established with the given originator for the given TID...
Definition: ht-frame-exchange-manager.cc:1280