diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index c9caa1864..01fcbb03e 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -2099,19 +2099,20 @@ HeFrameExchangeManager::IntraBssNavResetTimeout() m_channelAccessManager->NotifyNavResetNow(basicNav); } -void -HeFrameExchangeManager::SetTxopHolder(Ptr psdu, const WifiTxVector& txVector) +std::optional +HeFrameExchangeManager::FindTxopHolder(const WifiMacHeader& hdr, const WifiTxVector& txVector) { - NS_LOG_FUNCTION(this << psdu << txVector); + NS_LOG_FUNCTION(this << hdr << txVector); - if (psdu->GetHeader(0).IsTrigger() && psdu->GetAddr2() == m_bssid) + if (hdr.IsTrigger() && hdr.GetAddr2() == m_bssid) { - m_txopHolder = m_bssid; + return m_bssid; } - else if (!txVector.IsUlMu()) // the sender of a TB PPDU is not the TXOP holder + if (!txVector.IsUlMu()) // the sender of a TB PPDU is not the TXOP holder { - VhtFrameExchangeManager::SetTxopHolder(psdu, txVector); + return VhtFrameExchangeManager::FindTxopHolder(hdr, txVector); } + return std::nullopt; } bool diff --git a/src/wifi/model/he/he-frame-exchange-manager.h b/src/wifi/model/he/he-frame-exchange-manager.h index a11e63c92..11274edf7 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.h +++ b/src/wifi/model/he/he-frame-exchange-manager.h @@ -79,7 +79,8 @@ class HeFrameExchangeManager : public VhtFrameExchangeManager void SetWifiMac(const Ptr mac) override; void CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledgment) const override; void CalculateProtectionTime(WifiProtection* protection) const override; - void SetTxopHolder(Ptr psdu, const WifiTxVector& txVector) override; + std::optional FindTxopHolder(const WifiMacHeader& hdr, + const WifiTxVector& txVector) override; bool VirtualCsMediumIdle() const override; /** diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index 12a43cac2..1a175ab6e 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -704,8 +704,16 @@ void QosFrameExchangeManager::SetTxopHolder(Ptr psdu, const WifiTxVector& txVector) { NS_LOG_FUNCTION(this << psdu << txVector); + if (auto txopHolder = FindTxopHolder(psdu->GetHeader(0), txVector)) + { + m_txopHolder = *txopHolder; + } +} - const WifiMacHeader& hdr = psdu->GetHeader(0); +std::optional +QosFrameExchangeManager::FindTxopHolder(const WifiMacHeader& hdr, const WifiTxVector& txVector) +{ + NS_LOG_FUNCTION(this << hdr << txVector); // A STA shall save the TXOP holder address for the BSS in which it is associated. // The TXOP holder address is the MAC address from the Address 2 field of the frame @@ -714,12 +722,13 @@ QosFrameExchangeManager::SetTxopHolder(Ptr psdu, const WifiTxVec if ((hdr.IsQosData() || hdr.IsMgt() || hdr.IsRts()) && (hdr.GetAddr1() == m_bssid || hdr.GetAddr2() == m_bssid)) { - m_txopHolder = psdu->GetAddr2(); + return hdr.GetAddr2(); } - else if (hdr.IsCts() && hdr.GetAddr1() == m_bssid) + if (hdr.IsCts() && hdr.GetAddr1() == m_bssid) { - m_txopHolder = psdu->GetAddr1(); + return hdr.GetAddr1(); } + return std::nullopt; } void diff --git a/src/wifi/model/qos-frame-exchange-manager.h b/src/wifi/model/qos-frame-exchange-manager.h index a617c12d3..ac2422fe2 100644 --- a/src/wifi/model/qos-frame-exchange-manager.h +++ b/src/wifi/model/qos-frame-exchange-manager.h @@ -171,12 +171,14 @@ class QosFrameExchangeManager : public FrameExchangeManager virtual bool SendCfEndIfNeeded(); /** - * Set the TXOP holder, if needed, based on the received frame + * Determine the holder of the TXOP, if possible, based on the received frame * - * \param psdu the received PSDU + * \param hdr the MAC header of an MPDU included in the received PSDU * \param txVector TX vector of the received PSDU + * \return the holder of the TXOP, if one was found */ - virtual void SetTxopHolder(Ptr psdu, const WifiTxVector& txVector); + virtual std::optional FindTxopHolder(const WifiMacHeader& hdr, + const WifiTxVector& txVector); /** * Clear the TXOP holder if the NAV counted down to zero (includes the case of NAV reset). @@ -189,6 +191,14 @@ class QosFrameExchangeManager : public FrameExchangeManager QoS Control field of QoS data frames */ private: + /** + * Set the TXOP holder, if needed, based on the received frame + * + * \param psdu the received PSDU + * \param txVector TX vector of the received PSDU + */ + void SetTxopHolder(Ptr psdu, const WifiTxVector& txVector); + /** * Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery * release the channel.