From b47358f4a6cb7ae7d0b54de91f4ef0547fec3288 Mon Sep 17 00:00:00 2001 From: Rami Abdallah Date: Tue, 27 Feb 2024 23:25:15 +0100 Subject: [PATCH] wifi: Include HE 6GHz Band Capabilities in management frames --- src/wifi/model/ap-wifi-mac.cc | 21 ++++++++- src/wifi/model/sta-wifi-mac.cc | 18 ++++++++ src/wifi/model/wifi-mac.cc | 44 +++++++++++++++++++ src/wifi/model/wifi-mac.h | 15 +++++++ src/wifi/model/wifi-remote-station-manager.cc | 18 ++++++++ src/wifi/model/wifi-remote-station-manager.h | 18 ++++++++ 6 files changed, 133 insertions(+), 1 deletion(-) diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index cb04409fd..4c55c2c2c 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -1151,10 +1151,14 @@ ApWifiMac::SendProbeResp(Mac48Address to, uint8_t linkId) { probe.Get() = GetHeCapabilities(linkId); probe.Get() = GetHeOperation(linkId); - if (auto muEdcaParameterSet = GetMuEdcaParameterSet(); muEdcaParameterSet.has_value()) + if (auto muEdcaParameterSet = GetMuEdcaParameterSet()) { probe.Get() = std::move(*muEdcaParameterSet); } + if (Is6GhzBand(linkId)) + { + probe.Get() = GetHe6GhzBandCapabilities(linkId); + } } if (GetEhtSupported()) { @@ -1254,6 +1258,10 @@ ApWifiMac::GetAssocResp(Mac48Address to, uint8_t linkId) { assoc.Get() = std::move(*muEdcaParameterSet); } + if (Is6GhzBand(linkId)) + { + assoc.Get() = GetHe6GhzBandCapabilities(linkId); + } } if (GetEhtSupported()) { @@ -1546,6 +1554,10 @@ ApWifiMac::SendOneBeacon(uint8_t linkId) { beacon.Get() = std::move(*muEdcaParameterSet); } + if (Is6GhzBand(linkId)) + { + beacon.Get() = GetHe6GhzBandCapabilities(linkId); + } } if (GetEhtSupported()) { @@ -2144,6 +2156,13 @@ ApWifiMac::ReceiveAssocRequest(const AssocReqRefVariant& assoc, } } } + if (Is6GhzBand(linkId)) + { + if (const auto& he6GhzCapabilities = frame.template Get()) + { + remoteStationManager->AddStationHe6GhzCapabilities(from, *he6GhzCapabilities); + } + } } if (GetEhtSupported()) { diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index fb707581e..35eb6ed17 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -383,6 +383,10 @@ StaWifiMac::SendProbeRequest(uint8_t linkId) if (GetHeSupported()) { probe.Get() = GetHeCapabilities(linkId); + if (Is6GhzBand(linkId)) + { + probe.Get() = GetHe6GhzBandCapabilities(linkId); + } } if (GetEhtSupported()) { @@ -445,6 +449,10 @@ StaWifiMac::GetAssociationRequest(bool isReassoc, uint8_t linkId) const if (GetHeSupported()) { frame.template Get() = GetHeCapabilities(linkId); + if (Is6GhzBand(linkId)) + { + frame.template Get() = GetHe6GhzBandCapabilities(linkId); + } } if (GetEhtSupported()) { @@ -1804,6 +1812,16 @@ StaWifiMac::UpdateApInfo(const MgtFrameType& frame, linkId); } + if (Is6GhzBand(linkId)) + { + if (const auto& he6GhzCapabilities = frame.template Get()) + { + GetWifiRemoteStationManager(linkId)->AddStationHe6GhzCapabilities( + apAddr, + *he6GhzCapabilities); + } + } + if (!GetEhtSupported()) { return; diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 183d8eebf..958493b09 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -40,6 +40,7 @@ #include "ns3/vht-configuration.h" #include +#include #include #include @@ -1199,6 +1200,14 @@ WifiMac::SwapLinks(std::map links) } } +bool +WifiMac::Is6GhzBand(uint8_t linkId) const +{ + auto phy = GetLink(linkId).phy; + NS_ASSERT(phy); + return phy->GetPhyBand() == WIFI_PHY_BAND_6GHZ; +} + void WifiMac::UpdateTidToLinkMapping(const Mac48Address& mldAddr, WifiDirection dir, @@ -2286,6 +2295,41 @@ WifiMac::GetHeCapabilities(uint8_t linkId) const return capabilities; } +He6GhzBandCapabilities +WifiMac::GetHe6GhzBandCapabilities(uint8_t linkId) const +{ + auto phy = GetLink(linkId).phy; + NS_ASSERT_MSG(phy->GetPhyBand() == WIFI_PHY_BAND_6GHZ, + "Getting HE 6 GHz band capabilities on band different than 6 GHz"); + + He6GhzBandCapabilities capabilities; + + // Set Maximum MPDU Length subfield + const auto maxAmsduSize = + std::max({m_voMaxAmsduSize, m_viMaxAmsduSize, m_beMaxAmsduSize, m_bkMaxAmsduSize}); + if (maxAmsduSize <= 3839) + { + capabilities.SetMaxMpduLength(3895); + } + else if (maxAmsduSize <= 7935) + { + capabilities.SetMaxMpduLength(7991); + } + else + { + capabilities.SetMaxMpduLength(11454); + } + + auto maxAmpduLength = + std::max({m_voMaxAmpduSize, m_viMaxAmpduSize, m_beMaxAmpduSize, m_bkMaxAmpduSize}); + // round to the next power of two minus one + maxAmpduLength = (1UL << static_cast(std::ceil(std::log2(maxAmpduLength + 1)))) - 1; + // The maximum A-MPDU length in HE 6 GHz Band Capabilities elements ranges from 2^13-1 to 2^20-1 + capabilities.SetMaxAmpduLength(std::min(std::max(maxAmpduLength, 8191U), 1048575U)); + + return capabilities; +} + EhtCapabilities WifiMac::GetEhtCapabilities(uint8_t linkId) const { diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index 15b4f2f3c..87ceb8985 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -197,6 +197,14 @@ class WifiMac : public Object */ std::optional GetLinkForPhy(std::size_t phyId) const; + /** + * Indicate if a given link is on the 6 GHz band. + * + * \param linkId the ID of the given link + * \return whether the given link is on the 6 GHz band + */ + bool Is6GhzBand(uint8_t linkId) const; + /** * \param remoteAddr the (MLD or link) address of a remote device * \return the MLD address of the remote device having the given (MLD or link) address, if @@ -535,6 +543,13 @@ class WifiMac : public Object * \return the HE capabilities that we support */ HeCapabilities GetHeCapabilities(uint8_t linkId) const; + /** + * Return the HE 6GHz band capabilities of the device for the given 6 GHz link. + * + * \param linkId the ID of the given 6 GHz link + * \return the HE 6GHz band capabilities that we support + */ + He6GhzBandCapabilities GetHe6GhzBandCapabilities(uint8_t linkId) const; /** * Return the EHT capabilities of the device for the given link. * diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index dd7d08a19..001ee0c1e 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -1600,6 +1600,18 @@ WifiRemoteStationManager::AddStationHeCapabilities(Mac48Address from, HeCapabili SetQosSupport(from, true); } +void +WifiRemoteStationManager::AddStationHe6GhzCapabilities( + const Mac48Address& from, + const He6GhzBandCapabilities& he6GhzCapabilities) +{ + // Used by all stations to record HE 6GHz band capabilities of remote stations + NS_LOG_FUNCTION(this << from << he6GhzCapabilities); + auto state = LookupState(from); + state->m_he6GhzBandCapabilities = Create(he6GhzCapabilities); + SetQosSupport(from, true); +} + void WifiRemoteStationManager::AddStationEhtCapabilities(Mac48Address from, EhtCapabilities ehtCapabilities) @@ -1653,6 +1665,12 @@ WifiRemoteStationManager::GetStationHeCapabilities(Mac48Address from) return LookupState(from)->m_heCapabilities; } +Ptr +WifiRemoteStationManager::GetStationHe6GhzCapabilities(const Mac48Address& from) const +{ + return LookupState(from)->m_he6GhzBandCapabilities; +} + Ptr WifiRemoteStationManager::GetStationEhtCapabilities(Mac48Address from) { diff --git a/src/wifi/model/wifi-remote-station-manager.h b/src/wifi/model/wifi-remote-station-manager.h index 396fcb944..e9c176494 100644 --- a/src/wifi/model/wifi-remote-station-manager.h +++ b/src/wifi/model/wifi-remote-station-manager.h @@ -27,6 +27,7 @@ #include "ns3/data-rate.h" #include "ns3/eht-capabilities.h" +#include "ns3/he-6ghz-band-capabilities.h" #include "ns3/he-capabilities.h" #include "ns3/ht-capabilities.h" #include "ns3/mac48-address.h" @@ -112,6 +113,8 @@ struct WifiRemoteStationState Ptr m_htCapabilities; //!< remote station HT capabilities Ptr m_vhtCapabilities; //!< remote station VHT capabilities Ptr m_heCapabilities; //!< remote station HE capabilities + Ptr + m_he6GhzBandCapabilities; //!< remote station HE 6GHz band capabilities Ptr m_ehtCapabilities; //!< remote station EHT capabilities /// remote station Multi-Link Element Common Info std::shared_ptr m_mleCommonInfo; @@ -261,6 +264,14 @@ class WifiRemoteStationManager : public Object * \param heCapabilities the HE capabilities of the station */ void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities); + /** + * Records HE 6 GHz Band Capabilities of a remote station + * + * \param from the address of the remote station + * \param he6GhzCapabilities the HE 6 GHz Band Capabilities of the remote station + */ + void AddStationHe6GhzCapabilities(const Mac48Address& from, + const He6GhzBandCapabilities& he6GhzCapabilities); /** * Records EHT capabilities of the remote station. * @@ -298,6 +309,13 @@ class WifiRemoteStationManager : public Object * \return the HE capabilities sent by the remote station */ Ptr GetStationHeCapabilities(Mac48Address from); + /** + * Return the HE 6 GHz Band Capabilities sent by a remote station. + * + * \param from the address of the remote station + * \return the HE 6 GHz Band capabilities sent by the remote station + */ + Ptr GetStationHe6GhzCapabilities(const Mac48Address& from) const; /** * Return the EHT capabilities sent by the remote station. *