From dec1f2ca2423a3bdcf0dca2aec7b7da3834a26e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 24 Jan 2023 22:40:06 +0100 Subject: [PATCH] wifi: Pass information about the spectrum PHY interface to SpectrumWifiPhy::StartRx --- src/wifi/model/spectrum-wifi-phy.cc | 17 +++++++++++------ src/wifi/model/spectrum-wifi-phy.h | 4 +++- src/wifi/model/wifi-spectrum-phy-interface.cc | 2 +- src/wifi/test/spectrum-wifi-phy-test.cc | 7 ++++--- src/wifi/test/wifi-phy-ofdma-test.cc | 5 +++-- src/wifi/test/wifi-phy-reception-test.cc | 7 ++++--- src/wifi/test/wifi-phy-thresholds-test.cc | 5 +++-- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 8eb0a16b5..23e5f71f0 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -303,9 +303,14 @@ SpectrumWifiPhy::CanStartRx(Ptr ppdu, uint16_t txWidth) const } void -SpectrumWifiPhy::StartRx(Ptr rxParams) +SpectrumWifiPhy::StartRx(Ptr rxParams, + Ptr interface) { - NS_LOG_FUNCTION(this << rxParams); + NS_ASSERT(!interface || + interface == m_currentSpectrumPhyInterface); // TODO: Add support for receiving from + // multiple RF interfaces + const auto range = GetCurrentFrequencyRange(); + NS_LOG_FUNCTION(this << rxParams << interface << range); Time rxDuration = rxParams->duration; Ptr receivedSignalPsd = rxParams->psd; NS_LOG_DEBUG("Received signal with PSD " << *receivedSignalPsd << " and duration " @@ -407,14 +412,14 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) if (!wifiRxParams) { NS_LOG_INFO("Received non Wi-Fi signal"); - m_interference->AddForeignSignal(rxDuration, rxPowerW, GetCurrentFrequencyRange()); + m_interference->AddForeignSignal(rxDuration, rxPowerW, range); SwitchMaybeToCcaBusy(nullptr); return; } if (wifiRxParams && m_disableWifiReception) { NS_LOG_INFO("Received Wi-Fi signal but blocked from syncing"); - m_interference->AddForeignSignal(rxDuration, rxPowerW, GetCurrentFrequencyRange()); + m_interference->AddForeignSignal(rxDuration, rxPowerW, range); SwitchMaybeToCcaBusy(nullptr); return; } @@ -427,7 +432,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) if (totalRxPowerW < DbmToW(GetRxSensitivity()) * (txWidth / 20.0)) { NS_LOG_INFO("Received signal too weak to process: " << WToDbm(totalRxPowerW) << " dBm"); - m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, GetCurrentFrequencyRange()); + m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, range); SwitchMaybeToCcaBusy(nullptr); return; } @@ -437,7 +442,7 @@ SpectrumWifiPhy::StartRx(Ptr rxParams) if (!CanStartRx(ppdu, txWidth)) { NS_LOG_INFO("Cannot start reception of the PPDU, consider it as interference"); - m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, GetCurrentFrequencyRange()); + m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, range); SwitchMaybeToCcaBusy(ppdu); return; } diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 596620f1e..57fbaec11 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -91,8 +91,10 @@ class SpectrumWifiPhy : public WifiPhy * and low-level PHY interface to this SpectrumWifiPhy instance. * * \param rxParams Input signal parameters + * \param interface the Spectrum PHY interface for which the signal has been detected */ - void StartRx(Ptr rxParams); + void StartRx(Ptr rxParams, + Ptr interface); /** * \param antenna an AntennaModel to include in the transmitted diff --git a/src/wifi/model/wifi-spectrum-phy-interface.cc b/src/wifi/model/wifi-spectrum-phy-interface.cc index 6637b5612..aba29e605 100644 --- a/src/wifi/model/wifi-spectrum-phy-interface.cc +++ b/src/wifi/model/wifi-spectrum-phy-interface.cc @@ -150,7 +150,7 @@ WifiSpectrumPhyInterface::GetChannelWidth() const void WifiSpectrumPhyInterface::StartRx(Ptr params) { - m_spectrumWifiPhy->StartRx(params); + m_spectrumWifiPhy->StartRx(params, this); } void diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index 350454b50..d6879dfa3 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -15,6 +15,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "ns3/boolean.h" #include "ns3/constant-position-mobility-model.h" #include "ns3/he-phy.h" //includes OFDM PHY #include "ns3/interference-helper.h" @@ -190,7 +191,7 @@ SpectrumWifiPhyBasicTest::MakeSignal(double txPowerWatts, const WifiPhyOperating void SpectrumWifiPhyBasicTest::SendSignal(double txPowerWatts) { - m_phy->StartRx(MakeSignal(txPowerWatts, m_phy->GetOperatingChannel())); + m_phy->StartRx(MakeSignal(txPowerWatts, m_phy->GetOperatingChannel()), nullptr); } void @@ -1002,6 +1003,7 @@ SpectrumWifiPhyMultipleInterfacesTest::DoSetup() auto txNode = CreateObject(); auto txDev = CreateObject(); auto txPhy = CreateObject(); + txPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); auto txInterferenceHelper = CreateObject(); txPhy->SetInterferenceHelper(txInterferenceHelper); auto txError = CreateObject(); @@ -1018,13 +1020,13 @@ SpectrumWifiPhyMultipleInterfacesTest::DoSetup() txPhy->ConfigureStandard(WIFI_STANDARD_80211ax); txDev->SetPhy(txPhy); txNode->AddDevice(txDev); - txPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); m_txPhys.push_back(txPhy); auto rxNode = CreateObject(); auto rxDev = CreateObject(); auto rxPhy = CreateObject(); + rxPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); auto rxInterferenceHelper = CreateObject(); rxPhy->SetInterferenceHelper(rxInterferenceHelper); auto rxError = CreateObject(); @@ -1041,7 +1043,6 @@ SpectrumWifiPhyMultipleInterfacesTest::DoSetup() rxPhy->ConfigureStandard(WIFI_STANDARD_80211ax); rxDev->SetPhy(rxPhy); rxNode->AddDevice(rxDev); - rxPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); const auto index = m_rxPhys.size(); rxPhy->SetReceiveOkCallback( diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 27388b16a..47434f1fe 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -46,6 +46,7 @@ #include "ns3/wifi-net-device.h" #include "ns3/wifi-phy-listener.h" #include "ns3/wifi-psdu.h" +#include "ns3/wifi-spectrum-phy-interface.h" #include "ns3/wifi-spectrum-signal-parameters.h" #include "ns3/wifi-spectrum-value-helper.h" #include "ns3/wifi-utils.h" @@ -2454,7 +2455,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, auto hePhy = DynamicCast(m_phy->GetLatestPhyEntity()); hePhy->SetTrigVector(m_trigVector, ppduDuration); ppdu->ResetTxVector(); - m_phy->StartRx(rxParams); + m_phy->StartRx(rxParams, nullptr); // Schedule OFDMA part Ptr ppduOfdma = DynamicCast(ppdu->Copy()); // since flag will be modified @@ -2490,7 +2491,7 @@ TestMultipleHeTbPreambles::DoRxHeTbPpduOfdmaPart(PtrStartRx(rxParamsOfdma); + m_phy->StartRx(rxParamsOfdma, nullptr); } void diff --git a/src/wifi/test/wifi-phy-reception-test.cc b/src/wifi/test/wifi-phy-reception-test.cc index a4ef99bef..b2227f5fd 100644 --- a/src/wifi/test/wifi-phy-reception-test.cc +++ b/src/wifi/test/wifi-phy-reception-test.cc @@ -45,6 +45,7 @@ #include "ns3/wifi-mpdu.h" #include "ns3/wifi-net-device.h" #include "ns3/wifi-psdu.h" +#include "ns3/wifi-spectrum-phy-interface.h" #include "ns3/wifi-spectrum-signal-parameters.h" #include "ns3/wifi-spectrum-value-helper.h" #include "ns3/wifi-utils.h" @@ -144,7 +145,7 @@ WifiPhyReceptionTest::SendPacket(double rxPowerDbm, uint32_t packetSize, uint8_t txParams->ppdu = ppdu; txParams->txWidth = CHANNEL_WIDTH; - m_phy->StartRx(txParams); + m_phy->StartRx(txParams, nullptr); } void @@ -2804,7 +2805,7 @@ TestAmpduReception::SendAmpduWithThreeMpdus(double rxPowerDbm, uint32_t referenc txParams->ppdu = ppdu; txParams->txWidth = CHANNEL_WIDTH; - m_phy->StartRx(txParams); + m_phy->StartRx(txParams, nullptr); } void @@ -4327,7 +4328,7 @@ TestUnsupportedBandwidthReception::SendPpdu(uint16_t centerFreqMhz, uint16_t ban txParams->ppdu = ppdu; txParams->txWidth = bandwidthMhz; - m_rxPhy->StartRx(txParams); + m_rxPhy->StartRx(txParams, nullptr); } void diff --git a/src/wifi/test/wifi-phy-thresholds-test.cc b/src/wifi/test/wifi-phy-thresholds-test.cc index 205099028..db1fd63bf 100644 --- a/src/wifi/test/wifi-phy-thresholds-test.cc +++ b/src/wifi/test/wifi-phy-thresholds-test.cc @@ -30,6 +30,7 @@ #include "ns3/wifi-mac-header.h" #include "ns3/wifi-net-device.h" #include "ns3/wifi-psdu.h" +#include "ns3/wifi-spectrum-phy-interface.h" #include "ns3/wifi-spectrum-signal-parameters.h" #include "ns3/wifi-spectrum-value-helper.h" #include "ns3/wifi-utils.h" @@ -202,11 +203,11 @@ WifiPhyThresholdsTest::SendSignal(double txPowerWatts, bool wifiSignal) { if (wifiSignal) { - m_phy->StartRx(MakeWifiSignal(txPowerWatts, m_phy->GetOperatingChannel())); + m_phy->StartRx(MakeWifiSignal(txPowerWatts, m_phy->GetOperatingChannel()), nullptr); } else { - m_phy->StartRx(MakeForeignSignal(txPowerWatts)); + m_phy->StartRx(MakeForeignSignal(txPowerWatts), nullptr); } }