From e67f7c13bc28ada03bf46f3feae92e7210744e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 1 Mar 2023 20:16:40 +0100 Subject: [PATCH] wifi: Track signals coming from non-active PHY interfaces but do not process them --- src/wifi/model/spectrum-wifi-phy.cc | 35 ++++++++++++++++++++--------- src/wifi/model/spectrum-wifi-phy.h | 3 +++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 23e5f71f0..ffcf3499d 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -60,6 +60,12 @@ SpectrumWifiPhy::GetTypeId() BooleanValue(false), MakeBooleanAccessor(&SpectrumWifiPhy::m_disableWifiReception), MakeBooleanChecker()) + .AddAttribute( + "TrackSignalsFromInactiveInterfaces", + "Enable or disable tracking signals coming from inactive spectrum PHY interfaces", + BooleanValue(false), + MakeBooleanAccessor(&SpectrumWifiPhy::m_trackSignalsInactiveInterfaces), + MakeBooleanChecker()) .AddAttribute( "TxMaskInnerBandMinimumRejection", "Minimum rejection (dBr) for the inner band of the transmit spectrum mask", @@ -249,6 +255,8 @@ SpectrumWifiPhy::ResetSpectrumModel() GetBandBandwidth(), GetGuardBandwidth(channelWidth)); + m_currentSpectrumPhyInterface->GetChannel()->AddRx(m_currentSpectrumPhyInterface); + UpdateInterferenceHelperBands(); } @@ -278,7 +286,7 @@ SpectrumWifiPhy::DoChannelSwitch() { NS_LOG_DEBUG("Switch to existing RF interface with frequency/width pair of (" << frequencyAfter << ", " << widthAfter << ")"); - if (m_currentSpectrumPhyInterface) + if (m_currentSpectrumPhyInterface && !m_trackSignalsInactiveInterfaces) { m_currentSpectrumPhyInterface->GetChannel()->RemoveRx(m_currentSpectrumPhyInterface); } @@ -293,7 +301,6 @@ SpectrumWifiPhy::DoChannelSwitch() // it again in the entry associated with the new RX spectrum model UID) m_currentSpectrumPhyInterface = newSpectrumPhyInterface; ResetSpectrumModel(); - m_currentSpectrumPhyInterface->GetChannel()->AddRx(m_currentSpectrumPhyInterface); } bool @@ -306,10 +313,7 @@ void SpectrumWifiPhy::StartRx(Ptr rxParams, Ptr interface) { - NS_ASSERT(!interface || - interface == m_currentSpectrumPhyInterface); // TODO: Add support for receiving from - // multiple RF interfaces - const auto range = GetCurrentFrequencyRange(); + const auto range = interface ? interface->GetFrequencyRange() : GetCurrentFrequencyRange(); NS_LOG_FUNCTION(this << rxParams << interface << range); Time rxDuration = rxParams->duration; Ptr receivedSignalPsd = rxParams->psd; @@ -327,13 +331,13 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, // spectral mask representing our filtering allows) to find the // total energy apparent to the "demodulator". // This is done per 20 MHz channel band. - uint16_t channelWidth = GetChannelWidth(); + const auto channelWidth = interface ? interface->GetChannelWidth() : GetChannelWidth(); double totalRxPowerW = 0; RxPowerWattPerChannelBand rxPowerW; if ((channelWidth == 5) || (channelWidth == 10)) { - WifiSpectrumBand filteredBand = GetBand(channelWidth); + WifiSpectrumBand filteredBand = GetBandForInterface(channelWidth, 0, range, channelWidth); double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand); NS_LOG_DEBUG("Signal power received (watts) before antenna gain: " << rxPowerPerBandW); @@ -351,7 +355,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, for (uint32_t i = 0; i < (channelWidth / bw); i++) { NS_ASSERT(channelWidth >= bw); - WifiSpectrumBand filteredBand = GetBand(bw, i); + WifiSpectrumBand filteredBand = GetBandForInterface(bw, i, range, channelWidth); double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand); NS_LOG_DEBUG("Signal power received (watts) before antenna gain for " @@ -366,7 +370,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, for (uint32_t i = 0; i < (channelWidth / 20); i++) { - WifiSpectrumBand filteredBand = GetBand(20, i); + WifiSpectrumBand filteredBand = GetBandForInterface(20, i, range, channelWidth); double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand); NS_LOG_DEBUG("Signal power received (watts) before antenna gain for 20 MHz channel band " @@ -416,6 +420,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, SwitchMaybeToCcaBusy(nullptr); return; } + if (wifiRxParams && m_disableWifiReception) { NS_LOG_INFO("Received Wi-Fi signal but blocked from syncing"); @@ -423,6 +428,16 @@ SpectrumWifiPhy::StartRx(Ptr rxParams, SwitchMaybeToCcaBusy(nullptr); return; } + + if (m_trackSignalsInactiveInterfaces && interface && + (interface != m_currentSpectrumPhyInterface)) + { + NS_LOG_INFO("Received Wi-Fi signal from a non-active PHY interface"); + m_interference->AddForeignSignal(rxDuration, rxPowerW, range); + SwitchMaybeToCcaBusy(nullptr); + return; + } + // Do no further processing if signal is too weak // Current implementation assumes constant RX power over the PPDU duration // Compare received TX power per MHz to normalized RX sensitivity diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 57fbaec11..735d757ea 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -236,6 +236,9 @@ class SpectrumWifiPhy : public WifiPhy m_ruBands; /**< For each channel width, store all the distinct spectrum bands associated with every RU in a channel of that width */ bool m_disableWifiReception; //!< forces this PHY to fail to sync on any signal + bool m_trackSignalsInactiveInterfaces; //!< flag whether signals coming from inactive spectrum + //!< PHY interfaces are tracked + TracedCallback m_signalCb; //!< Signal callback double m_txMaskInnerBandMinimumRejection; //!< The minimum rejection (in dBr) for the inner band