From 255499b3c7bc1168b98a93c921e79ed4e1bbceca Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sun, 29 Nov 2020 19:11:10 +0100 Subject: [PATCH] wifi: Add some new QosTxop methods --- src/wifi/model/qos-txop.cc | 34 ++++++++++++++++++++++++ src/wifi/model/qos-txop.h | 54 ++++++++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 14 deletions(-) diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 28197920a..6170cac27 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -127,6 +127,22 @@ QosTxop::DoDispose (void) Txop::DoDispose (); } +void +QosTxop::SetQosQueueSize (Ptr mpdu) +{ + NS_LOG_FUNCTION (this << *mpdu); + + WifiMacHeader& hdr = mpdu->GetHeader (); + NS_ASSERT (hdr.IsQosData ()); + + uint32_t bufferSize = m_queue->GetNBytes (hdr.GetQosTid (), hdr.GetAddr1 ()) + + m_baManager->GetRetransmitQueue ()->GetNBytes (hdr.GetQosTid (), hdr.GetAddr1 ()); + // A queue size value of 254 is used for all sizes greater than 64 768 octets. + uint8_t queueSize = static_cast (std::ceil (std::min (bufferSize, 64769u) / 256.0)); + NS_LOG_DEBUG ("Buffer size=" << bufferSize << " Queue Size=" << +queueSize); + hdr.SetQosQueueSize (queueSize); +} + void QosTxop::SetQosFrameExchangeManager (const Ptr qosFem) { @@ -134,6 +150,12 @@ QosTxop::SetQosFrameExchangeManager (const Ptr qosFem) m_qosFem = qosFem; } +Ptr +QosTxop::GetBaManager (void) +{ + return m_baManager; +} + bool QosTxop::GetBaAgreementEstablished (Mac48Address address, uint8_t tid) const { @@ -213,6 +235,12 @@ QosTxop::GetTypeOfStation (void) const return m_typeOfStation; } +bool +QosTxop::UseExplicitBarAfterMissedBlockAck (void) const +{ + return m_useExplicitBarAfterMissedBlockAck; +} + bool QosTxop::HasFramesToTransmit (void) { @@ -1785,6 +1813,12 @@ QosTxop::GetBlockAckThreshold (void) const return m_blockAckThreshold; } +uint16_t +QosTxop::GetBlockAckInactivityTimeout (void) const +{ + return m_blockAckInactivityTimeout; +} + void QosTxop::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck) diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index 90b987780..427d7af24 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -165,6 +165,19 @@ public: */ void SetQosFrameExchangeManager (const Ptr qosFem); + /** + * Return true if an explicit BlockAckRequest is sent after a missed BlockAck + * + * \return true if an explicit BlockAckRequest is sent after a missed BlockAck + */ + bool UseExplicitBarAfterMissedBlockAck (void) const; + + /** + * Get the Block Ack Manager associated with this QosTxop. + * + * \returns the Block Ack Manager + */ + Ptr GetBaManager (void); /** * \param address recipient address of the peer station * \param tid traffic ID. @@ -255,6 +268,20 @@ public: * \param recipient address of the recipient. */ void GotDelBaFrame (const MgtDelBaHeader *delBaHdr, Mac48Address recipient); + /** + * Callback when ADDBA response is not received after timeout. + * + * \param recipient MAC address of recipient + * \param tid traffic ID + */ + void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid); + /** + * Reset BA agreement after BA negotiation failed. + * + * \param recipient MAC address of recipient + * \param tid traffic ID + */ + void ResetBa (Mac48Address recipient, uint8_t tid); /** * Check if BlockAckRequest should be re-transmitted. @@ -305,6 +332,12 @@ public: * \param timeout the BlockAck inactivity timeout. */ void SetBlockAckInactivityTimeout (uint16_t timeout); + /** + * Get the BlockAck inactivity timeout. + * + * \return the BlockAck inactivity timeout. + */ + uint16_t GetBlockAckInactivityTimeout (void) const; /** * Sends DELBA frame to cancel a block ack agreement with STA * addressed by addr for TID tid. @@ -532,6 +565,13 @@ public: */ Mac48Address MapDestAddressForAggregation (const WifiMacHeader &hdr); + /** + * Set the Queue Size subfield of the QoS Control field of the given QoS data frame. + * + * \param mpdu the given QoS data frame + */ + void SetQosQueueSize (Ptr mpdu); + /** * Return true if a TXOP has started. * @@ -623,20 +663,6 @@ private: * \returns the TXOP fragment offset in bytes */ uint32_t GetTxopFragmentOffset (uint32_t fragmentNumber) const; - /** - * Callback when ADDBA response is not received after timeout. - * - * \param recipient MAC address of recipient - * \param tid traffic ID - */ - void AddBaResponseTimeout (Mac48Address recipient, uint8_t tid); - /** - * Reset BA agreement after BA negotiation failed. - * - * \param recipient MAC address of recipient - * \param tid traffic ID - */ - void ResetBa (Mac48Address recipient, uint8_t tid); AcIndex m_ac; //!< the access category TypeOfStation m_typeOfStation; //!< the type of station