From 847c88d392ca7f767265f3ed4a908d9fea6787b5 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 13 May 2021 19:39:20 +0200 Subject: [PATCH] wifi: BlockAckManager does not need to hold a pointer to WifiRemoteStationManager --- src/wifi/model/block-ack-manager.cc | 30 +++++++------------ src/wifi/model/block-ack-manager.h | 22 +++++--------- .../model/he/he-frame-exchange-manager.cc | 15 ++++++---- .../model/ht/ht-frame-exchange-manager.cc | 5 ++-- src/wifi/model/qos-txop.cc | 8 ----- src/wifi/model/qos-txop.h | 1 - 6 files changed, 31 insertions(+), 50 deletions(-) diff --git a/src/wifi/model/block-ack-manager.cc b/src/wifi/model/block-ack-manager.cc index b42a71a95..3f0c9f7fe 100644 --- a/src/wifi/model/block-ack-manager.cc +++ b/src/wifi/model/block-ack-manager.cc @@ -21,7 +21,7 @@ #include "ns3/log.h" #include "ns3/simulator.h" #include "block-ack-manager.h" -#include "wifi-remote-station-manager.h" +#include "wifi-utils.h" #include "ctrl-headers.h" #include "mgt-headers.h" #include "wifi-mac-queue.h" @@ -82,7 +82,6 @@ BlockAckManager::DoDispose () m_retryPackets = nullptr; m_bars.clear (); m_queue = nullptr; - m_stationManager = nullptr; } bool @@ -120,9 +119,9 @@ BlockAckManager::ExistsAgreementInState (Mac48Address recipient, uint8_t tid, } void -BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient) +BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported) { - NS_LOG_FUNCTION (this << reqHdr << recipient); + NS_LOG_FUNCTION (this << reqHdr << recipient << htSupported); std::pair key (recipient, reqHdr->GetTid ()); OriginatorBlockAckAgreement agreement (recipient, reqHdr->GetTid ()); agreement.SetStartingSequence (reqHdr->GetStartingSequence ()); @@ -131,7 +130,7 @@ BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Addr agreement.SetBufferSize (reqHdr->GetBufferSize()); agreement.SetTimeout (reqHdr->GetTimeout ()); agreement.SetAmsduSupport (reqHdr->IsAmsduSupported ()); - agreement.SetHtSupported (m_stationManager->GetHtSupported () && m_stationManager->GetHtSupported (recipient)); + agreement.SetHtSupported (htSupported); if (reqHdr->IsImmediateBlockAck ()) { agreement.SetImmediateBlockAck (); @@ -393,13 +392,6 @@ BlockAckManager::SetBlockAckThreshold (uint8_t nPackets) m_blockAckThreshold = nPackets; } -void -BlockAckManager::SetWifiRemoteStationManager (const Ptr manager) -{ - NS_LOG_FUNCTION (this << manager); - m_stationManager = manager; -} - void BlockAckManager::NotifyGotAck (Ptr mpdu) { @@ -462,12 +454,14 @@ BlockAckManager::NotifyMissedAck (Ptr mpdu) InsertInRetryQueue (mpdu); } -void +std::pair BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, Mac48Address recipient, - const std::set& tids, double rxSnr, double dataSnr, - const WifiTxVector& dataTxVector, size_t index) + const std::set& tids, size_t index) { - NS_LOG_FUNCTION (this << blockAck << recipient << rxSnr << dataSnr << dataTxVector << index); + NS_LOG_FUNCTION (this << blockAck << recipient << index); + uint16_t nSuccessfulMpdus = 0; + uint16_t nFailedMpdus = 0; + if (!blockAck.IsMultiTid ()) { uint8_t tid = blockAck.GetTidInfo (index); @@ -481,8 +475,6 @@ BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, Mac4 if (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::ESTABLISHED)) { bool foundFirstLost = false; - uint16_t nSuccessfulMpdus = 0; - uint16_t nFailedMpdus = 0; AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); PacketQueueI queueEnd = it->second.second.end (); @@ -558,7 +550,6 @@ BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, Mac4 queueIt = it->second.second.erase (queueIt); } } - m_stationManager->ReportAmpduTxStatus (recipient, nSuccessfulMpdus, nFailedMpdus, rxSnr, dataSnr, dataTxVector); } } else @@ -566,6 +557,7 @@ BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, Mac4 //NOT SUPPORTED FOR NOW NS_FATAL_ERROR ("Multi-tid block ack is not supported."); } + return {nSuccessfulMpdus, nFailedMpdus}; } void diff --git a/src/wifi/model/block-ack-manager.h b/src/wifi/model/block-ack-manager.h index 78ee71d62..1233720f1 100644 --- a/src/wifi/model/block-ack-manager.h +++ b/src/wifi/model/block-ack-manager.h @@ -32,7 +32,6 @@ namespace ns3 { -class WifiRemoteStationManager; class MgtAddBaResponseHeader; class MgtAddBaRequestHeader; class CtrlBAckResponseHeader; @@ -90,12 +89,6 @@ public: BlockAckManager (); ~BlockAckManager (); - /** - * Set up WifiRemoteStationManager associated with this BlockAckManager. - * - * \param manager WifiRemoteStationManager associated with this BlockAckManager - */ - void SetWifiRemoteStationManager (const Ptr manager); /** * \param recipient Address of peer station involved in block ack mechanism. * \param tid Traffic ID. @@ -121,11 +114,12 @@ public: /** * \param reqHdr Relative Add block ack request (action frame). * \param recipient Address of peer station involved in block ack mechanism. + * \param htSupported Whether both originator and recipient support HT * * Creates a new block ack agreement in pending state. When a ADDBA response * with a successful status code is received, the relative agreement becomes established. */ - void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient); + void CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient, bool htSupported = true); /** * \param recipient Address of peer station involved in block ack mechanism. * \param tid traffic ID of transmitted packet. @@ -194,11 +188,10 @@ public: * \param blockAck The received BlockAck frame. * \param recipient Sender of BlockAck frame. * \param tids the set of TIDs the acknowledged MPDUs belong to - * \param rxSnr received SNR of the BlockAck frame itself - * \param dataSnr data SNR reported by remote station - * \param dataTxVector the TXVECTOR used to send the Data * \param index the index of the Per AID TID Info subfield, in case of Multi-STA * Block Ack, or 0, otherwise + * \return a pair of values indicating the number of successfully received MPDUs + * and the number of failed MPDUs * * Invoked upon receipt of a BlockAck frame. Typically, this function, is called * by ns3::QosTxop object. Performs a check on which MPDUs, previously sent @@ -207,9 +200,9 @@ public: * Note that tids is only used if blockAck is a Multi-STA Block Ack * using All-ack context. */ - void NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, Mac48Address recipient, - const std::set& tids, double rxSnr, double dataSnr, - const WifiTxVector& dataTxVector, size_t index = 0); + std::pair NotifyGotBlockAck (const CtrlBAckResponseHeader& blockAck, + Mac48Address recipient, const std::set& tids, + size_t index = 0); /** * \param recipient Sender of the expected BlockAck frame. * \param tid Traffic ID. @@ -534,7 +527,6 @@ private: Callback m_unblockPackets; ///< unblock packets callback TxOk m_txOkCallback; ///< transmit OK callback TxFailed m_txFailedCallback; ///< transmit failed callback - Ptr m_stationManager; ///< the station manager /** * The trace source fired when a state transition occurred. diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index 9919553d2..18ac6ac27 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -1428,8 +1428,10 @@ HeFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rx CtrlBAckResponseHeader blockAck; mpdu->GetPacket ()->PeekHeader (blockAck); uint8_t tid = blockAck.GetTidInfo (); - GetBaManager (tid)->NotifyGotBlockAck (blockAck, hdr.GetAddr2 (), {tid}, rxSignalInfo.snr, - tag.Get (), m_txParams.m_txVector); + std::pair ret = GetBaManager (tid)->NotifyGotBlockAck (blockAck, hdr.GetAddr2 (), + {tid}); + m_mac->GetWifiRemoteStationManager ()->ReportAmpduTxStatus (hdr.GetAddr2 (), ret.first, ret.second, + rxSignalInfo.snr, tag.Get (), m_txParams.m_txVector); // remove the sender from the set of stations that are expected to send a BlockAck if (m_staExpectTbPpduFrom.erase (sender) == 0) @@ -1497,9 +1499,12 @@ HeFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rx tid = *tids.begin (); } - GetBaManager (tid)->NotifyGotBlockAck (blockAck, hdr.GetAddr2 (), {tid}, - rxSignalInfo.snr, tag.Get (staId), - m_txParams.m_txVector, index); + std::pair ret = GetBaManager (tid)->NotifyGotBlockAck (blockAck, + hdr.GetAddr2 (), + {tid}, index); + m_mac->GetWifiRemoteStationManager ()->ReportAmpduTxStatus (hdr.GetAddr2 (), ret.first, + ret.second, rxSignalInfo.snr, + tag.Get (staId), m_txParams.m_txVector); } } diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index 9296b4721..4c5631505 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -1343,8 +1343,9 @@ HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rx CtrlBAckResponseHeader blockAck; mpdu->GetPacket ()->PeekHeader (blockAck); uint8_t tid = blockAck.GetTidInfo (); - GetBaManager (tid)->NotifyGotBlockAck (blockAck, hdr.GetAddr2 (), {tid}, rxSnr, - tag.Get (), m_txParams.m_txVector); + std::pair ret = GetBaManager (tid)->NotifyGotBlockAck (blockAck, hdr.GetAddr2 (), {tid}); + m_mac->GetWifiRemoteStationManager ()->ReportAmpduTxStatus (hdr.GetAddr2 (), ret.first, ret.second, + rxSnr, tag.Get (), m_txParams.m_txVector); // cancel the timer m_txTimer.Cancel (); diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 7efa13d59..93bb66f9d 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -203,14 +203,6 @@ QosTxop::ScheduleBar (Ptr bar, bool skipIfNoDataQueued) m_baManager->ScheduleBar (bar, skipIfNoDataQueued); } -void -QosTxop::SetWifiRemoteStationManager (const Ptr remoteManager) -{ - Txop::SetWifiRemoteStationManager (remoteManager); - NS_LOG_FUNCTION (this << remoteManager); - m_baManager->SetWifiRemoteStationManager (m_stationManager); -} - bool QosTxop::UseExplicitBarAfterMissedBlockAck (void) const { diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index 110cc0ee3..f135fadbb 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -85,7 +85,6 @@ public: bool IsQosTxop (void) const override; AcIndex GetAccessCategory (void) const override; - void SetWifiRemoteStationManager (const Ptr remoteManager) override; bool HasFramesToTransmit (void) override; void NotifyInternalCollision (void) override; void NotifyChannelAccessed (Time txopDuration) override;