From d58edfde6acc386daffbe1a95258109d692d8585 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 24 Jun 2025 12:07:23 +0200 Subject: [PATCH] wifi: Add an attribute to StaWifiMac to disable channel scanning --- CHANGES.md | 1 + src/wifi/model/sta-wifi-mac.cc | 11 +++++++++++ src/wifi/model/sta-wifi-mac.h | 1 + 3 files changed, 13 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 68ccb5390..fe6428669 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ This file is a best-effort approach to solving this issue; we will do our best b * (wifi) Added a new `EarlyTxopEndDetect` attribute to `EhtFrameExchangeManager` to control whether the Duration/ID value of the frame being transmitted or received by a device shall be used to early detect the end of an ongoing TXOP (held by another device). * (spectrum) Added the base `WraparoundModel`, which is retrieved from the associated objects of a spectrum channel, and then used to wraparound the transmitter mobility model during transmissions. * (spectrum) Added the `HexagonalWraparoundModel`, which implements the wraparound for a hexagonal cell deployment, typical of cellular networks. +* (wifi) Added a new `DisableScanning` attribute to `StaWifiMac` to disable channel scanning; it can be useful to set this attribute to false when a static setup is performed. ### Changes to existing API diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 69321466b..459e776ce 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -74,6 +74,12 @@ StaWifiMac::GetTypeId() UintegerValue(10), MakeUintegerAccessor(&StaWifiMac::m_maxMissedBeacons), MakeUintegerChecker()) + .AddAttribute("EnableScanning", + "If false, STA does not perform channel scanning. This may be useful in " + "case of static configuration via the static setup helper.", + BooleanValue(true), + MakeBooleanAccessor(&StaWifiMac::m_enableScanning), + MakeBooleanChecker()) .AddAttribute( "ActiveProbing", "If true, we send probe requests. If false, we don't." @@ -823,6 +829,11 @@ void StaWifiMac::StartScanning() { NS_LOG_FUNCTION(this); + if (!m_enableScanning) + { + NS_LOG_DEBUG("Scanning disabled"); + return; + } SetState(SCANNING); NS_ASSERT(m_assocManager); diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index fa5600959..aac8e85b0 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -662,6 +662,7 @@ class StaWifiMac : public WifiMac uint32_t m_maxMissedBeacons; ///< maximum missed beacons EventId m_beaconWatchdog; //!< beacon watchdog Time m_beaconWatchdogEnd{0}; //!< beacon watchdog end + bool m_enableScanning; //!< enable channel scanning bool m_activeProbing; ///< active probing Ptr m_probeDelay; ///< RandomVariable used to randomize the time ///< of the first Probe Response on each channel