From b035ad56f082c0ee6262d1ff33ff79b16ff9709c Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sat, 15 Jan 2022 16:07:04 +0100 Subject: [PATCH] wifi: Set TXVECTOR's RU PHY indices in HePpdu constructor This is a better place than WifiPhy::Send() because it is an operation specific to HE. Also, we avoid copying the WifiTxVector to pass to WifiPhy::Send(). --- src/wifi/model/he/he-phy.cc | 3 ++- src/wifi/model/he/he-ppdu.cc | 12 +++++++++--- src/wifi/model/he/he-ppdu.h | 3 ++- src/wifi/model/wifi-phy.cc | 12 +----------- src/wifi/model/wifi-phy.h | 2 +- src/wifi/test/wifi-phy-ofdma-test.cc | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 3f8a9e93f..378c7bdcb 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -328,7 +328,8 @@ HePhy::BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, flag = HePpdu::PSD_NON_HE_TB; } return Create (psdus, txVector, ppduDuration, m_wifiPhy->GetPhyBand (), - ObtainNextUid (txVector), flag); + ObtainNextUid (txVector), flag, + m_wifiPhy->GetOperatingChannel ().GetPrimaryChannelIndex (20)); } void diff --git a/src/wifi/model/he/he-ppdu.cc b/src/wifi/model/he/he-ppdu.cc index f3b284bfe..0b7e573c5 100644 --- a/src/wifi/model/he/he-ppdu.cc +++ b/src/wifi/model/he/he-ppdu.cc @@ -48,7 +48,7 @@ std::ostream& operator<< (std::ostream& os, const HePpdu::TxPsdFlag &flag) } HePpdu::HePpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration, - WifiPhyBand band, uint64_t uid, TxPsdFlag flag) + WifiPhyBand band, uint64_t uid, TxPsdFlag flag, uint8_t p20Index) : OfdmPpdu (psdus.begin ()->second, txVector, band, uid, false) //don't instantiate LSigHeader of OfdmPpdu { NS_LOG_FUNCTION (this << psdus << txVector << ppduDuration << band << uid << flag); @@ -59,7 +59,13 @@ HePpdu::HePpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Ti m_psdus = psdus; if (IsMu ()) { - m_muUserInfos = txVector.GetHeMuUserInfoMap (); + for (auto heMuUserInfo : txVector.GetHeMuUserInfoMap ()) + { + // Set RU PHY index + heMuUserInfo.second.ru.SetPhyIndex (txVector.GetChannelWidth (), p20Index); + auto [it, ret] = m_muUserInfos.emplace (heMuUserInfo); + NS_ABORT_MSG_IF (!ret, "STA-ID " << heMuUserInfo.first << " already present"); + } } SetPhyHeaders (txVector, ppduDuration); @@ -159,7 +165,7 @@ HePpdu::GetTxDuration (void) const Ptr HePpdu::Copy (void) const { - return Create (m_psdus, GetTxVector (), GetTxDuration (), m_band, m_uid, m_txPsdFlag); + return ns3::Copy (Ptr (this)); } WifiPpduType diff --git a/src/wifi/model/he/he-ppdu.h b/src/wifi/model/he/he-ppdu.h index 81ae09a22..28de677f6 100644 --- a/src/wifi/model/he/he-ppdu.h +++ b/src/wifi/model/he/he-ppdu.h @@ -184,9 +184,10 @@ public: * \param band the WifiPhyBand used for the transmission 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 p20Index the index of the primary 20 MHz channel */ HePpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration, - WifiPhyBand band, uint64_t uid, TxPsdFlag flag); + WifiPhyBand band, uint64_t uid, TxPsdFlag flag, uint8_t p20Index); /** * Destructor for HePpdu. */ diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 32045b0a7..a53f9471d 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1687,7 +1687,7 @@ WifiPhy::Send (Ptr psdu, const WifiTxVector& txVector) } void -WifiPhy::Send (WifiConstPsduMap psdus, WifiTxVector txVector) +WifiPhy::Send (WifiConstPsduMap psdus, const WifiTxVector& txVector) { NS_LOG_FUNCTION (this << psdus << txVector); /* Transmission can happen if: @@ -1713,16 +1713,6 @@ WifiPhy::Send (WifiConstPsduMap psdus, WifiTxVector txVector) } return; } - - // Set RU PHY indices - if (txVector.IsMu ()) - { - for (auto& heMuUserInfo : txVector.GetHeMuUserInfoMap ()) - { - heMuUserInfo.second.ru.SetPhyIndex (txVector.GetChannelWidth (), - m_operatingChannel.GetPrimaryChannelIndex (20)); - } - } Time txDuration = CalculateTxDuration (psdus, txVector, GetPhyBand ()); diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 6e3ff8d07..2780fe5c1 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -147,7 +147,7 @@ public: * this PSDU, and txPowerLevel, a power level to use to send the whole PPDU. The real transmission * power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels */ - void Send (WifiConstPsduMap psdus, WifiTxVector txVector); + void Send (WifiConstPsduMap psdus, const WifiTxVector& txVector); /** * \param ppdu the PPDU to send diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 98b5a7cc9..fbd74d230 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -1463,7 +1463,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu (uint64_t uid, uint16_t staId, double txPo Time ppduDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand (), staId); Ptr ppdu = Create (psdus, txVector, ppduDuration, WIFI_PHY_BAND_5GHZ, uid, - HePpdu::PSD_HE_TB_NON_OFDMA_PORTION); + HePpdu::PSD_HE_TB_NON_OFDMA_PORTION, 0); //Send non-OFDMA part Time nonOfdmaDuration = m_phy->GetHePhy ()->CalculateNonOfdmaDurationForHeTb (txVector);