diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index ae9e8e773..7cd0bc873 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1040,6 +1040,22 @@ PhyEntity::GetRxChannelWidth (const WifiTxVector& txVector) const return std::min (m_wifiPhy->GetChannelWidth (), txVector.GetChannelWidth ()); } +void +PhyEntity::SwitchMaybeToCcaBusy (uint16_t channelWidth) +{ + NS_LOG_FUNCTION (this << channelWidth); + //We are here because we have received the first bit of a packet and we are + //not going to be able to synchronize on it + //In this model, CCA becomes busy when the aggregation of all signals as + //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold + const Time delayUntilCcaEnd = m_wifiPhy->m_interference->GetEnergyDuration (m_wifiPhy->m_ccaEdThresholdW, m_wifiPhy->GetPrimaryBand (channelWidth)); + if (!delayUntilCcaEnd.IsZero ()) + { + NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S)); + m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); + } +} + uint64_t PhyEntity::ObtainNextUid (const WifiTxVector& /* txVector */) { diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 3ea9552c4..b72b50452 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -440,6 +440,16 @@ public: */ virtual uint16_t GetRxChannelWidth (const WifiTxVector& txVector) const; + /** + * Check if PHY state should move to CCA busy state based on current + * state of interference tracker. In this model, CCA becomes busy when + * the aggregation of all signals as tracked by the InterferenceHelper + * class is higher than the CcaEdThreshold + * + * \param channelWidth the channel width in MHz used for RSSI measurement + */ + virtual void SwitchMaybeToCcaBusy (uint16_t channelWidth); + /** * This function is called by SpectrumWifiPhy to send * the PPDU while performing amendment-specific actions. diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 5446156d8..278c86469 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1888,16 +1888,7 @@ void WifiPhy::SwitchMaybeToCcaBusy (uint16_t channelWidth) { NS_LOG_FUNCTION (this << channelWidth); - //We are here because we have received the first bit of a packet and we are - //not going to be able to synchronize on it - //In this model, CCA becomes busy when the aggregation of all signals as - //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold - Time delayUntilCcaEnd = m_interference->GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth)); - if (!delayUntilCcaEnd.IsZero ()) - { - NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S)); - m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); - } + GetPhyEntity (m_standard)->SwitchMaybeToCcaBusy (channelWidth); } void