diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 11a25855a..e7f853ca6 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -101,6 +101,7 @@ Bugs fixed - Bug 2660 - TrafficControlHelper::Default should not configure internal queue sizes - Bug 2665 - Ipv4RawSocket can not send packets to broadcast or multicast - Bug 2671 - ArpCache::Entry::SetMacAddress is misspelled +- Bug 2673 - run-time channel switch does not update WiFi spectrum model - Bug 2717 - Fix mask generation for Ipv4RoutingTableEntry::CreateDefaultRoute - Bug 2722 - 802.11g sends DSSS spectrum signals using CreateOfdmTxPowerSpectralDensity - Bug 2741 - IPv4 fragmentation fails when last fragment have to be re-fragmented. diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 49306a6f3..e383fae28 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -125,6 +125,62 @@ SpectrumWifiPhy::SetChannel (const Ptr channel) m_channel = channel; } +void +SpectrumWifiPhy::ResetSpectrumModel (void) +{ + NS_LOG_FUNCTION (this); + NS_ASSERT_MSG (IsInitialized (), "Executing method before run-time"); + NS_LOG_DEBUG ("Run-time change of spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")"); + // Replace existing spectrum model with new one, and must call AddRx () + // on the SpectrumChannel to provide this new spectrum model to it + m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth (), GetBandBandwidth (), GetGuardBandwidth ()); + m_channel->AddRx (m_wifiSpectrumPhyInterface); +} + +void +SpectrumWifiPhy::SetChannelNumber (uint8_t nch) +{ + NS_LOG_FUNCTION (this << (uint16_t) nch); + WifiPhy::SetChannelNumber (nch); + if (IsInitialized ()) + { + ResetSpectrumModel (); + } +} + +void +SpectrumWifiPhy::SetFrequency (uint16_t freq) +{ + NS_LOG_FUNCTION (this << freq); + WifiPhy::SetFrequency (freq); + if (IsInitialized ()) + { + ResetSpectrumModel (); + } +} + +void +SpectrumWifiPhy::SetChannelWidth (uint8_t channelwidth) +{ + NS_LOG_FUNCTION (this << (uint16_t) channelwidth); + WifiPhy::SetChannelWidth (channelwidth); + if (IsInitialized ()) + { + ResetSpectrumModel (); + } +} + +void +SpectrumWifiPhy::ConfigureStandard (WifiPhyStandard standard) +{ + NS_LOG_FUNCTION (this << standard); + WifiPhy::ConfigureStandard (standard); + if (IsInitialized ()) + { + ResetSpectrumModel (); + } +} + void SpectrumWifiPhy::AddOperationalChannel (uint8_t channelNumber) { diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 0e804ebde..03deb9c01 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -160,6 +160,16 @@ public: Ptr GetChannel (void) const; + // The following four methods call to the base WifiPhy class method + // but also generate a new SpectrumModel if called during runtime + + virtual void SetChannelNumber (uint8_t id); + + virtual void SetFrequency (uint16_t freq); + + virtual void SetChannelWidth (uint8_t channelwidth); + + virtual void ConfigureStandard (WifiPhyStandard standard); protected: // Inherited @@ -180,6 +190,11 @@ private: */ Ptr GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const; + /** + * Perform run-time spectrum model change + */ + void ResetSpectrumModel (void); + Ptr m_channel; //!< SpectrumChannel that this SpectrumWifiPhy is connected to std::vector m_operationalChannelList; //!< List of possible channels diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index cfd91eb1d..e36237cc5 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -588,14 +588,14 @@ public: * * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1) * - * where Starting channel frequency is standard-dependent, see SetStandard() + * where Starting channel frequency is standard-dependent, * as defined in (Section 18.3.8.4.2 "Channel numbering"; IEEE Std 802.11-2012). * This method may fail to take action if the Phy model determines that * the channel number cannot be switched for some reason (e.g. sleep state) * * \param id the channel number */ - void SetChannelNumber (uint8_t id); + virtual void SetChannelNumber (uint8_t id); /** * Return current channel number. * @@ -612,7 +612,7 @@ public: * * \param standard the Wi-Fi standard */ - void ConfigureStandard (WifiPhyStandard standard); + virtual void ConfigureStandard (WifiPhyStandard standard); /** * Get the configured Wi-Fi standard @@ -1488,7 +1488,7 @@ public: /** * \param freq the operating center frequency (MHz) on this node. */ - void SetFrequency (uint16_t freq); + virtual void SetFrequency (uint16_t freq); /** * \return the operating center frequency (MHz) */ @@ -1628,7 +1628,7 @@ public: /** * \param channelwidth channel width */ - void SetChannelWidth (uint8_t channelwidth); + virtual void SetChannelWidth (uint8_t channelwidth); /** * \param channelwidth channel width (in MHz) to support */ @@ -1695,7 +1695,6 @@ protected: EventId m_endRxEvent; //!< the end reeive event EventId m_endPlcpRxEvent; //!< the end PLCP receive event - private: /** * \brief post-construction setting of frequency and/or channel number