diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index c0571d03d..8b7f07836 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -1180,6 +1180,20 @@ HePhy::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */) return true; } +WifiConstPsduMap +HePhy::GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector) const +{ + uint16_t staId = SU_STA_ID; + + if (txVector.IsUlMu ()) + { + NS_ASSERT (txVector.GetHeMuUserInfoMap ().size () == 1); + staId = txVector.GetHeMuUserInfoMap ().begin ()->first; + } + + return WifiConstPsduMap ({std::make_pair (staId, psdu)}); +} + uint32_t HePhy::GetMaxPsduSize (void) const { diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index fb0b270b0..23b79d0e5 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -416,6 +416,8 @@ protected: */ virtual uint32_t GetMaxPsduSize (void) const override; + virtual WifiConstPsduMap GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector) const override; + uint64_t m_previouslyTxPpduUid; //!< UID of the previously sent PPDU, used by AP to recognize response HE TB PPDUs uint64_t m_currentHeTbPpduUid; //!< UID of the HE TB PPDU being received diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index a313ba69a..f00efe5f9 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -193,6 +193,12 @@ PhyEntity::CalculatePhyPreambleAndHeaderDuration (const WifiTxVector& txVector) return duration; } +WifiConstPsduMap +PhyEntity::GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector) const +{ + return WifiConstPsduMap ({std::make_pair (SU_STA_ID, psdu)}); +} + Ptr PhyEntity::GetAddressedPsduInPpdu (Ptr ppdu) const { diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 7b6c81f19..8261044a3 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -275,6 +275,17 @@ public: bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const = 0; + /** + * Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU. + * The STA-ID value is properly determined based on whether the given PSDU has + * to be transmitted as a DL or UL frame. + * + * \param psdu the given PSDU + * \param txVector the TXVECTOR to use to send the PSDU + * \return a WifiConstPsduMap built from the given PSDU and the given TXVECTOR + */ + virtual WifiConstPsduMap GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector) const; + /** * Get the maximum PSDU size in bytes. * diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index dfb21db4a..53562c0a2 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1619,6 +1619,12 @@ WifiPhy::CalculateTxDuration (uint32_t size, const WifiTxVector& txVector, WifiP return duration; } +Time +WifiPhy::CalculateTxDuration (Ptr psdu, const WifiTxVector& txVector, WifiPhyBand band) +{ + return CalculateTxDuration (GetWifiConstPsduMap (psdu, txVector), txVector, band); +} + Time WifiPhy::CalculateTxDuration (WifiConstPsduMap psduMap, const WifiTxVector& txVector, WifiPhyBand band) { @@ -1756,13 +1762,17 @@ WifiPhy::NotifyMonitorSniffTx (Ptr psdu, uint16_t channelFreqMhz } } +WifiConstPsduMap +WifiPhy::GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector) +{ + return GetStaticPhyEntity (txVector.GetModulationClass ())->GetWifiConstPsduMap (psdu, txVector); +} + void WifiPhy::Send (Ptr psdu, const WifiTxVector& txVector) { NS_LOG_FUNCTION (this << *psdu << txVector); - WifiConstPsduMap psdus; - psdus.insert (std::make_pair (SU_STA_ID, psdu)); - Send (psdus, txVector); + Send (GetWifiConstPsduMap (psdu, txVector), txVector); } void diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 8b0df560b..74443eb5c 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -121,7 +121,23 @@ public: void EndReceiveInterBss (void); /** - * \param psdu the PSDU to send + * Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU. + * The STA-ID value is properly determined based on whether the given PSDU has + * to be transmitted as a DL or UL frame. + * + * \param psdu the given PSDU + * \param txVector the TXVECTOR to use to send the PSDU + * \return a WifiConstPsduMap built from the given PSDU and the given TXVECTOR + */ + static WifiConstPsduMap GetWifiConstPsduMap (Ptr psdu, const WifiTxVector& txVector); + + /** + * This function is a wrapper for the Send variant that accepts a WifiConstPsduMap + * as first argument. This function inserts the given PSDU in a WifiConstPsduMap + * along with a STA-ID value that is determined based on whether the given PSDU has + * to be transmitted as a DL or UL frame. + * + * \param psdu the PSDU to send (in a SU PPDU) * \param txVector the TXVECTOR that has TX parameters such as mode, the transmission mode to use to send * 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 @@ -217,6 +233,21 @@ public: */ static Time CalculateTxDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, uint16_t staId = SU_STA_ID); + /** + * This function is a wrapper for the CalculateTxDuration variant that accepts a + * WifiConstPsduMap as first argument. This function inserts the given PSDU in a + * WifiConstPsduMap along with a STA-ID value that is determined based on whether + * the given PSDU has to be transmitted as a DL or UL frame, thus allowing to + * properly calculate the TX duration in case the PSDU has to be transmitted as + * an UL frame. + * + * \param psdu the PSDU to transmit + * \param txVector the TXVECTOR used for the transmission of the PSDU + * \param band the frequency band + * + * \return the total amount of time this PHY will stay busy for the transmission of the PPDU + */ + static Time CalculateTxDuration (Ptr psdu, const WifiTxVector& txVector, WifiPhyBand band); /** * \param psduMap the PSDU(s) to transmit indexed by STA-ID * \param txVector the TXVECTOR used for the transmission of the PPDU