From eaeb0987200326fcb9e6ccaf9cd0963cc0ef57b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 18 Feb 2023 10:52:30 +0100 Subject: [PATCH] wifi: Use WifiSpectrumBandInfo and get rid of bands offset calculation --- src/wifi/model/he/he-phy.cc | 36 ++++---- src/wifi/model/he/he-phy.h | 13 ++- src/wifi/model/ht/ht-phy.cc | 4 +- src/wifi/model/interference-helper.cc | 110 ++++++++---------------- src/wifi/model/interference-helper.h | 56 ++++++------ src/wifi/model/phy-entity.cc | 27 +++--- src/wifi/model/phy-entity.h | 6 +- src/wifi/model/spectrum-wifi-phy.cc | 71 +++++---------- src/wifi/model/spectrum-wifi-phy.h | 4 +- src/wifi/model/vht/vht-phy.cc | 4 +- src/wifi/model/yans-wifi-channel.cc | 2 +- src/wifi/model/yans-wifi-phy.cc | 2 +- src/wifi/test/spectrum-wifi-phy-test.cc | 10 +-- src/wifi/test/wifi-phy-ofdma-test.cc | 46 +++++----- 14 files changed, 163 insertions(+), 228 deletions(-) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index fd927ca84..452ec16e8 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -975,7 +975,7 @@ HePhy::StartReceiveOfdmaPayload(Ptr event) NotifyPayloadBegin(ppdu->GetTxVector(), payloadDuration); } -std::pair +std::pair HePhy::GetChannelWidthAndBand(const WifiTxVector& txVector, uint16_t staId) const { if (txVector.IsMu()) @@ -989,7 +989,7 @@ HePhy::GetChannelWidthAndBand(const WifiTxVector& txVector, uint16_t staId) cons } } -WifiSpectrumBandIndices +WifiSpectrumBandInfo HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const { NS_ASSERT(txVector.IsMu()); @@ -1004,14 +1004,16 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const std::make_pair(group.front().first, group.back().second); // for a TX spectrum, the guard bandwidth is a function of the transmission channel width // and the spectrum width equals the transmission channel width (hence bandIndex equals 0) - return ConvertHeRuSubcarriers(channelWidth, - GetGuardBandwidth(channelWidth), - m_wifiPhy->GetSubcarrierSpacing(), - subcarrierRange, - 0); + auto indices = ConvertHeRuSubcarriers(channelWidth, + GetGuardBandwidth(channelWidth), + m_wifiPhy->GetSubcarrierSpacing(), + subcarrierRange, + 0); + auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices); + return {indices, frequencies}; } -WifiSpectrumBandIndices +WifiSpectrumBandInfo HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const { NS_ASSERT(txVector.IsMu()); @@ -1026,15 +1028,17 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const std::make_pair(group.front().first, group.back().second); // for an RX spectrum, the guard bandwidth is a function of the operating channel width // and the spectrum width equals the operating channel width - return ConvertHeRuSubcarriers( + auto indices = ConvertHeRuSubcarriers( channelWidth, GetGuardBandwidth(m_wifiPhy->GetChannelWidth()), m_wifiPhy->GetSubcarrierSpacing(), subcarrierRange, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth)); + auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices); + return {indices, frequencies}; } -WifiSpectrumBandIndices +WifiSpectrumBandInfo HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const { NS_ASSERT(txVector.IsUlMu() && (txVector.GetModulationClass() >= WIFI_MOD_CLASS_HE)); @@ -1055,12 +1059,14 @@ HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20))); HeRu::SubcarrierRange subcarrierRange = std::make_pair(groupPreamble.front().first, groupPreamble.back().second); - return ConvertHeRuSubcarriers( + auto indices = ConvertHeRuSubcarriers( channelWidth, GetGuardBandwidth(m_wifiPhy->GetChannelWidth()), m_wifiPhy->GetSubcarrierSpacing(), subcarrierRange, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth)); + auto frequencies = m_wifiPhy->ConvertIndicesToFrequencies(indices); + return {indices, frequencies}; } uint16_t @@ -1206,7 +1212,7 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) * busy while the threshold continues to be exceeded. */ double ccaThresholdDbm = -62; - Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, band.indices); + Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, band); if (ppdu) { @@ -1266,7 +1272,7 @@ HePhy::GetPer20MHzDurations(const Ptr ppdu) NS_ASSERT_MSG(false, "Invalid channel width: " << ppduBw); } } - Time ppduCcaDuration = GetDelayUntilCcaEnd(ccaThresholdDbm, band.indices); + Time ppduCcaDuration = GetDelayUntilCcaEnd(ccaThresholdDbm, band); delayUntilCcaEnd = std::max(delayUntilCcaEnd, ppduCcaDuration); } per20MhzDurations.push_back(delayUntilCcaEnd); @@ -1365,7 +1371,7 @@ HePhy::GetTxPowerSpectralDensity(double txPowerW, } else { - const auto band = GetRuBandForTx(txVector, GetStaId(ppdu)); + const auto band = GetRuBandForTx(txVector, GetStaId(ppdu)).indices; return WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity( centerFrequency, channelWidth, @@ -1906,7 +1912,7 @@ HePhy::GetRuBands(Ptr phy, uint16_t channelWidth, uint16_t guardB (!primary80IsLower80 && phyIndex > nRus / 2)); HeRu::RuSpec ru(ruType, index, primary80); NS_ABORT_IF(ru.GetPhyIndex(bw, p20Index) != phyIndex); - ruBands.insert({band.indices, ru}); + ruBands.insert({band, ru}); } } } diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 49c0118d3..513f832ab 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -172,7 +172,7 @@ class HePhy : public VhtPhy * * \return the RU band in the TX spectrum */ - WifiSpectrumBandIndices GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const; + WifiSpectrumBandInfo GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const; /** * Get the band in the RX spectrum associated with the RU used by the PSDU * transmitted to/by a given STA in a DL MU PPDU/HE TB PPDU @@ -182,7 +182,7 @@ class HePhy : public VhtPhy * * \return the RU band in the RX spectrum */ - WifiSpectrumBandIndices GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const; + WifiSpectrumBandInfo GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const; /** * Get the band used to transmit the non-OFDMA part of an HE TB PPDU. * @@ -191,7 +191,7 @@ class HePhy : public VhtPhy * * \return the spectrum band used to transmit the non-OFDMA part of an HE TB PPDU */ - WifiSpectrumBandIndices GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const; + WifiSpectrumBandInfo GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const; /** * Get the width in MHz of the non-OFDMA portion of an HE TB PPDU * @@ -452,7 +452,7 @@ class HePhy : public VhtPhy uint8_t bandIndex = 0); /// Map a spectrum band associated with an RU to the RU specification - using RuBands = std::map; + using RuBands = std::map; /** * Static function to compute the RU bands that belong to a given channel width. @@ -473,9 +473,8 @@ class HePhy : public VhtPhy Ptr DoGetEvent(Ptr ppdu, RxPowerWattPerChannelBand& rxPowersW) override; bool IsConfigSupported(Ptr ppdu) const override; Time DoStartReceivePayload(Ptr event) override; - std::pair GetChannelWidthAndBand( - const WifiTxVector& txVector, - uint16_t staId) const override; + std::pair GetChannelWidthAndBand(const WifiTxVector& txVector, + uint16_t staId) const override; void RxPayloadSucceeded(Ptr psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index 9a04836f1..dfa742544 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -827,7 +827,7 @@ HtPhy::GetCcaIndication(const Ptr ppdu) return PhyEntity::GetCcaIndication(ppdu); } double ccaThresholdDbm = GetCcaThreshold(ppdu, WIFI_CHANLIST_PRIMARY); - Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(20).indices); + Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(20)); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair( @@ -863,7 +863,7 @@ HtPhy::GetCcaIndication(const Ptr ppdu) if (!ppdu || ppdu->DoesOverlapChannel(s20MinFreq, s20MaxFreq)) { ccaThresholdDbm = GetCcaThreshold(ppdu, WIFI_CHANLIST_SECONDARY); - delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetSecondaryBand(20).indices); + delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetSecondaryBand(20)); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair(delayUntilCcaEnd, WIFI_CHANLIST_SECONDARY); diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index fad130d02..62dc153a4 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -99,7 +99,7 @@ Event::GetRxPowerW() const } double -Event::GetRxPowerW(const WifiSpectrumBandIndices& band) const +Event::GetRxPowerW(const WifiSpectrumBandInfo& band) const { const auto it = m_rxPowerW.find(band); NS_ASSERT(it != m_rxPowerW.cend()); @@ -254,37 +254,24 @@ InterferenceHelper::AddForeignSignal(Time duration, Add(fakePpdu, WifiTxVector(), duration, rxPowerW, freqRange); } -void -InterferenceHelper::RemoveBands(FrequencyRange freqRange) +bool +InterferenceHelper::HasBands(const FrequencyRange& freqRange) const { NS_LOG_FUNCTION(this << freqRange); - if ((m_niChanges.count(freqRange) == 0) && (m_firstPowers.count(freqRange) == 0)) - { - return; - } - auto niChangesPerBand = m_niChanges.at(freqRange); - for (auto it : niChangesPerBand) - { - it.second.clear(); - } - niChangesPerBand.clear(); - m_niChanges.erase(freqRange); - m_firstPowers.at(freqRange).clear(); - m_firstPowers.erase(freqRange); + return (m_niChanges.count(freqRange) > 0); } bool -InterferenceHelper::HasBand(const WifiSpectrumBandIndices& band, - const FrequencyRange& freqRange) const +InterferenceHelper::HasBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const { - NS_LOG_FUNCTION(this << band.first << band.second << freqRange); + NS_LOG_FUNCTION(this << band << freqRange); return (m_niChanges.count(freqRange) > 0 && m_niChanges.at(freqRange).count(band) > 0); } void -InterferenceHelper::AddBand(const WifiSpectrumBandIndices& band, const FrequencyRange& freqRange) +InterferenceHelper::AddBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) { - NS_LOG_FUNCTION(this << band.first << band.second << freqRange); + NS_LOG_FUNCTION(this << band << freqRange); NS_ASSERT(m_niChanges.count(freqRange) == 0 || m_niChanges.at(freqRange).count(band) == 0); NS_ASSERT(m_firstPowers.count(freqRange) == 0 || m_firstPowers.at(freqRange).count(band) == 0); NiChanges niChanges; @@ -296,59 +283,33 @@ InterferenceHelper::AddBand(const WifiSpectrumBandIndices& band, const Frequency } void -InterferenceHelper::UpdateBands(const std::vector& bands, - const FrequencyRange& freqRange, - int32_t offset) +InterferenceHelper::UpdateBands(const std::vector& bands, + const FrequencyRange& freqRange) { - NS_LOG_FUNCTION(this << freqRange << offset); + NS_LOG_FUNCTION(this << freqRange); NS_ABORT_IF(m_niChanges.count(freqRange) == 0); auto& niChangesPerBand = m_niChanges.at(freqRange); auto& firstPowerPerBand = m_firstPowers.at(freqRange); - // start index of the lowest band - const auto minStartIndex = - (std::min_element(bands.cbegin(), bands.cend(), [](const auto& lhs, const auto& rhs) { - return lhs.first < rhs.first; - }))->first; - // stop index of the highest band - const auto maxStopIndex = - (std::max_element(bands.cbegin(), bands.cend(), [](const auto& lhs, const auto& rhs) { - return lhs.second < rhs.second; - }))->second; - // index of DC so that it can be skipped - const auto dcIndex = - static_cast(minStartIndex + ((maxStopIndex - minStartIndex) / 2) + 0.5); NiChangesPerBand newNiChangesPerBand{}; FirstPowerPerBand newFirstPowerPerBand{}; for (auto it = niChangesPerBand.begin(); it != niChangesPerBand.end();) { - // apply offset to start index and stop index to get the corresponding ones in the new - // spectrum model - auto newBandStartIndex = - static_cast(static_cast(it->first.first) + offset); - auto newBandStopIndex = - static_cast(static_cast(it->first.second) + offset); - const auto erase = std::find_if(bands.cbegin(), - bands.cend(), - [newBandStartIndex, newBandStopIndex](const auto& item) { - return ((newBandStartIndex == item.first) && - (newBandStopIndex == item.second)); - }) == std::end(bands); - if (erase) + const auto frequencies = it->first.frequencies; + const auto itEqual = + std::find_if(bands.cbegin(), bands.cend(), [frequencies](const auto& item) { + return frequencies == item.frequencies; + }); + if (itEqual == std::end(bands)) { // band does not belong to the new bands, erase it it->second.clear(); } else { - if (newBandStartIndex >= dcIndex) - { - // skip DC - newBandStartIndex++; - } - const auto band = std::make_pair(newBandStartIndex, newBandStopIndex); - newNiChangesPerBand.insert({band, std::move(it->second)}); - newFirstPowerPerBand.insert({band, firstPowerPerBand.at(it->first)}); + newNiChangesPerBand.insert({*itEqual, std::move(it->second)}); + newFirstPowerPerBand.insert({*itEqual, firstPowerPerBand.at(it->first)}); } + firstPowerPerBand.erase(it->first); it = niChangesPerBand.erase(it); } niChangesPerBand.swap(newNiChangesPerBand); @@ -389,10 +350,10 @@ InterferenceHelper::SetNumberOfReceiveAntennas(uint8_t rx) Time InterferenceHelper::GetEnergyDuration(double energyW, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) { - NS_LOG_FUNCTION(this << energyW << band.first << band.second << freqRange); + NS_LOG_FUNCTION(this << energyW << band << freqRange); Time now = Simulator::Now(); NS_ABORT_IF(m_niChanges.count(freqRange) == 0); auto niIt = m_niChanges.at(freqRange).find(band); @@ -508,10 +469,10 @@ InterferenceHelper::CalculateSnr(double signal, double InterferenceHelper::CalculateNoiseInterferenceW(Ptr event, NiChangesPerBand* nis, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const { - NS_LOG_FUNCTION(this << band.first << band.second << freqRange); + NS_LOG_FUNCTION(this << band << freqRange); NS_ABORT_IF(m_firstPowers.count(freqRange) == 0); auto firstPower_it = m_firstPowers.at(freqRange).find(band); NS_ABORT_IF(firstPower_it == m_firstPowers.at(freqRange).end()); @@ -590,13 +551,12 @@ double InterferenceHelper::CalculatePayloadPer(Ptr event, uint16_t channelWidth, NiChangesPerBand* nis, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, uint16_t staId, std::pair window) const { - NS_LOG_FUNCTION(this << channelWidth << band.first << band.second << staId << window.first - << window.second); + NS_LOG_FUNCTION(this << channelWidth << band << staId << window.first << window.second); double psr = 1.0; /* Packet Success Rate */ const auto& niIt = nis->find(band)->second; auto j = niIt.cbegin(); @@ -664,11 +624,11 @@ InterferenceHelper::CalculatePhyHeaderSectionPsr( Ptr event, NiChangesPerBand* nis, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, PhyEntity::PhyHeaderSections phyHeaderSections) const { - NS_LOG_FUNCTION(this << band.first << band.second << freqRange); + NS_LOG_FUNCTION(this << band << freqRange); double psr = 1.0; /* Packet Success Rate */ auto niIt = nis->find(band)->second; auto j = niIt.begin(); @@ -729,11 +689,11 @@ double InterferenceHelper::CalculatePhyHeaderPer(Ptr event, NiChangesPerBand* nis, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, WifiPpduField header) const { - NS_LOG_FUNCTION(this << band.first << band.second << freqRange << header); + NS_LOG_FUNCTION(this << band << freqRange << header); auto niIt = nis->find(band)->second; auto phyEntity = WifiPhy::GetStaticPhyEntity(event->GetTxVector().GetModulationClass()); @@ -758,12 +718,12 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr event, PhyEntity::SnrPer InterferenceHelper::CalculatePayloadSnrPer(Ptr event, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, uint16_t staId, std::pair relativeMpduStartStop) const { - NS_LOG_FUNCTION(this << channelWidth << band.first << band.second << freqRange << staId + NS_LOG_FUNCTION(this << channelWidth << band << freqRange << staId << relativeMpduStartStop.first << relativeMpduStartStop.second); NiChangesPerBand ni; double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange); @@ -790,7 +750,7 @@ double InterferenceHelper::CalculateSnr(Ptr event, uint16_t channelWidth, uint8_t nss, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const { NiChangesPerBand ni; @@ -802,11 +762,11 @@ InterferenceHelper::CalculateSnr(Ptr event, PhyEntity::SnrPer InterferenceHelper::CalculatePhyHeaderSnrPer(Ptr event, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, WifiPpduField header) const { - NS_LOG_FUNCTION(this << band.first << band.second << header); + NS_LOG_FUNCTION(this << band << header); NiChangesPerBand ni; double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange); double snr = CalculateSnr(event->GetRxPowerW(band), noiseInterferenceW, channelWidth, 1); diff --git a/src/wifi/model/interference-helper.h b/src/wifi/model/interference-helper.h index 4bec8b755..8dfce4d56 100644 --- a/src/wifi/model/interference-helper.h +++ b/src/wifi/model/interference-helper.h @@ -90,7 +90,7 @@ class Event : public SimpleRefCount * \param band the band for which the power should be returned * \return the received power (W) for a given band */ - double GetRxPowerW(const WifiSpectrumBandIndices& band) const; + double GetRxPowerW(const WifiSpectrumBandInfo& band) const; /** * Return the received power (W) for all bands. * @@ -150,34 +150,25 @@ class InterferenceHelper : public Object * \param band the band to be added * \param freqRange the frequency range the band to add belongs to */ - void AddBand(const WifiSpectrumBandIndices& band, const FrequencyRange& freqRange); + void AddBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange); /** - * Remove the frequency bands for a given frequency range. + * Check whether a given frequency range is already tracked by this interference helper. * - * \param freqRange the frequency range the bands to remove belong to + * \param freqRange the frequency range to check + * \return true if bands are tracked by this interference helper for a given frequency range, + * false otherwise */ - void RemoveBands(FrequencyRange freqRange); - - /** - * Check whether a given band is tracked by this interference helper. - * - * \param band the band to be checked - * \param freqRange the frequency range the band to check belongs to - * \return true if the band is already tracked by this interference helper, false otherwise - */ - bool HasBand(const WifiSpectrumBandIndices& band, const FrequencyRange& freqRange) const; + bool HasBands(const FrequencyRange& freqRange) const; /** * Update the frequency bands for a given frequency range when the spectrum model is changed. * * \param bands the bands to be added in the new spectrum model * \param freqRange the frequency range the bands belong to - * \param offset the offset to convert start and stop indices from old to new spectrum model */ - void UpdateBands(const std::vector& bands, - const FrequencyRange& freqRange, - int32_t offset); + void UpdateBands(const std::vector& bands, + const FrequencyRange& freqRange); /** * Set the noise figure. @@ -216,7 +207,7 @@ class InterferenceHelper : public Object * be higher than the requested threshold. */ Time GetEnergyDuration(double energyW, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange); /** @@ -268,7 +259,7 @@ class InterferenceHelper : public Object */ PhyEntity::SnrPer CalculatePayloadSnrPer(Ptr event, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, uint16_t staId, std::pair relativeMpduStartStop) const; @@ -286,7 +277,7 @@ class InterferenceHelper : public Object double CalculateSnr(Ptr event, uint16_t channelWidth, uint8_t nss, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const; /** * Calculate the SNIR at the start of the PHY header and accumulate @@ -302,7 +293,7 @@ class InterferenceHelper : public Object */ PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr event, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, WifiPpduField header) const; @@ -427,7 +418,7 @@ class InterferenceHelper : public Object /** * Map of NiChanges per band */ - using NiChangesPerBand = std::map; + using NiChangesPerBand = std::map; /** * Map of NiChanges per band and per range @@ -437,13 +428,22 @@ class InterferenceHelper : public Object /** * Map of first power per band */ - using FirstPowerPerBand = std::map; + using FirstPowerPerBand = std::map; /** * Map of first power per band and per range */ using FirstPowerPerBandPerRange = std::map; + /** + * Check whether a given band is tracked by this interference helper. + * + * \param band the band to be checked + * \param freqRange the frequency range the band to check belongs to + * \return true if the band is already tracked by this interference helper, false otherwise + */ + bool HasBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const; + /** * Append the given Event. * @@ -466,7 +466,7 @@ class InterferenceHelper : public Object */ double CalculateNoiseInterferenceW(Ptr event, NiChangesPerBand* nis, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const; /** * Calculate the error rate of the given PHY payload only in the provided time @@ -486,7 +486,7 @@ class InterferenceHelper : public Object double CalculatePayloadPer(Ptr event, uint16_t channelWidth, NiChangesPerBand* nis, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, uint16_t staId, std::pair window) const; @@ -506,7 +506,7 @@ class InterferenceHelper : public Object double CalculatePhyHeaderPer(Ptr event, NiChangesPerBand* nis, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, WifiPpduField header) const; /** @@ -524,7 +524,7 @@ class InterferenceHelper : public Object double CalculatePhyHeaderSectionPsr(Ptr event, NiChangesPerBand* nis, uint16_t channelWidth, - const WifiSpectrumBandIndices& band, + const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange, PhyEntity::PhyHeaderSections phyHeaderSections) const; diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index cbd603b81..6ef17a3a1 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -272,7 +272,7 @@ PhyEntity::GetPhyHeaderSnrPer(WifiPpduField field, Ptr event) const return m_wifiPhy->m_interference->CalculatePhyHeaderSnrPer( event, measurementChannelWidth, - GetPrimaryBand(measurementChannelWidth).indices, + GetPrimaryBand(measurementChannelWidth), m_wifiPhy->GetCurrentFrequencyRange(), field); } @@ -401,11 +401,10 @@ PhyEntity::StartReceivePreamble(Ptr ppdu, Time rxDuration) { // The total RX power corresponds to the maximum over all the bands - auto it = std::max_element( - rxPowersW.begin(), - rxPowersW.end(), - [](const std::pair& p1, - const std::pair& p2) { return p1.second < p2.second; }); + auto it = + std::max_element(rxPowersW.begin(), rxPowersW.end(), [](const auto& p1, const auto& p2) { + return p1.second < p2.second; + }); NS_LOG_FUNCTION(this << ppdu << it->second); auto event = DoGetEvent(ppdu, rxPowersW); @@ -826,11 +825,11 @@ PhyEntity::GetReceptionStatus(Ptr psdu, } } -std::pair +std::pair PhyEntity::GetChannelWidthAndBand(const WifiTxVector& txVector, uint16_t /* staId */) const { uint16_t channelWidth = GetRxChannelWidth(txVector); - return std::make_pair(channelWidth, GetPrimaryBand(channelWidth).indices); + return std::make_pair(channelWidth, GetPrimaryBand(channelWidth)); } const std::map, Ptr>& @@ -965,7 +964,7 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr event) NS_ASSERT(!m_wifiPhy->m_currentPreambleEvents.empty()); for (auto preambleEvent : m_wifiPhy->m_currentPreambleEvents) { - double rxPowerW = preambleEvent.second->GetRxPowerW(measurementBand.indices); + double rxPowerW = preambleEvent.second->GetRxPowerW(measurementBand); if (rxPowerW > maxRxPowerW) { maxRxPowerW = rxPowerW; @@ -998,14 +997,14 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr event) double snr = m_wifiPhy->m_interference->CalculateSnr(m_wifiPhy->m_currentEvent, measurementChannelWidth, 1, - measurementBand.indices, + measurementBand, m_wifiPhy->GetCurrentFrequencyRange()); NS_LOG_DEBUG("SNR(dB)=" << RatioToDb(snr) << " at end of preamble detection period"); if ((!m_wifiPhy->m_preambleDetectionModel && maxRxPowerW > 0.0) || (m_wifiPhy->m_preambleDetectionModel && m_wifiPhy->m_preambleDetectionModel->IsPreambleDetected( - m_wifiPhy->m_currentEvent->GetRxPowerW(measurementBand.indices), + m_wifiPhy->m_currentEvent->GetRxPowerW(measurementBand), snr, measurementChannelWidth))) { @@ -1193,7 +1192,7 @@ PhyEntity::GetRandomValue() const double PhyEntity::GetRxPowerWForPpdu(Ptr event) const { - return event->GetRxPowerW(GetPrimaryBand(GetMeasurementChannelWidth(event->GetPpdu())).indices); + return event->GetRxPowerW(GetPrimaryBand(GetMeasurementChannelWidth(event->GetPpdu()))); } Ptr @@ -1235,7 +1234,7 @@ PhyEntity::GetCcaThreshold(const Ptr ppdu, } Time -PhyEntity::GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandIndices& band) +PhyEntity::GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandInfo& band) { return m_wifiPhy->m_interference->GetEnergyDuration(DbmToW(thresholdDbm), band, @@ -1272,7 +1271,7 @@ PhyEntity::GetCcaIndication(const Ptr ppdu) NS_LOG_FUNCTION(this << channelWidth); const double ccaThresholdDbm = GetCcaThreshold(ppdu, WIFI_CHANLIST_PRIMARY); const Time delayUntilCcaEnd = - GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(channelWidth).indices); + GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(channelWidth)); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair(delayUntilCcaEnd, WIFI_CHANLIST_PRIMARY); diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 44d71bb58..fbd798599 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -75,7 +75,7 @@ struct RxSignalInfo /** * A map of the received power (Watts) for each band */ -typedef std::map RxPowerWattPerChannelBand; +using RxPowerWattPerChannelBand = std::map; class WifiPsdu; class WifiPhy; @@ -775,7 +775,7 @@ class PhyEntity : public SimpleRefCount * \param staId the station ID of the PSDU * \return a pair of channel width (MHz) and band */ - virtual std::pair GetChannelWidthAndBand( + virtual std::pair GetChannelWidthAndBand( const WifiTxVector& txVector, uint16_t staId) const; @@ -939,7 +939,7 @@ class PhyEntity : public SimpleRefCount * \param band identify the requested band * \return the delay until CCA busy is ended */ - Time GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandIndices& band); + Time GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandInfo& band); /** * \param currentChannelWidth channel width of the current transmission (MHz) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 6b88de2e3..637cffd11 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -122,16 +122,15 @@ SpectrumWifiPhy::DoInitialize() } void -SpectrumWifiPhy::UpdateInterferenceHelperBands(std::optional indicesOffset) +SpectrumWifiPhy::UpdateInterferenceHelperBands() { NS_LOG_FUNCTION(this); NS_ASSERT(!m_spectrumPhyInterfaces.empty()); uint16_t channelWidth = GetChannelWidth(); - std::vector ccaBands{}; - std::vector ruBands{}; + std::vector bands{}; if (channelWidth < 20) { - ccaBands.push_back(GetBand(channelWidth).indices); + bands.push_back(GetBand(channelWidth)); } else { @@ -139,49 +138,30 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands(std::optional indicesOff { for (uint32_t i = 0; i < (channelWidth / bw); ++i) { - ccaBands.push_back(GetBand(bw, i).indices); + bands.push_back(GetBand(bw, i)); } } } if (GetStandard() >= WIFI_STANDARD_80211ax) { - auto&& ruBandsMap = HePhy::GetRuBands(this, channelWidth, GetGuardBandwidth(channelWidth)); - for (const auto& bandRuPair : ruBandsMap) + auto&& ruBands = HePhy::GetRuBands(this, channelWidth, GetGuardBandwidth(channelWidth)); + for (const auto& bandRuPair : ruBands) { - ruBands.push_back(bandRuPair.first); + bands.push_back(bandRuPair.first); } - m_currentSpectrumPhyInterface->SetRuBands(std::move(ruBandsMap)); + m_currentSpectrumPhyInterface->SetRuBands(std::move(ruBands)); } - auto bands{ccaBands}; - bands.insert(bands.end(), ruBands.begin(), ruBands.end()); - const auto bandsChanged = std::any_of(bands.cbegin(), bands.cend(), [&](const auto& band) { - return !m_interference->HasBand(band, GetCurrentFrequencyRange()); - }); - if (!bandsChanged) + + if (m_interference->HasBands(GetCurrentFrequencyRange())) { - return; + m_interference->UpdateBands(bands, GetCurrentFrequencyRange()); } - if (indicesOffset.has_value()) + else { - // indicesOffset is computed for multiple of 20 MHz subchannels, and since RU bands are not - // used for CCA, we can here safely erase RU bands (UpdateBands will erase them since they - // are not passed to the call) - m_interference->UpdateBands(ccaBands, GetCurrentFrequencyRange(), *indicesOffset); - // add new RU bands - if (!ruBands.empty()) + for (const auto& band : bands) { - for (const auto& band : ruBands) - { - NS_ASSERT(!m_interference->HasBand(band, GetCurrentFrequencyRange())); - m_interference->AddBand(band, GetCurrentFrequencyRange()); - } + m_interference->AddBand(band, GetCurrentFrequencyRange()); } - return; - } - m_interference->RemoveBands(GetCurrentFrequencyRange()); - for (const auto& band : bands) - { - m_interference->AddBand(band, GetCurrentFrequencyRange()); } } @@ -226,14 +206,6 @@ SpectrumWifiPhy::ResetSpectrumModel() { NS_LOG_FUNCTION(this); - std::optional indicesOffset{}; - if (m_currentSpectrumPhyInterface->GetCenterFrequency() > 0) - { - indicesOffset = - (2e6 * (GetFrequency() - m_currentSpectrumPhyInterface->GetCenterFrequency())) / - GetSubcarrierSpacing(); - } - // Replace existing spectrum model with new one const auto channelWidth = GetChannelWidth(); m_currentSpectrumPhyInterface->SetRxSpectrumModel(GetFrequency(), @@ -243,7 +215,7 @@ SpectrumWifiPhy::ResetSpectrumModel() m_currentSpectrumPhyInterface->GetChannel()->AddRx(m_currentSpectrumPhyInterface); - UpdateInterferenceHelperBands(indicesOffset); + UpdateInterferenceHelperBands(); } void @@ -339,7 +311,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, NS_LOG_DEBUG("Signal power received (watts) before antenna gain: " << rxPowerPerBandW); rxPowerPerBandW *= DbToRatio(GetRxGain()); totalRxPowerW += rxPowerPerBandW; - rxPowerW.insert({filteredBand.indices, rxPowerPerBandW}); + rxPowerW.insert({filteredBand, rxPowerPerBandW}); NS_LOG_DEBUG("Signal power received after antenna gain for " << channelWidth << " MHz channel: " << rxPowerPerBandW << " W (" << WToDbm(rxPowerPerBandW) << " dBm)"); @@ -359,7 +331,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, { totalRxPowerW += rxPowerPerBandW; } - rxPowerW.insert({filteredBand.indices, rxPowerPerBandW}); + rxPowerW.insert({filteredBand, rxPowerPerBandW}); NS_LOG_DEBUG("Signal power received after antenna gain for " << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm(rxPowerPerBandW) << " dBm)"); @@ -374,15 +346,16 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, for (const auto& [band, ru] : ruBands) { double rxPowerPerBandW = - WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, band); + WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, band.indices); NS_LOG_DEBUG("Signal power received (watts) before antenna gain for RU with type " << ru.GetRuType() << " and index " << ru.GetIndex() << " -> (" - << band.first << "; " << band.second << "): " << rxPowerPerBandW); + << band.indices.first << "; " << band.indices.second + << "): " << rxPowerPerBandW); rxPowerPerBandW *= DbToRatio(GetRxGain()); NS_LOG_DEBUG("Signal power received after antenna gain for RU with type " << ru.GetRuType() << " and index " << ru.GetIndex() << " -> (" - << band.first << "; " << band.second << "): " << rxPowerPerBandW << " W (" - << WToDbm(rxPowerPerBandW) << " dBm)"); + << band.indices.first << "; " << band.indices.second << "): " + << rxPowerPerBandW << " W (" << WToDbm(rxPowerPerBandW) << " dBm)"); rxPowerW.insert({band, rxPowerPerBandW}); } } diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 9140d795e..c7a444ccd 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -195,10 +195,8 @@ class SpectrumWifiPhy : public WifiPhy /** * This function is called to update the bands handled by the InterferenceHelper. - * \param indicesOffset the offset to convert start and stop indices from old to new spectrum - * model, if bands are already handled by the InterferenceHelper */ - void UpdateInterferenceHelperBands(std::optional indicesOffset); + void UpdateInterferenceHelperBands(); /** * Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index d92628c71..4edba093b 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -591,7 +591,7 @@ VhtPhy::GetCcaIndication(const Ptr ppdu) } double ccaThresholdDbm = GetCcaThreshold(ppdu, WIFI_CHANLIST_PRIMARY); - Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(20).indices); + Time delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetPrimaryBand(20)); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair( @@ -653,7 +653,7 @@ VhtPhy::GetCcaIndication(const Ptr ppdu) { auto channelType = secondaryChannels.at(secondaryWidth); ccaThresholdDbm = GetCcaThreshold(ppdu, channelType); - delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetSecondaryBand(secondaryWidth).indices); + delayUntilCcaEnd = GetDelayUntilCcaEnd(ccaThresholdDbm, GetSecondaryBand(secondaryWidth)); if (delayUntilCcaEnd.IsStrictlyPositive()) { return std::make_pair(delayUntilCcaEnd, channelType); diff --git a/src/wifi/model/yans-wifi-channel.cc b/src/wifi/model/yans-wifi-channel.cc index f9f402a97..7e66c9c4f 100644 --- a/src/wifi/model/yans-wifi-channel.cc +++ b/src/wifi/model/yans-wifi-channel.cc @@ -145,7 +145,7 @@ YansWifiChannel::Receive(Ptr phy, Ptr ppdu, double } RxPowerWattPerChannelBand rxPowerW; rxPowerW.insert( - {std::make_pair(0, 0), (DbmToW(rxPowerDbm + phy->GetRxGain()))}); // dummy band for YANS + {{{0, 0}, {0, 0}}, (DbmToW(rxPowerDbm + phy->GetRxGain()))}); // dummy band for YANS phy->StartReceivePreamble(ppdu, rxPowerW, ppdu->GetTxDuration()); } diff --git a/src/wifi/model/yans-wifi-phy.cc b/src/wifi/model/yans-wifi-phy.cc index 2e56c92dc..634fd084f 100644 --- a/src/wifi/model/yans-wifi-phy.cc +++ b/src/wifi/model/yans-wifi-phy.cc @@ -53,7 +53,7 @@ YansWifiPhy::SetInterferenceHelper(const Ptr helper) { WifiPhy::SetInterferenceHelper(helper); // add dummy band for Yans - m_interference->AddBand({0, 0}, GetCurrentFrequencyRange()); + m_interference->AddBand({{0, 0}, {0, 0}}, GetCurrentFrequencyRange()); } YansWifiPhy::~YansWifiPhy() diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index 08b537bf4..d1e387d26 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -520,8 +520,8 @@ SpectrumWifiPhyFilterTest::RxCallback(Ptr p, RxPowerWattPerChannel { for (const auto& pair : rxPowersW) { - NS_LOG_INFO("band: (" << pair.first.first << ";" << pair.first.second << ") -> powerW=" - << pair.second << " (" << WToDbm(pair.second) << " dBm)"); + NS_LOG_INFO("band: (" << pair.first << ") -> powerW=" << pair.second << " (" + << WToDbm(pair.second) << " dBm)"); } size_t numBands = rxPowersW.size(); @@ -537,7 +537,7 @@ SpectrumWifiPhyFilterTest::RxCallback(Ptr p, RxPowerWattPerChannel uint16_t channelWidth = std::min(m_txChannelWidth, m_rxChannelWidth); auto band = m_rxPhy->GetBand(channelWidth, 0); - auto it = rxPowersW.find(band.indices); + auto it = rxPowersW.find(band); NS_LOG_INFO("powerW total band: " << it->second << " (" << WToDbm(it->second) << " dBm)"); int totalRxPower = static_cast(WToDbm(it->second) + 0.5); int expectedTotalRxPower; @@ -560,7 +560,7 @@ SpectrumWifiPhyFilterTest::RxCallback(Ptr p, RxPowerWattPerChannel if ((m_txChannelWidth <= m_rxChannelWidth) && (channelWidth >= 20)) { band = m_rxPhy->GetBand(20, 0); // primary 20 MHz - it = rxPowersW.find(band.indices); + it = rxPowersW.find(band); NS_LOG_INFO("powerW in primary 20 MHz channel: " << it->second << " (" << WToDbm(it->second) << " dBm)"); int rxPowerPrimaryChannel20 = static_cast(WToDbm(it->second) + 0.5); @@ -1016,7 +1016,7 @@ SpectrumWifiPhyMultipleInterfacesTest::DoCheckInterferences(Ptr(ptr.Get()); NS_ASSERT(interferenceHelper); const auto band = phy->GetBandForInterface(channelWidth, 0, freqRange, channelWidth); - const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band.indices, freqRange); + const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band, freqRange); NS_TEST_ASSERT_MSG_EQ(energyDuration.IsStrictlyPositive(), interferencesExpected, "Incorrect interferences detection"); diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 17d3d472b..9263fde66 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -192,7 +192,7 @@ class OfdmaSpectrumWifiPhy : public SpectrumWifiPhy * energy on the medium for a given band will * be higher than the requested threshold. */ - Time GetEnergyDuration(double energyW, WifiSpectrumBandIndices band); + Time GetEnergyDuration(double energyW, WifiSpectrumBandInfo band); /** * \return a const pointer to the HE PHY instance @@ -278,7 +278,7 @@ OfdmaSpectrumWifiPhy::GetCurrentEvent() } Time -OfdmaSpectrumWifiPhy::GetEnergyDuration(double energyW, WifiSpectrumBandIndices band) +OfdmaSpectrumWifiPhy::GetEnergyDuration(double energyW, WifiSpectrumBandInfo band) { return m_interference->GetEnergyDuration(energyW, band, WHOLE_WIFI_SPECTRUM); } @@ -2466,7 +2466,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, DEFAULT_CHANNEL_WIDTH, txPowerWatts, DEFAULT_GUARD_WIDTH, - band); + band.indices); Ptr rxParamsOfdma = Create(); rxParamsOfdma->psd = rxPsd; rxParamsOfdma->txPhy = nullptr; @@ -3056,7 +3056,7 @@ class TestUlOfdmaPhyTransmission : public TestCase * \param expectedRxPower the expected received power in W */ void CheckNonOfdmaRxPower(Ptr phy, - WifiSpectrumBandIndices band, + WifiSpectrumBandInfo band, double expectedRxPower); /** * Check the received power for the OFDMA part of the HE TB PPDUs over the given band @@ -3065,7 +3065,7 @@ class TestUlOfdmaPhyTransmission : public TestCase * \param expectedRxPower the expected received power in W */ void CheckOfdmaRxPower(Ptr phy, - WifiSpectrumBandIndices band, + WifiSpectrumBandInfo band, double expectedRxPower); /** @@ -3534,25 +3534,25 @@ TestUlOfdmaPhyTransmission::CheckRxFromSta2(uint32_t expectedSuccess, void TestUlOfdmaPhyTransmission::CheckNonOfdmaRxPower(Ptr phy, - WifiSpectrumBandIndices band, + WifiSpectrumBandInfo band, double expectedRxPower) { Ptr event = phy->GetCurrentEvent(); NS_ASSERT(event); - double rxPower = event->GetRxPowerW(band); - NS_LOG_FUNCTION(this << band.first << band.second << expectedRxPower << rxPower); + auto rxPower = event->GetRxPowerW(band); + NS_LOG_FUNCTION(this << band << expectedRxPower << rxPower); // Since there is out of band emission due to spectrum mask, the tolerance cannot be very low NS_TEST_ASSERT_MSG_EQ_TOL(rxPower, expectedRxPower, 5e-3, - "RX power " << rxPower << " over (" << band.first << ", " - << band.second << ") does not match expected power " - << expectedRxPower << " at " << Simulator::Now()); + "RX power " << rxPower << " over (" << band + << ") does not match expected power " << expectedRxPower + << " at " << Simulator::Now()); } void TestUlOfdmaPhyTransmission::CheckOfdmaRxPower(Ptr phy, - WifiSpectrumBandIndices band, + WifiSpectrumBandInfo band, double expectedRxPower) { /** @@ -3560,28 +3560,28 @@ TestUlOfdmaPhyTransmission::CheckOfdmaRxPower(Ptr phy, * We will have to check if the expected power is indeed the max power returning a positive * duration when calling GetEnergyDuration. */ - NS_LOG_FUNCTION(this << band.first << band.second << expectedRxPower); + NS_LOG_FUNCTION(this << band << expectedRxPower); double step = 5e-3; if (expectedRxPower > 0.0) { NS_TEST_ASSERT_MSG_EQ( phy->GetEnergyDuration(expectedRxPower - step, band).IsStrictlyPositive(), true, - "At least " << expectedRxPower << " W expected for OFDMA part over (" << band.first - << ", " << band.second << ") at " << Simulator::Now()); + "At least " << expectedRxPower << " W expected for OFDMA part over (" << band << ") at " + << Simulator::Now()); NS_TEST_ASSERT_MSG_EQ( phy->GetEnergyDuration(expectedRxPower + step, band).IsStrictlyPositive(), false, - "At most " << expectedRxPower << " W expected for OFDMA part over (" << band.first - << ", " << band.second << ") at " << Simulator::Now()); + "At most " << expectedRxPower << " W expected for OFDMA part over (" << band << ") at " + << Simulator::Now()); } else { NS_TEST_ASSERT_MSG_EQ( phy->GetEnergyDuration(expectedRxPower + step, band).IsStrictlyPositive(), false, - "At most " << expectedRxPower << " W expected for OFDMA part over (" << band.first - << ", " << band.second << ") at " << Simulator::Now()); + "At most " << expectedRxPower << " W expected for OFDMA part over (" << band << ") at " + << Simulator::Now()); } } @@ -3986,11 +3986,11 @@ TestUlOfdmaPhyTransmission::SchedulePowerMeasurementChecks(Time delay, NS_ASSERT(nonOfdmaDuration == hePhy->CalculateNonOfdmaDurationForHeTb(txVectorSta1)); std::vector rxPowerNonOfdma{rxPowerNonOfdmaRu1, rxPowerNonOfdmaRu2}; - std::vector nonOfdmaBand{hePhy->GetNonOfdmaBand(txVectorSta1, 1), - hePhy->GetNonOfdmaBand(txVectorSta2, 2)}; + std::vector nonOfdmaBand{hePhy->GetNonOfdmaBand(txVectorSta1, 1), + hePhy->GetNonOfdmaBand(txVectorSta2, 2)}; std::vector rxPowerOfdma{rxPowerOfdmaRu1, rxPowerOfdmaRu2}; - std::vector ofdmaBand{hePhy->GetRuBandForRx(txVectorSta1, 1), - hePhy->GetRuBandForRx(txVectorSta2, 2)}; + std::vector ofdmaBand{hePhy->GetRuBandForRx(txVectorSta1, 1), + hePhy->GetRuBandForRx(txVectorSta2, 2)}; for (uint8_t i = 0; i < 2; ++i) {