From 38ed82a8ee6e9a0ee382c99ca3846b5d552bf668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 31 Jan 2023 23:02:19 +0100 Subject: [PATCH] wifi: Hold center frequency and channel width of the RX spectrum model in spectrum PHY interface --- src/wifi/model/spectrum-wifi-phy.cc | 10 +++---- src/wifi/model/wifi-spectrum-phy-interface.cc | 30 ++++++++++++++++--- src/wifi/model/wifi-spectrum-phy-interface.h | 28 +++++++++++++++-- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 1f00eee07..390ad1e07 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -244,11 +244,11 @@ SpectrumWifiPhy::ResetSpectrumModel() // Replace existing spectrum model with new one const auto channelWidth = GetChannelWidth(); - m_currentSpectrumPhyInterface->SetRxSpectrumModel( - WifiSpectrumValueHelper::GetSpectrumModel(GetFrequency(), - channelWidth, - GetBandBandwidth(), - GetGuardBandwidth(channelWidth))); + m_currentSpectrumPhyInterface->SetRxSpectrumModel(GetFrequency(), + channelWidth, + GetBandBandwidth(), + GetGuardBandwidth(channelWidth)); + UpdateInterferenceHelperBands(); } diff --git a/src/wifi/model/wifi-spectrum-phy-interface.cc b/src/wifi/model/wifi-spectrum-phy-interface.cc index c38e6659f..6637b5612 100644 --- a/src/wifi/model/wifi-spectrum-phy-interface.cc +++ b/src/wifi/model/wifi-spectrum-phy-interface.cc @@ -41,7 +41,9 @@ WifiSpectrumPhyInterface::GetTypeId() } WifiSpectrumPhyInterface::WifiSpectrumPhyInterface(FrequencyRange range) - : m_range{range} + : m_range{range}, + m_centerFrequency{0}, + m_channelWidth{0} { NS_LOG_FUNCTION(this << range); } @@ -95,10 +97,18 @@ WifiSpectrumPhyInterface::SetChannel(const Ptr c) } void -WifiSpectrumPhyInterface::SetRxSpectrumModel(Ptr rxSpectrumModel) +WifiSpectrumPhyInterface::SetRxSpectrumModel(uint32_t centerFrequency, + uint16_t channelWidth, + uint32_t bandBandwidth, + uint16_t guardBandwidth) { - NS_LOG_FUNCTION(this << rxSpectrumModel); - m_rxSpectrumModel = rxSpectrumModel; + NS_LOG_FUNCTION(this << centerFrequency << channelWidth << bandBandwidth << guardBandwidth); + m_centerFrequency = centerFrequency; + m_channelWidth = channelWidth; + m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel(centerFrequency, + channelWidth, + bandBandwidth, + guardBandwidth); } Ptr @@ -125,6 +135,18 @@ WifiSpectrumPhyInterface::GetFrequencyRange() const return m_range; } +uint16_t +WifiSpectrumPhyInterface::GetCenterFrequency() const +{ + return m_centerFrequency; +} + +uint16_t +WifiSpectrumPhyInterface::GetChannelWidth() const +{ + return m_channelWidth; +} + void WifiSpectrumPhyInterface::StartRx(Ptr params) { diff --git a/src/wifi/model/wifi-spectrum-phy-interface.h b/src/wifi/model/wifi-spectrum-phy-interface.h index 5fd51fe1c..eff2474ba 100644 --- a/src/wifi/model/wifi-spectrum-phy-interface.h +++ b/src/wifi/model/wifi-spectrum-phy-interface.h @@ -83,6 +83,22 @@ class WifiSpectrumPhyInterface : public SpectrumPhy */ const FrequencyRange& GetFrequencyRange() const; + /** + * Get the center frequency in MHz of the the spectrum channel this interface is attached to + * + * \return the center frequency in MHz of the the spectrum channel this interface is attached to + * to + */ + uint16_t GetCenterFrequency() const; + + /** + * Get the channel width in MHz covered by the spectrum channel this interface is attached to + * + * \return the channel width in MHz covered by the spectrum channel this interface is attached + * to to + */ + uint16_t GetChannelWidth() const; + /** * Start transmission over the spectrum channel * @@ -93,9 +109,15 @@ class WifiSpectrumPhyInterface : public SpectrumPhy /** * Set the RX spectrum model * - * \param rxSpectrumModel the RX spectrum model + * \param centerFrequency the center frequency in MHz + * \param channelWidth the channel width in MHz + * \param bandBandwidth the width of each band in Hz + * \param guardBandwidth the width of the guard band in MHz */ - void SetRxSpectrumModel(Ptr rxSpectrumModel); + void SetRxSpectrumModel(uint32_t centerFrequency, + uint16_t channelWidth, + uint32_t bandBandwidth, + uint16_t guardBandwidth); private: void DoDispose() override; @@ -104,6 +126,8 @@ class WifiSpectrumPhyInterface : public SpectrumPhy Ptr m_spectrumWifiPhy; ///< spectrum PHY Ptr m_netDevice; ///< the device Ptr m_channel; ///< spectrum channel + uint16_t m_centerFrequency; ///< center frequency in MHz + uint16_t m_channelWidth; ///< channel width in MHz Ptr m_rxSpectrumModel; ///< receive spectrum model };