diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index 24d946751..18096b81f 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -270,7 +270,7 @@ SpectrumWifiPhy::DoChannelSwitch() bool SpectrumWifiPhy::CanStartRx(Ptr ppdu) const { - return GetPhyEntity(GetStandard())->CanStartRx(ppdu); + return GetLatestPhyEntity()->CanStartRx(ppdu); } void diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 9e1a89ea7..b6562108f 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -713,6 +713,12 @@ WifiPhy::GetPhyEntity(WifiStandard standard) const return GetPhyEntity(GetModulationClassForStandard(standard)); } +Ptr +WifiPhy::GetLatestPhyEntity() const +{ + return GetPhyEntity(m_standard); +} + void WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, Ptr phyEntity) { @@ -2029,14 +2035,14 @@ void WifiPhy::SwitchMaybeToCcaBusy(const Ptr ppdu) { NS_LOG_FUNCTION(this); - GetPhyEntity(m_standard)->SwitchMaybeToCcaBusy(ppdu); + GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu); } void WifiPhy::NotifyCcaBusy(const Ptr ppdu, Time duration) { NS_LOG_FUNCTION(this << duration); - GetPhyEntity(m_standard)->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY); + GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY); } void @@ -2139,7 +2145,7 @@ Ptr WifiPhy::GetAddressedPsduInPpdu(Ptr ppdu) const { // TODO: wrapper. See if still needed - return GetPhyEntity(ppdu->GetModulation())->GetAddressedPsduInPpdu(ppdu); + return GetLatestPhyEntity()->GetAddressedPsduInPpdu(ppdu); } WifiSpectrumBand diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 009e2aa7e..52873ee0f 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -1083,6 +1083,12 @@ class WifiPhy : public Object * \return the pointer to the supported PHY entity */ Ptr GetPhyEntity(WifiStandard standard) const; + /** + * Get the latest PHY entity supported by this PHY instance. + * + * \return the latest PHY entity supported by this PHY instance + */ + Ptr GetLatestPhyEntity() const; /** * \return the UID of the previously received PPDU (reset to UINT64_MAX upon transmission) diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 925773c7d..4e46af407 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -285,7 +285,7 @@ OfdmaSpectrumWifiPhy::GetEnergyDuration(double energyW, WifiSpectrumBand band) Ptr OfdmaSpectrumWifiPhy::GetHePhy() const { - return DynamicCast(GetPhyEntity(WIFI_MOD_CLASS_HE)); + return DynamicCast(GetLatestPhyEntity()); } /** @@ -2450,7 +2450,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, HePhy::ConvertHeTbPpduDurationToLSigLength(ppduDuration, txVector, m_phy->GetPhyBand()); txVector.SetLength(length); m_trigVector.SetLength(length); - auto hePhy = DynamicCast(m_phy->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhy = DynamicCast(m_phy->GetLatestPhyEntity()); hePhy->SetTrigVector(m_trigVector, ppduDuration); ppdu->ResetTxVector(); m_phy->StartRx(rxParams); @@ -3383,7 +3383,7 @@ TestUlOfdmaPhyTransmission::SetTrigVector(uint8_t bssColor, TrigVectorInfo error ++length; } txVector.SetLength(length); - auto hePhyAp = DynamicCast(m_phyAp->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhyAp = DynamicCast(m_phyAp->GetLatestPhyEntity()); hePhyAp->SetTrigVector(txVector, m_expectedPpduDuration); } @@ -5241,7 +5241,7 @@ TestPhyPaddingExclusion::SetTrigVector(Time ppduDuration) std::tie(length, ppduDuration) = HePhy::ConvertHeTbPpduDurationToLSigLength(ppduDuration, trigVector, m_phyAp->GetPhyBand()); trigVector.SetLength(length); - auto hePhyAp = DynamicCast(m_phyAp->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhyAp = DynamicCast(m_phyAp->GetLatestPhyEntity()); hePhyAp->SetTrigVector(trigVector, ppduDuration); } diff --git a/src/wifi/test/wifi-primary-channels-test.cc b/src/wifi/test/wifi-primary-channels-test.cc index 2698112e8..eb27d1640 100644 --- a/src/wifi/test/wifi-primary-channels-test.cc +++ b/src/wifi/test/wifi-primary-channels-test.cc @@ -954,7 +954,7 @@ WifiPrimaryChannelsTest::DoSendHeTbPpdu(uint8_t bss, // AP's PHY expects to receive a TRIGVECTOR (just once) trigVector.SetLength(length); - auto apHePhy = StaticCast(apDev->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto apHePhy = StaticCast(apDev->GetPhy()->GetLatestPhyEntity()); apHePhy->SetTrigVector(trigVector, duration); }