diff --git a/src/wifi/helper/spectrum-wifi-helper.cc b/src/wifi/helper/spectrum-wifi-helper.cc index f7512339d..da36409cd 100644 --- a/src/wifi/helper/spectrum-wifi-helper.cc +++ b/src/wifi/helper/spectrum-wifi-helper.cc @@ -200,7 +200,8 @@ SpectrumWifiPhyHelper::SpectrumChannelSwitched(Ptr phy) // no interface attached to that channel continue; } - spectrumPhy->ConfigureInterface(phy->GetFrequency(), phy->GetChannelWidth()); + spectrumPhy->ConfigureInterface(phy->GetOperatingChannel().GetFrequencies(), + phy->GetChannelWidth()); } } diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index acd3b2ac2..1b78e854d 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -404,9 +404,14 @@ SpectrumWifiPhy::NotifyChannelSwitched() } void -SpectrumWifiPhy::ConfigureInterface(uint16_t frequency, ChannelWidthMhz width) +SpectrumWifiPhy::ConfigureInterface(const std::vector& frequencies, ChannelWidthMhz width) { - NS_LOG_FUNCTION(this << frequency << width); + std::stringstream ss; + for (const auto& centerFrequency : frequencies) + { + ss << centerFrequency << " "; + } + NS_LOG_FUNCTION(this << ss.str() << width); if (!m_trackSignalsInactiveInterfaces) { @@ -414,25 +419,39 @@ SpectrumWifiPhy::ConfigureInterface(uint16_t frequency, ChannelWidthMhz width) return; } - auto spectrumPhyInterface = GetInterfaceCoveringChannelBand(frequency, width); - - NS_ABORT_MSG_IF(!spectrumPhyInterface, - "No spectrum channel covers frequency range [" - << frequency - (width / 2) << " MHz - " << frequency + (width / 2) - << " MHz]"); + Ptr spectrumPhyInterface; + const auto numSegments = frequencies.size(); + const auto segmentWidth = width / numSegments; + for (std::size_t i = 0; i < numSegments; ++i) + { + auto interfaceCoveringBand = + GetInterfaceCoveringChannelBand(frequencies.at(i), segmentWidth); + NS_ABORT_MSG_IF(!interfaceCoveringBand, + "No spectrum channel covers frequency range [" + << frequencies.at(i) - (segmentWidth / 2) << " MHz - " + << frequencies.at(i) + (segmentWidth / 2) << " MHz]"); + if (!spectrumPhyInterface) + { + spectrumPhyInterface = interfaceCoveringBand; + } + else + { + NS_ABORT_MSG_IF(interfaceCoveringBand != spectrumPhyInterface, + "All segments are not covered by the same spectrum channel"); + } + } NS_ABORT_MSG_IF(spectrumPhyInterface == m_currentSpectrumPhyInterface, "This method should not be called for the current interface"); - if (!spectrumPhyInterface->GetCenterFrequencies().empty() && - (frequency == spectrumPhyInterface->GetCenterFrequencies().front()) && + if ((frequencies == spectrumPhyInterface->GetCenterFrequencies()) && (width == spectrumPhyInterface->GetChannelWidth())) { NS_LOG_DEBUG("Same RF channel as before on that interface, do nothing"); return; } - ResetSpectrumModel(spectrumPhyInterface, {frequency}, width); + ResetSpectrumModel(spectrumPhyInterface, frequencies, width); } bool diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 46919d1e1..bf2b536e6 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -135,16 +135,16 @@ class SpectrumWifiPhy : public WifiPhy Time duration); /** - * Configure a non-active spectrum PHY interface to operate on a given frequency with a given - * width. The function searches for the non-active PHY interface that operates on the frequency - * range corresponding to the spectrum portion specified by the caller. It takes care to - * configure the RX spectrum model of the PHY interface and to update the bands tracked in - * interference helper. + * Configure a non-active spectrum PHY interface to operate on a given frequency (or several + * frequencies for non-contiguous) with a given total width. The function searches for the + * non-active PHY interface that operates on the frequency range corresponding to the spectrum + * portion specified by the caller. It takes care to configure the RX spectrum model of the PHY + * interface and to update the bands tracked in interference helper. * - * \param frequency the center frequency in MHz the PHY interface should use - * \param width the channel width in MHz the PHY interface should use + * \param frequencies the center frequency of each segment in MHz the PHY interface should use + * \param width the total channel width in MHz the PHY interface should use */ - void ConfigureInterface(uint16_t frequency, ChannelWidthMhz width); + void ConfigureInterface(const std::vector& frequencies, ChannelWidthMhz width); /** * This function is sending the signal to the Spectrum channel