From 0b4ebba006d16da82113fb143540cef829d043e4 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 18 Dec 2023 17:21:16 +0100 Subject: [PATCH] wifi: Generate in-device interference during transmissions on EMLSR links ...if the corresponding attribute is set to true --- .../model/eht/eht-frame-exchange-manager.cc | 60 +++++++++++++++++++ .../model/eht/eht-frame-exchange-manager.h | 10 ++++ src/wifi/model/eht/emlsr-manager.cc | 23 ++++++- src/wifi/model/eht/emlsr-manager.h | 18 ++++++ 4 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index 0dfedb77c..cae79a416 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -26,9 +26,11 @@ #include "ns3/ap-wifi-mac.h" #include "ns3/log.h" #include "ns3/mgt-action-headers.h" +#include "ns3/spectrum-signal-parameters.h" #include "ns3/sta-wifi-mac.h" #include "ns3/wifi-mac-queue.h" #include "ns3/wifi-net-device.h" +#include "ns3/wifi-spectrum-phy-interface.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT WIFI_FEM_NS_LOG_APPEND_CONTEXT @@ -448,6 +450,21 @@ EhtFrameExchangeManager::ForwardPsduDown(Ptr psdu, WifiTxVector& } } } + else if (m_staMac && m_staMac->IsEmlsrLink(m_linkId) && + m_staMac->GetEmlsrManager()->GetInDeviceInterference()) + { + for (const auto linkId : m_staMac->GetLinkIds()) + { + if (auto phy = m_mac->GetWifiPhy(linkId); + phy && linkId != m_linkId && m_staMac->IsEmlsrLink(linkId)) + { + auto txPowerDbm = phy->GetPowerDbm(txVector.GetTxPowerLevel()) + phy->GetTxGain(); + // generate in-device interference on the other EMLSR link for the duration of this + // transmission + GenerateInDeviceInterference(linkId, txDuration, DbmToW(txPowerDbm)); + } + } + } } void @@ -483,6 +500,49 @@ EhtFrameExchangeManager::ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVect } } } + else if (m_staMac && m_staMac->IsEmlsrLink(m_linkId) && + m_staMac->GetEmlsrManager()->GetInDeviceInterference()) + { + for (const auto linkId : m_staMac->GetLinkIds()) + { + if (auto phy = m_mac->GetWifiPhy(linkId); + phy && linkId != m_linkId && m_staMac->IsEmlsrLink(linkId)) + { + auto txPowerDbm = phy->GetPowerDbm(txVector.GetTxPowerLevel()) + phy->GetTxGain(); + // generate in-device interference on the other EMLSR link for the duration of this + // transmission + GenerateInDeviceInterference(linkId, txDuration, DbmToW(txPowerDbm)); + } + } + } +} + +void +EhtFrameExchangeManager::GenerateInDeviceInterference(uint8_t linkId, Time duration, double txPower) +{ + NS_LOG_FUNCTION(this << linkId << duration.As(Time::US) << txPower); + + auto rxPhy = DynamicCast(m_mac->GetWifiPhy(linkId)); + + if (!rxPhy) + { + NS_LOG_DEBUG("No spectrum PHY operating on link " << +linkId); + return; + } + + auto txPhy = DynamicCast(m_phy); + NS_ASSERT(txPhy); + + auto psd = Create(rxPhy->GetCurrentInterface()->GetRxSpectrumModel()); + *psd = txPower; + + auto spectrumSignalParams = Create(); + spectrumSignalParams->duration = duration; + spectrumSignalParams->txPhy = txPhy->GetCurrentInterface(); + spectrumSignalParams->txAntenna = txPhy->GetAntenna(); + spectrumSignalParams->psd = psd; + + rxPhy->StartRx(spectrumSignalParams, rxPhy->GetCurrentInterface()); } void diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.h b/src/wifi/model/eht/eht-frame-exchange-manager.h index c7befdd21..2c349d43c 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.h +++ b/src/wifi/model/eht/eht-frame-exchange-manager.h @@ -146,6 +146,16 @@ class EhtFrameExchangeManager : public HeFrameExchangeManager */ bool CheckEmlsrClientStartingTxop(const WifiMacHeader& hdr, const WifiTxVector& txVector); + /** + * Generate an in-device interference of the given power on the given link for the given + * duration. + * + * \param linkId the ID of the link on which in-device interference is generated + * \param duration the duration of the in-device interference + * \param txPower the TX power in Watts + */ + void GenerateInDeviceInterference(uint8_t linkId, Time duration, double txPower); + /** * Update the TXOP end timer when starting a frame transmission. * diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 4b5a378fe..b9e4c8c1e 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -104,6 +104,14 @@ EmlsrManager::GetTypeId() MakeBooleanAccessor(&EmlsrManager::SetAuxPhyTxCapable, &EmlsrManager::GetAuxPhyTxCapable), MakeBooleanChecker()) + .AddAttribute("InDeviceInterference", + "Whether in-device interference is such that a PHY cannot decode " + "anything and cannot decrease the backoff counter when another PHY " + "of the same device is transmitting.", + BooleanValue(false), + MakeBooleanAccessor(&EmlsrManager::SetInDeviceInterference, + &EmlsrManager::GetInDeviceInterference), + MakeBooleanChecker()) .AddAttribute( "EmlsrLinkSet", "IDs of the links on which EMLSR mode will be enabled. An empty set " @@ -209,6 +217,18 @@ EmlsrManager::GetAuxPhyTxCapable() const return m_auxPhyTxCapable; } +void +EmlsrManager::SetInDeviceInterference(bool enable) +{ + m_inDeviceInterference = enable; +} + +bool +EmlsrManager::GetInDeviceInterference() const +{ + return m_inDeviceInterference; +} + const std::set& EmlsrManager::GetEmlsrLinks() const { @@ -366,7 +386,6 @@ EmlsrManager::NotifyIcfReceived(uint8_t linkId) if (id != linkId && m_staMac->IsEmlsrLink(id)) { m_staMac->BlockTxOnLink(id, WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK); - m_staMac->GetChannelAccessManager(id)->NotifyStartUsingOtherEmlsrLink(); } } @@ -410,7 +429,6 @@ EmlsrManager::NotifyUlTxopStart(uint8_t linkId, std::optional