From c1dfb42dcfeda904bbb35140af97c0d11863cade Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Wed, 20 Apr 2022 20:56:41 +0200 Subject: [PATCH] wifi: Pass channel type to WifiPhyListener::NotifyCcaBusyStart --- src/wave/model/ocb-wifi-mac.cc | 2 +- src/wifi/model/channel-access-manager.cc | 8 +-- src/wifi/model/channel-access-manager.h | 4 +- src/wifi/model/wifi-phy-listener.h | 7 ++- src/wifi/model/wifi-phy-state-helper.cc | 4 +- src/wifi/model/wifi-phy-state-helper.h | 3 +- src/wifi/model/wifi-radio-energy-model.cc | 4 +- src/wifi/model/wifi-radio-energy-model.h | 65 +------------------- src/wifi/test/channel-access-manager-test.cc | 7 ++- src/wifi/test/spectrum-wifi-phy-test.cc | 4 +- 10 files changed, 25 insertions(+), 83 deletions(-) diff --git a/src/wave/model/ocb-wifi-mac.cc b/src/wave/model/ocb-wifi-mac.cc index 5c1abd80a..0ad6df65f 100644 --- a/src/wave/model/ocb-wifi-mac.cc +++ b/src/wave/model/ocb-wifi-mac.cc @@ -443,7 +443,7 @@ void OcbWifiMac::MakeVirtualBusy (Time duration) { NS_LOG_FUNCTION (this << duration); - m_channelAccessManager->NotifyCcaBusyStartNow (duration); + m_channelAccessManager->NotifyCcaBusyStartNow (duration, WIFI_CHANLIST_PRIMARY); } void diff --git a/src/wifi/model/channel-access-manager.cc b/src/wifi/model/channel-access-manager.cc index f212bd8ca..15036d486 100644 --- a/src/wifi/model/channel-access-manager.cc +++ b/src/wifi/model/channel-access-manager.cc @@ -64,9 +64,9 @@ public: { m_cam->NotifyTxStartNow (duration); } - void NotifyCcaBusyStart (Time duration) + void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) { - m_cam->NotifyCcaBusyStartNow (duration); + m_cam->NotifyCcaBusyStartNow (duration, channelType); } void NotifySwitchingStart (Time duration) { @@ -613,9 +613,9 @@ ChannelAccessManager::NotifyTxStartNow (Time duration) } void -ChannelAccessManager::NotifyCcaBusyStartNow (Time duration) +ChannelAccessManager::NotifyCcaBusyStartNow (Time duration, WifiChannelListType channelType) { - NS_LOG_FUNCTION (this << duration); + NS_LOG_FUNCTION (this << duration << channelType); NS_LOG_DEBUG ("busy start for " << duration); UpdateBackoff (); m_lastBusyStart = Simulator::Now (); diff --git a/src/wifi/model/channel-access-manager.h b/src/wifi/model/channel-access-manager.h index 9efdf3e82..42d2e9aca 100644 --- a/src/wifi/model/channel-access-manager.h +++ b/src/wifi/model/channel-access-manager.h @@ -25,6 +25,7 @@ #include #include "ns3/event-id.h" #include "ns3/nstime.h" +#include "wifi-phy-common.h" namespace ns3 { @@ -152,10 +153,11 @@ public: void NotifyTxStartNow (Time duration); /** * \param duration expected duration of CCA busy period + * \param channelType the channel type for which the CCA busy state is reported. * * Notify the Txop that a CCA busy period has just started. */ - void NotifyCcaBusyStartNow (Time duration); + void NotifyCcaBusyStartNow (Time duration, WifiChannelListType channelType); /** * \param duration expected duration of channel switching period * diff --git a/src/wifi/model/wifi-phy-listener.h b/src/wifi/model/wifi-phy-listener.h index 5a9046d03..ba27df539 100644 --- a/src/wifi/model/wifi-phy-listener.h +++ b/src/wifi/model/wifi-phy-listener.h @@ -22,9 +22,9 @@ #ifndef WIFI_PHY_LISTENER_H #define WIFI_PHY_LISTENER_H -namespace ns3 { +#include "wifi-phy-common.h" -class Time; +namespace ns3 { /** * \brief receive notifications about PHY events. @@ -78,6 +78,7 @@ public: virtual void NotifyTxStart (Time duration, double txPowerDbm) = 0; /** * \param duration the expected busy duration. + * \param channelType the channel type for which the CCA busy state is reported. * * This method does not really report a real state * change as opposed to the other methods in this class. @@ -91,7 +92,7 @@ public: * which the last NotifyCcaBusyStart method is called and * what duration it reported. */ - virtual void NotifyCcaBusyStart (Time duration) = 0; + virtual void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) = 0; /** * \param duration the expected channel switching duration. * diff --git a/src/wifi/model/wifi-phy-state-helper.cc b/src/wifi/model/wifi-phy-state-helper.cc index 8cd5bfd29..cdbf36454 100644 --- a/src/wifi/model/wifi-phy-state-helper.cc +++ b/src/wifi/model/wifi-phy-state-helper.cc @@ -266,12 +266,12 @@ WifiPhyStateHelper::NotifyRxEndError (void) } void -WifiPhyStateHelper::NotifyCcaBusyStart (Time duration) +WifiPhyStateHelper::NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) { NS_LOG_FUNCTION (this); for (const auto& listener : m_listeners) { - listener->NotifyCcaBusyStart (duration); + listener->NotifyCcaBusyStart (duration, channelType); } } diff --git a/src/wifi/model/wifi-phy-state-helper.h b/src/wifi/model/wifi-phy-state-helper.h index cbec432c2..0a0bed0f4 100644 --- a/src/wifi/model/wifi-phy-state-helper.h +++ b/src/wifi/model/wifi-phy-state-helper.h @@ -314,8 +314,9 @@ private: * Notify all WifiPhyListener that the CCA has started for the given duration. * * \param duration the duration of the CCA state + * \param channelType the channel type for which the CCA busy state is reported. */ - void NotifyCcaBusyStart (Time duration); + void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType = WIFI_CHANLIST_PRIMARY); /** * Notify all WifiPhyListener that we are switching channel with the given channel * switching delay. diff --git a/src/wifi/model/wifi-radio-energy-model.cc b/src/wifi/model/wifi-radio-energy-model.cc index a54950297..db7707358 100644 --- a/src/wifi/model/wifi-radio-energy-model.cc +++ b/src/wifi/model/wifi-radio-energy-model.cc @@ -541,9 +541,9 @@ WifiRadioEnergyModelPhyListener::NotifyTxStart (Time duration, double txPowerDbm } void -WifiRadioEnergyModelPhyListener::NotifyCcaBusyStart (Time duration) +WifiRadioEnergyModelPhyListener::NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) { - NS_LOG_FUNCTION (this << duration); + NS_LOG_FUNCTION (this << duration << channelType); if (m_changeStateCallback.IsNull ()) { NS_FATAL_ERROR ("WifiRadioEnergyModelPhyListener:Change state callback not set!"); diff --git a/src/wifi/model/wifi-radio-energy-model.h b/src/wifi/model/wifi-radio-energy-model.h index bd22090ed..26cfc3e7b 100644 --- a/src/wifi/model/wifi-radio-energy-model.h +++ b/src/wifi/model/wifi-radio-energy-model.h @@ -64,78 +64,15 @@ public: */ void SetUpdateTxCurrentCallback (UpdateTxCurrentCallback callback); - /** - * \brief Switches the WifiRadioEnergyModel to RX state. - * - * \param duration the expected duration of the packet reception. - * - * Defined in ns3::WifiPhyListener - */ void NotifyRxStart (Time duration) override; - - /** - * \brief Switches the WifiRadioEnergyModel back to IDLE state. - * - * Defined in ns3::WifiPhyListener - * - * Note that for the WifiRadioEnergyModel, the behavior of the function is the - * same as NotifyRxEndError. - */ void NotifyRxEndOk (void) override; - - /** - * \brief Switches the WifiRadioEnergyModel back to IDLE state. - * - * Defined in ns3::WifiPhyListener - * - * Note that for the WifiRadioEnergyModel, the behavior of the function is the - * same as NotifyRxEndOk. - */ void NotifyRxEndError (void) override; - - /** - * \brief Switches the WifiRadioEnergyModel to TX state and switches back to - * IDLE after TX duration. - * - * \param duration the expected transmission duration. - * \param txPowerDbm the nominal TX power in dBm - * - * Defined in ns3::WifiPhyListener - */ void NotifyTxStart (Time duration, double txPowerDbm) override; - - /** - * \param duration the expected busy duration. - * - * Defined in ns3::WifiPhyListener - */ - void NotifyCcaBusyStart (Time duration) override; - - /** - * \param duration the expected channel switching duration. - * - * Defined in ns3::WifiPhyListener - */ + void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) override; void NotifySwitchingStart (Time duration) override; - - /** - * Defined in ns3::WifiPhyListener - */ void NotifySleep (void) override; - - /** - * Defined in ns3::WifiPhyListener - */ void NotifyOff (void) override; - - /** - * Defined in ns3::WifiPhyListener - */ void NotifyWakeup (void) override; - - /** - * Defined in ns3::WifiPhyListener - */ void NotifyOn (void) override; diff --git a/src/wifi/test/channel-access-manager-test.cc b/src/wifi/test/channel-access-manager-test.cc index 6bca13b14..5dc6f340c 100644 --- a/src/wifi/test/channel-access-manager-test.cc +++ b/src/wifi/test/channel-access-manager-test.cc @@ -363,8 +363,9 @@ private: * Add CCA busy event function * \param at the event time * \param duration the duration + * \param channelType the channel type */ - void AddCcaBusyEvt (uint64_t at, uint64_t duration); + void AddCcaBusyEvt (uint64_t at, uint64_t duration, WifiChannelListType channelType = WIFI_CHANLIST_PRIMARY); /** * Add switching event function * \param at the event time @@ -715,11 +716,11 @@ ChannelAccessManagerTest::DoAccessRequest (uint64_t txTime, uint64_t e template void -ChannelAccessManagerTest::AddCcaBusyEvt (uint64_t at, uint64_t duration) +ChannelAccessManagerTest::AddCcaBusyEvt (uint64_t at, uint64_t duration, WifiChannelListType channelType) { Simulator::Schedule (MicroSeconds (at) - Now (), &ChannelAccessManager::NotifyCcaBusyStartNow, m_ChannelAccessManager, - MicroSeconds (duration)); + MicroSeconds (duration), channelType); } template diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index a5237b3b1..282ffbdb2 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -253,9 +253,9 @@ public: { NS_LOG_FUNCTION (this << duration << txPowerDbm); } - void NotifyCcaBusyStart (Time duration) override + void NotifyCcaBusyStart (Time duration, WifiChannelListType channelType) override { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << duration << channelType); ++m_notifyMaybeCcaBusyStart; } void NotifySwitchingStart (Time duration) override