From f9d5949735ebcc0eea2ee8a8ec6aaf60f2d0e688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 4 Nov 2018 16:21:09 +0100 Subject: [PATCH] wifi: Add transport of 802.11ax BSS coloring field (with contributions from Tom Henderson) --- src/wifi/model/ap-wifi-mac.cc | 12 ++++++------ src/wifi/model/he-configuration.cc | 4 ++++ src/wifi/model/he-configuration.h | 1 + src/wifi/model/he-operation.cc | 14 ++++++++++++++ src/wifi/model/he-operation.h | 10 ++++++++++ src/wifi/model/sta-wifi-mac.cc | 10 ++++------ src/wifi/model/wifi-mac.cc | 17 +++++++++++++++++ src/wifi/model/wifi-mac.h | 11 +++++++++++ 8 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index ff23f43a6..1eb5aa5e0 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -36,6 +36,7 @@ #include "wifi-phy.h" #include "wifi-net-device.h" #include "ht-configuration.h" +#include "he-configuration.h" namespace ns3 { @@ -564,8 +565,6 @@ ApWifiMac::GetHtOperation (void) const HtOperation operation; if (GetHtSupported ()) { - Ptr device = DynamicCast (GetDevice ()); - Ptr htConfiguration = device->GetHtConfiguration (); operation.SetHtSupported (1); operation.SetPrimaryChannel (m_phy->GetChannelNumber ()); operation.SetRifsMode (GetRifsMode ()); @@ -593,7 +592,7 @@ ApWifiMac::GetHtOperation (void) const } uint8_t nss = (mcs.GetMcsValue () / 8) + 1; NS_ASSERT (nss > 0 && nss < 5); - uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), htConfiguration->GetShortGuardIntervalSupported () ? 400 : 800, nss); + uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss); if (dataRate > maxSupportedRate) { maxSupportedRate = dataRate; @@ -718,6 +717,9 @@ ApWifiMac::GetHeOperation (void) const { operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported } + UintegerValue bssColor; + GetHeConfiguration ()->GetAttribute ("BssColor", bssColor); + operation.SetBssColor (bssColor.Get ()); } return operation; } @@ -1588,9 +1590,7 @@ ApWifiMac::GetRifsMode (void) const rifsMode = true; } } - Ptr device = DynamicCast (GetDevice ()); - Ptr htConfiguration = device->GetHtConfiguration (); - if (htConfiguration && htConfiguration->GetRifsSupported () && rifsMode) + if (GetHtSupported () && GetHtConfiguration ()->GetRifsSupported () && rifsMode) { m_stationManager->SetRifsPermitted (true); } diff --git a/src/wifi/model/he-configuration.cc b/src/wifi/model/he-configuration.cc index 25bcd8352..1357165a8 100644 --- a/src/wifi/model/he-configuration.cc +++ b/src/wifi/model/he-configuration.cc @@ -46,6 +46,10 @@ HeConfiguration::GetTypeId (void) MakeTimeAccessor (&HeConfiguration::GetGuardInterval, &HeConfiguration::SetGuardInterval), MakeTimeChecker (NanoSeconds (800), NanoSeconds (3200))) + .AddAttribute ("BssColor", "BSS color", + UintegerValue (0), + MakeUintegerAccessor (&HeConfiguration::m_bssColor), + MakeUintegerChecker ()) ; return tid; } diff --git a/src/wifi/model/he-configuration.h b/src/wifi/model/he-configuration.h index dfca626cb..78775144a 100644 --- a/src/wifi/model/he-configuration.h +++ b/src/wifi/model/he-configuration.h @@ -50,6 +50,7 @@ public: private: Time m_guardInterval; //!< Supported HE guard interval + uint8_t m_bssColor; //!< BSS color }; } //namespace ns3 diff --git a/src/wifi/model/he-operation.cc b/src/wifi/model/he-operation.cc index 6247f80bf..5f8cb7c43 100644 --- a/src/wifi/model/he-operation.cc +++ b/src/wifi/model/he-operation.cc @@ -119,6 +119,20 @@ HeOperation::GetBasicHeMcsAndNssSet (void) const return m_basicHeMcsAndNssSet; } +void +HeOperation::SetBssColor (uint8_t bssColor) +{ + NS_ABORT_UNLESS (bssColor < 64); // 6 bits + m_bssColor = bssColor; + m_bssColorDisabled = 0; +} + +uint8_t +HeOperation::GetBssColor (void) const +{ + return m_bssColor; +} + Buffer::Iterator HeOperation::Serialize (Buffer::Iterator i) const { diff --git a/src/wifi/model/he-operation.h b/src/wifi/model/he-operation.h index 2caf16b8d..861a8b83c 100644 --- a/src/wifi/model/he-operation.h +++ b/src/wifi/model/he-operation.h @@ -72,6 +72,16 @@ public: * \return the Basic HE-MCS And Nss field in the HE Operation information element */ uint16_t GetBasicHeMcsAndNssSet (void) const; + /** + * Set the BSS color + * \param bssColor the BSS color value + */ + void SetBssColor (uint8_t bssColor); + /** + * Get the BSS color + * \return the BSS color value + */ + uint8_t GetBssColor (void) const; /** * Return the element ID. diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 33c0c4f40..c6bf376ca 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -30,6 +30,7 @@ #include "snr-tag.h" #include "wifi-net-device.h" #include "ht-configuration.h" +#include "he-configuration.h" namespace ns3 { @@ -804,9 +805,7 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, { m_stationManager->SetUseGreenfieldProtection (false); } - Ptr device = DynamicCast (GetDevice ()); - Ptr htConfiguration = device->GetHtConfiguration (); - if (!GetVhtSupported () && htConfiguration && htConfiguration->GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -1005,9 +1004,7 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad { m_stationManager->SetUseGreenfieldProtection (false); } - Ptr device = DynamicCast (GetDevice ()); - Ptr htConfiguration = device->GetHtConfiguration (); - if (!GetVhtSupported () && htConfiguration && htConfiguration->GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetHtConfiguration ()->GetRifsSupported () && htOperation.GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -1033,6 +1030,7 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities); HeOperation heOperation = assocResp.GetHeOperation (); + GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ())); } for (uint8_t i = 0; i < m_phy->GetNModes (); i++) { diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index b45425a7f..d489fa5b2 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -23,6 +23,9 @@ #include "wifi-mac.h" #include "txop.h" #include "ssid.h" +#include "wifi-net-device.h" +#include "ht-configuration.h" +#include "he-configuration.h" namespace ns3 { @@ -470,5 +473,19 @@ WifiMac::ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, bool isDss } } +Ptr +WifiMac::GetHtConfiguration (void) const +{ + Ptr device = DynamicCast (GetDevice ()); + return device->GetHtConfiguration (); +} + +Ptr +WifiMac::GetHeConfiguration (void) const +{ + Ptr device = DynamicCast (GetDevice ()); + return device->GetHeConfiguration (); +} + } //namespace ns3 diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index 3156c6ba1..db203acd4 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -30,6 +30,8 @@ namespace ns3 { class Ssid; class Txop; +class HtConfiguration; +class HeConfiguration; /** * \brief base class for all MAC-level wifi objects. @@ -323,6 +325,15 @@ protected: */ void ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, bool isDsss, AcIndex ac); + /** + * \return pointer to HtConfiguration if it exists + */ + Ptr GetHtConfiguration (void) const; + /** + * \return pointer to HeConfiguration if it exists + */ + Ptr GetHeConfiguration (void) const; + private: /**