diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index b2cc76943..975729d88 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -220,6 +220,22 @@ DsssPhy::EndReceiveHeader (Ptr event) return status; } +uint16_t +DsssPhy::GetRxChannelWidth (const WifiTxVector& txVector) const +{ + if (m_wifiPhy->GetChannelWidth () > 20) + { + /* + * This is a workaround necessary with HE-capable PHYs, + * since their DSSS entity will reuse its RxSpectrumModel. + * Without this hack, SpectrumWifiPhy::GetBand will crash. + * FIXME: see issue #402 for a better solution. + */ + return 20; + } + return PhyEntity::GetRxChannelWidth (txVector); +} + Ptr DsssPhy::GetTxPowerSpectralDensity (double txPowerW, Ptr ppdu) const { diff --git a/src/wifi/model/non-ht/dsss-phy.h b/src/wifi/model/non-ht/dsss-phy.h index 3193ce860..d2b374d83 100644 --- a/src/wifi/model/non-ht/dsss-phy.h +++ b/src/wifi/model/non-ht/dsss-phy.h @@ -157,6 +157,7 @@ public: private: PhyFieldRxStatus DoEndReceiveField (WifiPpduField field, Ptr event) override; Ptr GetTxPowerSpectralDensity (double txPowerW, Ptr ppdu) const override; + uint16_t GetRxChannelWidth (const WifiTxVector& txVector) const override; /** * \param txVector the transmission parameters diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 9991f6216..17ff1473a 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -717,7 +717,7 @@ PhyEntity::GetReceptionStatus (Ptr psdu, Ptr event, uint1 std::pair PhyEntity::GetChannelWidthAndBand (const WifiTxVector& txVector, uint16_t /* staId */) const { - uint16_t channelWidth = std::min (m_wifiPhy->GetChannelWidth (), txVector.GetChannelWidth ()); + uint16_t channelWidth = GetRxChannelWidth (txVector); return std::make_pair (channelWidth, m_wifiPhy->GetPrimaryBand (channelWidth)); } @@ -1008,7 +1008,13 @@ PhyEntity::GetCurrentEvent (void) const uint16_t PhyEntity::GetMeasurementChannelWidth (const Ptr ppdu) const { - return std::min (m_wifiPhy->GetChannelWidth (), ppdu->GetTxVector ().GetChannelWidth ()); + return GetRxChannelWidth (ppdu->GetTxVector ()); +} + +uint16_t +PhyEntity::GetRxChannelWidth (const WifiTxVector& txVector) const +{ + return std::min (m_wifiPhy->GetChannelWidth (), txVector.GetChannelWidth ()); } uint64_t diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 9d530c9f4..617822997 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -432,6 +432,14 @@ public: */ virtual uint16_t GetMeasurementChannelWidth (const Ptr ppdu) const; + /** + * Return the channel width used in the reception spectrum model. + * + * \param txVector the TXVECTOR of the PPDU that is being received + * \return the channel width (in MHz) used for RxSpectrumModel + */ + virtual uint16_t GetRxChannelWidth (const WifiTxVector& txVector) const; + /** * This function is called by SpectrumWifiPhy to send * the PPDU while performing amendment-specific actions. diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 15ea4e0f2..201143cac 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -311,10 +311,10 @@ SpectrumWifiPhy::StartRx (Ptr rxParams) WifiSpectrumBand filteredBand = GetBand (bw, i); Ptr filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand); SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd); - NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for" << bw << " MHz channel band " << +i << ": " << Integral (filteredSignal)); + NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for " << bw << " MHz channel band " << +i << ": " << Integral (filteredSignal)); double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ()); rxPowerW.insert ({filteredBand, rxPowerPerBandW}); - NS_LOG_DEBUG ("Signal power received after antenna gain for" << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)"); + NS_LOG_DEBUG ("Signal power received after antenna gain for " << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)"); } }