From a10f0b9ad9353d41de4e6704f9888004e15be95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 7 Aug 2022 13:00:50 +0200 Subject: [PATCH] wifi: Add missing condition to HtPhy::GetCcaIndication to skip CCA sensitivity check if PPDU does not occupy neither primary nor secondary 20 MHz subchannels --- src/wifi/model/ht/ht-phy.cc | 18 +++++++++++++----- src/wifi/model/vht/vht-phy.cc | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index e13f1cb54..cfcd848fc 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -797,7 +797,7 @@ HtPhy::GetCcaIndication (const Ptr ppdu) { return std::make_pair (delayUntilCcaEnd, WIFI_CHANLIST_PRIMARY); //if Primary is busy, ignore CCA for Secondary } - if (ppdu != nullptr) + if (ppdu) { const uint16_t primaryWidth = 20; uint16_t p20MinFreq = @@ -814,11 +814,19 @@ HtPhy::GetCcaIndication (const Ptr ppdu) } } - ccaThresholdDbm = GetCcaThreshold (ppdu, WIFI_CHANLIST_SECONDARY); - delayUntilCcaEnd = GetDelayUntilCcaEnd (ccaThresholdDbm, GetSecondaryBand (20)); - if (delayUntilCcaEnd.IsStrictlyPositive ()) + const uint16_t secondaryWidth = 20; + uint16_t s20MinFreq = + m_wifiPhy->GetOperatingChannel ().GetSecondaryChannelCenterFrequency (secondaryWidth) - (secondaryWidth / 2); + uint16_t s20MaxFreq = + m_wifiPhy->GetOperatingChannel ().GetSecondaryChannelCenterFrequency (secondaryWidth) + (secondaryWidth / 2); + if (!ppdu || ppdu->DoesOverlapChannel (s20MinFreq, s20MaxFreq)) { - return std::make_pair (delayUntilCcaEnd, WIFI_CHANLIST_SECONDARY); + ccaThresholdDbm = GetCcaThreshold (ppdu, WIFI_CHANLIST_SECONDARY); + delayUntilCcaEnd = GetDelayUntilCcaEnd (ccaThresholdDbm, GetSecondaryBand (20)); + if (delayUntilCcaEnd.IsStrictlyPositive ()) + { + return std::make_pair (delayUntilCcaEnd, WIFI_CHANLIST_SECONDARY); + } } return std::nullopt; diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index 5d72747d3..261f313a6 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -532,7 +532,7 @@ VhtPhy::GetMaxPsduSize (void) const double VhtPhy::GetCcaThreshold (const Ptr ppdu, WifiChannelListType channelType) const { - if (ppdu != nullptr) + if (ppdu) { const uint16_t ppduBw = ppdu->GetTxVector ().GetChannelWidth (); switch (channelType) @@ -586,7 +586,7 @@ VhtPhy::GetCcaIndication (const Ptr ppdu) return std::make_pair (delayUntilCcaEnd, WIFI_CHANLIST_PRIMARY); //if Primary is busy, ignore CCA for Secondary } - if (ppdu != nullptr) + if (ppdu) { const uint16_t primaryWidth = 20; uint16_t p20MinFreq = @@ -604,7 +604,7 @@ VhtPhy::GetCcaIndication (const Ptr ppdu) } std::vector secondaryWidthsToCheck; - if (ppdu != nullptr) + if (ppdu) { for (const auto& secondaryChannel : secondaryChannels) {