diff --git a/src/wifi/doc/source/wifi-user.rst b/src/wifi/doc/source/wifi-user.rst index 00afe32ac..2b9c8c737 100644 --- a/src/wifi/doc/source/wifi-user.rst +++ b/src/wifi/doc/source/wifi-user.rst @@ -579,6 +579,28 @@ The wifi standard can be configured only once, i.e., it is not possible to change standard during a simulation. It is instead possible to change the channel settings at any time. +Advertisement of the channel width +++++++++++++++++++++++++++++++++++ + +STAs are advertizing their channel width in capabilities and operations (for APs) information elements +contained in management frames. + +The channel width that is being advertised is the value that is returned by WifiPhy::ChannelWidth, which corresponds to +the value that is set in the ChannelSettings attribute (or the total width in case of non-contiguous channel operation). + +Not all the channel widths can be advertised for non-AP STAs, depending on the standard and the band. +This is not a problem as long as the AP the non-AP STA is associated with is operating on the same channel width +or on a narrower one. Otherwise, the AP might select a larger channel width for the transmission of downlink PPDUs, +which would then be dropped by the PHY of the non-AP STA. + +For example, since VHT Capabilities Information Elements only allow the advertisement of 80 and 160 MHz channel widths, +a VHT non-AP STA with its ChannelSettings set to use a 40 MHz channel width won't be able to receive any downlink PPDUs +if the VHT AP has its ChannelSettings set to operate on an 80 MHz channel width. + +It is possible to configure the behavior of the association manager to either abort the simulation when such +a problematic situation is detected (default) or to allow the association anyway, depending on the configured value +for the ``ns3::WifiMac::AllowAssociationWithDifferentChannelWidth`` attribute. + SpectrumWifiPhyHelper ===================== diff --git a/src/wifi/model/wifi-assoc-manager.cc b/src/wifi/model/wifi-assoc-manager.cc index a911a8173..baa6967f2 100644 --- a/src/wifi/model/wifi-assoc-manager.cc +++ b/src/wifi/model/wifi-assoc-manager.cc @@ -10,8 +10,10 @@ #include "wifi-assoc-manager.h" #include "sta-wifi-mac.h" +#include "wifi-phy.h" #include "ns3/attribute-container.h" +#include "ns3/boolean.h" #include "ns3/eht-configuration.h" #include "ns3/enum.h" #include "ns3/log.h" @@ -67,7 +69,15 @@ WifiAssocManager::GetTypeId() "set are processed. An empty set is equivalent to the set of all links.", AttributeContainerValue(), MakeAttributeContainerAccessor(&WifiAssocManager::m_allowedLinks), - MakeAttributeContainerChecker(MakeUintegerChecker())); + MakeAttributeContainerChecker(MakeUintegerChecker())) + .AddAttribute("AllowAssocAllChannelWidths", + "If set to true, it bypasses the check on channel width compatibility " + "with the candidate AP. A channel width is compatible if the STA can " + "advertise it to the AP, or AP operates on a channel width that is equal " + "or lower than that channel width.", + BooleanValue(false), + MakeBooleanAccessor(&WifiAssocManager::m_allowAssocAllChannelWidths), + MakeBooleanChecker()); return tid; } @@ -236,6 +246,10 @@ WifiAssocManager::ScanningTimeout() m_apListIt.erase(bestAp.m_bssid); } while (!CanBeReturned(bestAp)); + NS_ABORT_MSG_IF(!m_allowAssocAllChannelWidths && !IsChannelWidthCompatible(bestAp), + "Channel width of STA is not part of the channel width set that can be " + "advertised to the AP"); + m_mac->ScanningTimeout(std::move(bestAp)); } @@ -361,4 +375,14 @@ WifiAssocManager::GetAllAffiliatedAps(const ReducedNeighborReport& rnr) return apList; } +bool +WifiAssocManager::IsChannelWidthCompatible(const StaWifiMac::ApInfo& apInfo) const +{ + auto phy = m_mac->GetWifiPhy(apInfo.m_linkId); + return GetSupportedChannelWidthSet(phy->GetStandard(), apInfo.m_channel.band) + .contains(phy->GetChannelWidth()) || + (phy->GetChannelWidth() >= m_mac->GetWifiRemoteStationManager(apInfo.m_linkId) + ->GetChannelWidthSupported(apInfo.m_bssid)); +} + } // namespace ns3 diff --git a/src/wifi/model/wifi-assoc-manager.h b/src/wifi/model/wifi-assoc-manager.h index 6bdba4344..c20d57f37 100644 --- a/src/wifi/model/wifi-assoc-manager.h +++ b/src/wifi/model/wifi-assoc-manager.h @@ -199,6 +199,16 @@ class WifiAssocManager : public Object */ virtual bool CanBeReturned(const StaWifiMac::ApInfo& apInfo) const = 0; + /** + * Check whether the channel width of the STA is compatible with the channel width of the + * operating channel of a given AP. A channel width is compatible if the STA can advertise it to + * the AP, or AP operates on a channel width that is equal or lower than that channel width + * + * @param apInfo the given AP information + * @return true if the channel width of the STA is compatible, false otherwise + */ + bool IsChannelWidthCompatible(const StaWifiMac::ApInfo& apInfo) const; + /** * Extract the best AP to associate with from the sorted list and return * it, if any, to the STA wifi MAC along with the notification that scanning @@ -226,6 +236,9 @@ class WifiAssocManager : public Object std::set m_allowedLinks; /**< "Only Beacon and Probe Response frames received on a link belonging to the this set are processed */ + bool m_allowAssocAllChannelWidths; ///< flag whether the check on channel width compatibility + ///< with the candidate AP should be skipped + private: /** * Start a scanning procedure. This method needs to schedule a call to