From dd5ce2e03700d42b184d0ff48c1183dd16bd1dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 29 Sep 2024 15:32:46 +0200 Subject: [PATCH] wifi: Do not instantiate HE PHY headers for EHT PPDUs --- src/wifi/model/eht/eht-ppdu.cc | 43 ++++++++++++++++++++++++++++++++-- src/wifi/model/eht/eht-ppdu.h | 3 ++- src/wifi/model/he/he-ppdu.cc | 22 ++++++++++++----- src/wifi/model/he/he-ppdu.h | 28 +++++++++++++--------- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/src/wifi/model/eht/eht-ppdu.cc b/src/wifi/model/eht/eht-ppdu.cc index b8689cf33..3aa3283b1 100644 --- a/src/wifi/model/eht/eht-ppdu.cc +++ b/src/wifi/model/eht/eht-ppdu.cc @@ -28,7 +28,7 @@ EhtPpdu::EhtPpdu(const WifiConstPsduMap& psdus, Time ppduDuration, uint64_t uid, TxPsdFlag flag) - : HePpdu(psdus, txVector, channel, ppduDuration, uid, flag) + : HePpdu(psdus, txVector, channel, ppduDuration, uid, flag, false) { NS_LOG_FUNCTION(this << psdus << txVector << channel << ppduDuration << uid << flag); SetPhyHeaders(txVector, ppduDuration); @@ -38,6 +38,7 @@ void EhtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration) { NS_LOG_FUNCTION(this << txVector << ppduDuration); + SetLSigHeader(ppduDuration); SetEhtPhyHeader(txVector); } @@ -133,7 +134,7 @@ EhtPpdu::SetTxVectorFromPhyHeaders(WifiTxVector& txVector) const { // TODO: use punctured channel information } - txVector.SetSigBMode(HePhy::GetVhtMcs(ehtPhyHeader->m_ehtSigMcs)); + txVector.SetSigBMode(EhtPhy::GetVhtMcs(ehtPhyHeader->m_ehtSigMcs)); txVector.SetGuardInterval(GetGuardIntervalFromEncoding(ehtPhyHeader->m_giLtfSize)); const auto ruAllocation = ehtPhyHeader->m_ruAllocationA; // RU Allocation-B not supported // yet @@ -313,6 +314,44 @@ EhtPpdu::GetPuncturedInfo(const std::vector& inactiveSubchannels, return 0; } +Ptr +EhtPpdu::GetPsdu(uint8_t bssColor, uint16_t staId /* = SU_STA_ID */) const +{ + if (m_psdus.contains(SU_STA_ID)) + { + NS_ASSERT(m_psdus.size() == 1); + return m_psdus.at(SU_STA_ID); + } + + if (IsUlMu()) + { + auto ehtPhyHeader = std::get_if(&m_ehtPhyHeader); + NS_ASSERT(ehtPhyHeader); + NS_ASSERT(m_psdus.size() == 1); + if ((bssColor == 0) || (ehtPhyHeader->m_bssColor == 0) || + (bssColor == ehtPhyHeader->m_bssColor)) + { + return m_psdus.cbegin()->second; + } + } + else if (IsDlMu()) + { + auto ehtPhyHeader = std::get_if(&m_ehtPhyHeader); + NS_ASSERT(ehtPhyHeader); + if ((bssColor == 0) || (ehtPhyHeader->m_bssColor == 0) || + (bssColor == ehtPhyHeader->m_bssColor)) + { + const auto it = m_psdus.find(staId); + if (it != m_psdus.cend()) + { + return it->second; + } + } + } + + return nullptr; +} + Ptr EhtPpdu::Copy() const { diff --git a/src/wifi/model/eht/eht-ppdu.h b/src/wifi/model/eht/eht-ppdu.h index f021137fd..15d4310af 100644 --- a/src/wifi/model/eht/eht-ppdu.h +++ b/src/wifi/model/eht/eht-ppdu.h @@ -90,6 +90,7 @@ class EhtPpdu : public HePpdu TxPsdFlag flag); WifiPpduType GetType() const override; + Ptr GetPsdu(uint8_t bssColor, uint16_t staId = SU_STA_ID) const override; Ptr Copy() const override; /** @@ -161,7 +162,7 @@ class EhtPpdu : public HePpdu * @param txVector the TXVECTOR that was used for this PPDU * @param ppduDuration the transmission duration of this PPDU */ - void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); + void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration) override; /** * Fill in the EHT PHY header. diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index b5963c3d6..88cbd0ae2 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -46,7 +46,8 @@ HePpdu::HePpdu(const WifiConstPsduMap& psdus, const WifiPhyOperatingChannel& channel, Time ppduDuration, uint64_t uid, - TxPsdFlag flag) + TxPsdFlag flag, + bool instantiateHeaders /* = true */) : OfdmPpdu(psdus.begin()->second, txVector, channel, @@ -54,20 +55,25 @@ HePpdu::HePpdu(const WifiConstPsduMap& psdus, false), // don't instantiate LSigHeader of OfdmPpdu m_txPsdFlag(flag) { - NS_LOG_FUNCTION(this << psdus << txVector << channel << ppduDuration << uid << flag); + NS_LOG_FUNCTION(this << psdus << txVector << channel << ppduDuration << uid << flag + << instantiateHeaders); // overwrite with map (since only first element used by OfdmPpdu) m_psdus.begin()->second = nullptr; m_psdus.clear(); m_psdus = psdus; - SetPhyHeaders(txVector, ppduDuration); + if (instantiateHeaders) + { + SetPhyHeaders(txVector, ppduDuration); + } } HePpdu::HePpdu(Ptr psdu, const WifiTxVector& txVector, const WifiPhyOperatingChannel& channel, Time ppduDuration, - uint64_t uid) + uint64_t uid, + bool instantiateHeaders /* = true */) : OfdmPpdu(psdu, txVector, channel, @@ -75,9 +81,13 @@ HePpdu::HePpdu(Ptr psdu, false), // don't instantiate LSigHeader of OfdmPpdu m_txPsdFlag(PSD_NON_HE_PORTION) { - NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid); + NS_LOG_FUNCTION(this << psdu << txVector << channel << ppduDuration << uid + << instantiateHeaders); NS_ASSERT(!IsMu()); - SetPhyHeaders(txVector, ppduDuration); + if (instantiateHeaders) + { + SetPhyHeaders(txVector, ppduDuration); + } } void diff --git a/src/wifi/model/he/he-ppdu.h b/src/wifi/model/he/he-ppdu.h index ec6a5e368..78142d729 100644 --- a/src/wifi/model/he/he-ppdu.h +++ b/src/wifi/model/he/he-ppdu.h @@ -114,12 +114,15 @@ class HePpdu : public OfdmPpdu * @param channel the operating channel of the PHY used to transmit this PPDU * @param ppduDuration the transmission duration of this PPDU * @param uid the unique ID of this PPDU + * @param instantiateHeaders flag used to instantiate HE header, should be disabled by child + * classes */ HePpdu(Ptr psdu, const WifiTxVector& txVector, const WifiPhyOperatingChannel& channel, Time ppduDuration, - uint64_t uid); + uint64_t uid, + bool instantiateHeaders = true); /** * Create an MU HE PPDU, storing a map of PSDUs. * @@ -131,13 +134,16 @@ class HePpdu : public OfdmPpdu * @param ppduDuration the transmission duration of this PPDU * @param uid the unique ID of this PPDU or of the triggering PPDU if this is an HE TB PPDU * @param flag the flag indicating the type of Tx PSD to build + * @param instantiateHeaders flag used to instantiate HE header, should be disabled by child + * classes */ HePpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, const WifiPhyOperatingChannel& channel, Time ppduDuration, uint64_t uid, - TxPsdFlag flag); + TxPsdFlag flag, + bool instantiateHeaders = true); Time GetTxDuration() const override; Ptr Copy() const override; @@ -152,7 +158,7 @@ class HePpdu : public OfdmPpdu * @param staId the STA-ID of the PHY calling this function. * @return the PSDU */ - Ptr GetPsdu(uint8_t bssColor, uint16_t staId = SU_STA_ID) const; + virtual Ptr GetPsdu(uint8_t bssColor, uint16_t staId = SU_STA_ID) const; /** * @return the transmit PSD flag set for this PPDU @@ -231,6 +237,13 @@ class HePpdu : public OfdmPpdu */ virtual void SetTxVectorFromPhyHeaders(WifiTxVector& txVector) const; + /** + * Fill in the L-SIG header. + * + * @param ppduDuration the transmission duration of this PPDU + */ + void SetLSigHeader(Time ppduDuration); + /** * Reconstruct HeMuUserInfoMap from HE-SIG-B header. * @@ -341,14 +354,7 @@ class HePpdu : public OfdmPpdu * @param txVector the TXVECTOR that was used for this PPDU * @param ppduDuration the transmission duration of this PPDU */ - void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); - - /** - * Fill in the L-SIG header. - * - * @param ppduDuration the transmission duration of this PPDU - */ - void SetLSigHeader(Time ppduDuration); + virtual void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); /** * Fill in the HE-SIG header.