From b8bfb853790318e56060e7a85b750076ff7e80af Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 14 Jan 2025 19:00:07 +0100 Subject: [PATCH] wifi: Generate in-device interference on other PHYs rather than other links --- .../model/eht/eht-frame-exchange-manager.cc | 54 ++++++++++--------- .../model/eht/eht-frame-exchange-manager.h | 17 ++++-- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index 882327654..72fc96b6e 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -408,18 +408,7 @@ EhtFrameExchangeManager::ForwardPsduDown(Ptr psdu, WifiTxVector& { NS_ASSERT(m_staMac->GetEmlsrManager()); m_staMac->GetEmlsrManager()->NotifyInDeviceInterferenceStart(m_linkId, txDuration); - - for (const auto linkId : m_staMac->GetLinkIds()) - { - if (auto phy = m_mac->GetWifiPhy(linkId); - phy && linkId != m_linkId && m_staMac->IsEmlsrLink(linkId)) - { - const auto txPower = phy->GetPower(txVector.GetTxPowerLevel()) + phy->GetTxGain(); - // generate in-device interference on the other EMLSR link for the duration of this - // transmission - GenerateInDeviceInterference(linkId, txDuration, DbmToW(txPower)); - } - } + GenerateInDeviceInterferenceForAll(txDuration, txVector); } } @@ -497,31 +486,46 @@ EhtFrameExchangeManager::ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVect { NS_ASSERT(m_staMac->GetEmlsrManager()); m_staMac->GetEmlsrManager()->NotifyInDeviceInterferenceStart(m_linkId, txDuration); + GenerateInDeviceInterferenceForAll(txDuration, txVector); + } +} - for (const auto linkId : m_staMac->GetLinkIds()) +void +EhtFrameExchangeManager::GenerateInDeviceInterferenceForAll(const Time& txDuration, + const WifiTxVector& txVector) +{ + NS_LOG_FUNCTION(this << txDuration.As(Time::MS) << txVector); + + NS_ASSERT(m_staMac); + NS_ASSERT(m_staMac->GetEmlsrManager()); + + for (const auto& phy : m_staMac->GetDevice()->GetPhys()) + { + // generate in-device interference for a PHY provided that: + // - the PHY is not the one the client is using to transmit + // - either the PHY is not operating on any link or it is operating on an EMLSR link + // Interference is generated for the duration of this transmission + if (auto id = m_staMac->GetLinkForPhy(phy); + phy != m_phy && (!id || m_staMac->IsEmlsrLink(*id))) { - if (auto phy = m_mac->GetWifiPhy(linkId); - phy && linkId != m_linkId && m_staMac->IsEmlsrLink(linkId)) - { - const auto txPower = phy->GetPower(txVector.GetTxPowerLevel()) + phy->GetTxGain(); - // generate in-device interference on the other EMLSR link for the duration of this - // transmission - GenerateInDeviceInterference(linkId, txDuration, DbmToW(txPower)); - } + const auto txPower = phy->GetPower(txVector.GetTxPowerLevel()) + phy->GetTxGain(); + GenerateInDeviceInterference(phy, txDuration, DbmToW(txPower)); } } } void -EhtFrameExchangeManager::GenerateInDeviceInterference(uint8_t linkId, Time duration, Watt_u txPower) +EhtFrameExchangeManager::GenerateInDeviceInterference(Ptr phy, + Time duration, + Watt_u txPower) { - NS_LOG_FUNCTION(this << linkId << duration.As(Time::US) << txPower); + NS_LOG_FUNCTION(this << phy << duration.As(Time::US) << txPower); - auto rxPhy = DynamicCast(m_mac->GetWifiPhy(linkId)); + auto rxPhy = DynamicCast(phy); if (!rxPhy) { - NS_LOG_DEBUG("No spectrum PHY operating on link " << +linkId); + NS_LOG_DEBUG("No spectrum PHY"); return; } diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.h b/src/wifi/model/eht/eht-frame-exchange-manager.h index 89c8094c8..a2675f6e2 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.h +++ b/src/wifi/model/eht/eht-frame-exchange-manager.h @@ -266,14 +266,23 @@ class EhtFrameExchangeManager : public HeFrameExchangeManager void SwitchToListeningOrUnblockLinks(const std::set& clients); /** - * Generate an in-device interference of the given power on the given link for the given - * duration. + * Generate an in-device interference of the given power for the given duration for the given + * PHY. * - * @param linkId the ID of the link on which in-device interference is generated + * @param phy the PHY for which in-device interference is generated * @param duration the duration of the in-device interference * @param txPower the TX power */ - void GenerateInDeviceInterference(uint8_t linkId, Time duration, Watt_u txPower); + void GenerateInDeviceInterference(Ptr phy, Time duration, Watt_u txPower); + + /** + * Generate in-device interference caused by a transmission on this link for all the other PHYs + * of this EMLSR client. + * + * @param txDuration the duration of the transmission + * @param txVector the TXVECTOR used to transmit the frame + */ + void GenerateInDeviceInterferenceForAll(const Time& txDuration, const WifiTxVector& txVector); /** * Update the TXOP end timer when starting a frame transmission.