diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 24e2721422..60657b450d 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -1324,9 +1324,18 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, HePpdu::TxPsdFlag flag) const { const auto& txVector = ppdu->GetTxVector(); - uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); + const auto& centerFrequencies = ppdu->GetTxCenterFreqs(); auto channelWidth = txVector.GetChannelWidth(); - NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW << txVector); + auto printFrequencies = [](const std::vector& v) { + std::stringstream ss; + for (const auto& centerFrequency : v) + { + ss << centerFrequency << " "; + } + return ss.str(); + }; + NS_LOG_FUNCTION(this << printFrequencies(centerFrequencies) << channelWidth << txPowerW + << txVector); const auto& puncturedSubchannels = txVector.GetInactiveSubchannels(); if (!puncturedSubchannels.empty()) { @@ -1345,11 +1354,10 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, { // non-HE portion is sent only on the 20 MHz channels covering the RU const uint16_t staId = GetStaId(ppdu); - centerFrequency = GetCenterFrequencyForNonHePart(txVector, staId); const auto ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType()); channelWidth = (ruWidth < 20) ? 20 : ruWidth; return WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( - centerFrequency, + GetCenterFrequenciesForNonHePart(ppdu, staId).front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -1362,7 +1370,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, { const auto band = GetRuBandForTx(txVector, GetStaId(ppdu)).indices; return WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -1373,7 +1381,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, if (flag == HePpdu::PSD_NON_HE_PORTION) { return WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -1385,7 +1393,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, else { return WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -1399,7 +1407,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, default: { NS_ASSERT(puncturedSubchannels.empty()); return WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -1410,12 +1418,13 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, } } -uint16_t -HePhy::GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t staId) const +std::vector +HePhy::GetCenterFrequenciesForNonHePart(Ptr ppdu, uint16_t staId) const { - NS_LOG_FUNCTION(this << txVector << staId); + NS_LOG_FUNCTION(this << ppdu << staId); + const auto& txVector = ppdu->GetTxVector(); NS_ASSERT(txVector.IsUlMu() && (txVector.GetModulationClass() >= WIFI_MOD_CLASS_HE)); - uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); + auto centerFrequencies = ppdu->GetTxCenterFreqs(); const auto currentWidth = txVector.GetChannelWidth(); HeRu::RuSpec ru = txVector.GetRu(staId); @@ -1426,8 +1435,8 @@ HePhy::GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t sta HeRu::RuSpec nonOfdmaRu = HeRu::FindOverlappingRu(currentWidth, ru, HeRu::GetRuType(nonOfdmaWidth)); - uint16_t startingFrequency = centerFrequency - (currentWidth / 2); - centerFrequency = + uint16_t startingFrequency = centerFrequencies.front() - (currentWidth / 2); + centerFrequencies.front() = startingFrequency + nonOfdmaWidth * (nonOfdmaRu.GetPhyIndex( currentWidth, @@ -1435,7 +1444,7 @@ HePhy::GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t sta 1) + nonOfdmaWidth / 2; } - return centerFrequency; + return centerFrequencies; } void diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 8dac6b9c4b..1fb8cba770 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -216,15 +216,15 @@ class HePhy : public VhtPhy void SetTrigVector(const WifiTxVector& trigVector, Time validity); /** - * Get the center frequency of the non-HE portion of the current TxVector for the - * given STA-ID. - * Note this method is only to be used for UL MU. + * Get the center frequency per segment of the non-HE portion of the current PPDU for the given + * STA-ID. Note this method is only to be used for UL MU. * - * \param txVector the TXVECTOR that has the RU allocation + * \param ppdu the PPDU * \param staId the STA-ID of the station taking part of the UL MU * \return the center frequency in MHz corresponding to the non-HE portion of the HE TB PPDU */ - uint16_t GetCenterFrequencyForNonHePart(const WifiTxVector& txVector, uint16_t staId) const; + std::vector GetCenterFrequenciesForNonHePart(const Ptr ppdu, + uint16_t staId) const; /** * Sets the OBSS-PD algorithm. diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index d1494c6bac..2ed70a768a 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -462,13 +462,14 @@ HtPhy::IsConfigSupported(Ptr ppdu) const Ptr HtPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& centerFrequencies = ppdu->GetTxCenterFreqs(); + NS_ASSERT(centerFrequencies.size() == 1); const auto& txVector = ppdu->GetTxVector(); - uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); const auto channelWidth = txVector.GetChannelWidth(); - NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); + NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW); const auto& txMaskRejectionParams = GetTxMaskRejectionParams(); Ptr v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index 49d70fef77..48b79d6c02 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -269,13 +269,14 @@ DsssPhy::GetMeasurementChannelWidth(const Ptr ppdu) const Ptr DsssPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& centerFrequencies = ppdu->GetTxCenterFreqs(); + NS_ASSERT(centerFrequencies.size() == 1); const auto& txVector = ppdu->GetTxVector(); - uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); const auto channelWidth = txVector.GetChannelWidth(); - NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); + NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW); NS_ABORT_MSG_IF(channelWidth != 22, "Invalid channel width for DSSS"); Ptr v = - WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(centerFrequency, + WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(centerFrequencies.front(), txPowerW, GetGuardBandwidth(channelWidth)); return v; diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index c3a7686ff0..5a58ccc3a2 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -367,16 +367,17 @@ OfdmPhy::IsAllConfigSupported(WifiPpduField /* field */, Ptr ppd Ptr OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const { + const auto& centerFrequencies = ppdu->GetTxCenterFreqs(); + NS_ASSERT(centerFrequencies.size() == 1); const auto& txVector = ppdu->GetTxVector(); - uint16_t centerFrequency = GetCenterFrequencyForChannelWidth(txVector); const auto channelWidth = txVector.GetChannelWidth(); - NS_LOG_FUNCTION(this << centerFrequency << channelWidth << txPowerW); + NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPowerW); const auto& txMaskRejectionParams = GetTxMaskRejectionParams(); Ptr v; if (txVector.IsNonHtDuplicate()) { v = WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), @@ -386,8 +387,9 @@ OfdmPhy::GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) co } else { + NS_ASSERT(centerFrequencies.size() == 1); v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity( - centerFrequency, + centerFrequencies.front(), channelWidth, txPowerW, GetGuardBandwidth(channelWidth), diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 2a9224a2ab..593be14ef0 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1301,15 +1301,6 @@ PhyEntity::GetMaxDelayPpduSameUid(const WifiTxVector& /*txVector*/) return Seconds(0); } -uint16_t -PhyEntity::GetCenterFrequencyForChannelWidth(const WifiTxVector& txVector) const -{ - NS_LOG_FUNCTION(this << txVector); - - return m_wifiPhy->GetOperatingChannel().GetPrimaryChannelCenterFrequency( - txVector.GetChannelWidth()); -} - void PhyEntity::NotifyPayloadBegin(const WifiTxVector& txVector, const Time& payloadDuration) { diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index ecae529b11..ea798d18ab 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -857,16 +857,6 @@ class PhyEntity : public SimpleRefCount virtual Ptr GetTxPowerSpectralDensity(double txPowerW, Ptr ppdu) const = 0; - /** - * Get the center frequency of the channel corresponding the current TxVector rather than - * that of the supported channel width. - * Consider that this "primary channel" is on the lower part for the time being. - * - * \param txVector the TXVECTOR that has the channel width that is to be used - * \return the center frequency in MHz corresponding to the channel width to be used - */ - uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector& txVector) const; - /** * Fire the trace indicating that the PHY is starting to receive the payload of a PPDU. * diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 4a4473d983..d402d9c8fa 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -2435,7 +2435,8 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, // Send non-OFDMA part Time nonOfdmaDuration = m_phy->GetHePhy()->CalculateNonHeDurationForHeTb(txVector); - uint32_t centerFrequency = m_phy->GetHePhy()->GetCenterFrequencyForNonHePart(txVector, staId); + uint32_t centerFrequency = + m_phy->GetHePhy()->GetCenterFrequenciesForNonHePart(ppdu, staId).front(); ChannelWidthMhz ruWidth = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType()); ChannelWidthMhz channelWidth = ruWidth < 20 ? 20 : ruWidth; Ptr rxPsd = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(