diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 317fabe18..a9eb399e8 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -801,27 +801,26 @@ HeOperation ApWifiMac::GetHeOperation (void) const { NS_LOG_FUNCTION (this); + NS_ASSERT (GetHeSupported ()); HeOperation operation; - if (GetHeSupported ()) + + uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { - operation.SetHeSupported (1); - uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); - for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) + if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second)) { - if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second)) + if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) { - if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) - { - maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second); - } + maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second); } } - for (uint8_t nss = 1; nss <= maxSpatialStream; nss++) - { - operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported - } - operation.SetBssColor (GetHeConfiguration ()->GetBssColor ()); } + for (uint8_t nss = 1; nss <= maxSpatialStream; nss++) + { + operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported + } + operation.SetBssColor (GetHeConfiguration ()->GetBssColor ()); + return operation; } diff --git a/src/wifi/model/he/he-operation.cc b/src/wifi/model/he/he-operation.cc index ea8c7855d..f91a1bd8f 100644 --- a/src/wifi/model/he/he-operation.cc +++ b/src/wifi/model/he/he-operation.cc @@ -32,8 +32,7 @@ HeOperation::HeOperation () m_txBssidIndicator (0), m_bssColorDisabled (0), m_dualBeacon (0), - m_basicHeMcsAndNssSet (0), - m_heSupported (0) + m_basicHeMcsAndNssSet (0) { } @@ -49,17 +48,9 @@ HeOperation::ElementIdExt () const return IE_EXT_HE_OPERATION; } -void -HeOperation::SetHeSupported (uint8_t heSupported) -{ - m_heSupported = heSupported; -} - uint8_t HeOperation::GetInformationFieldSize () const { - //we should not be here if he is not supported - NS_ASSERT (m_heSupported > 0); return 7; } @@ -133,36 +124,13 @@ HeOperation::GetBssColor (void) const return m_bssColor; } -Buffer::Iterator -HeOperation::Serialize (Buffer::Iterator i) const -{ - if (m_heSupported < 1) - { - return i; - } - return WifiInformationElement::Serialize (i); -} - -uint16_t -HeOperation::GetSerializedSize () const -{ - if (m_heSupported < 1) - { - return 0; - } - return WifiInformationElement::GetSerializedSize (); -} - void HeOperation::SerializeInformationField (Buffer::Iterator start) const { - if (m_heSupported == 1) - { - //write the corresponding value for each bit - start.WriteHtolsbU32 (GetHeOperationParameters ()); - start.WriteU16 (GetBasicHeMcsAndNssSet ()); - //todo: VHT Operation Information (variable) - } + //write the corresponding value for each bit + start.WriteHtolsbU32 (GetHeOperationParameters ()); + start.WriteU16 (GetBasicHeMcsAndNssSet ()); + //todo: VHT Operation Information (variable) } uint8_t diff --git a/src/wifi/model/he/he-operation.h b/src/wifi/model/he/he-operation.h index 74d6854b3..793ced506 100644 --- a/src/wifi/model/he/he-operation.h +++ b/src/wifi/model/he/he-operation.h @@ -43,19 +43,6 @@ public: uint8_t GetInformationFieldSize () const override; void SerializeInformationField (Buffer::Iterator start) const override; uint8_t DeserializeInformationField (Buffer::Iterator start, uint8_t length) override; - /* This information element is a bit special in that it is only - included if the STA is a HE STA. To support this we - override the Serialize and GetSerializedSize methods of - WifiInformationElement. */ - Buffer::Iterator Serialize (Buffer::Iterator start) const override; - uint16_t GetSerializedSize () const override; - - /** - * Set the HE supported information element. - * - * \param heSupported the HE supported information element - */ - void SetHeSupported (uint8_t heSupported); /** * Set the HE Operation Parameters field in the HE Operation information element. @@ -112,9 +99,6 @@ private: uint16_t m_basicHeMcsAndNssSet; ///< basic HE MCS NSS set //TODO: VHT Operation Information subfields not defined in the standard yet. - - /// This is used to decide whether this element should be added to the frame or not - uint8_t m_heSupported; }; /** diff --git a/src/wifi/model/mgt-headers.cc b/src/wifi/model/mgt-headers.cc index f11c6c219..9c732db11 100644 --- a/src/wifi/model/mgt-headers.cc +++ b/src/wifi/model/mgt-headers.cc @@ -412,7 +412,7 @@ MgtProbeResponseHeader::SetHeOperation (HeOperation&& heOperation) m_heOperation = std::move (heOperation); } -const HeOperation& +const std::optional& MgtProbeResponseHeader::GetHeOperation (void) const { return m_heOperation; @@ -598,7 +598,7 @@ MgtProbeResponseHeader::GetSerializedSize (void) const if (m_vhtCapability.has_value ()) size += m_vhtCapability->GetSerializedSize (); if (m_vhtOperation.has_value ()) size += m_vhtOperation->GetSerializedSize (); if (m_heCapability.has_value ()) size += m_heCapability->GetSerializedSize (); - size += m_heOperation.GetSerializedSize (); + if (m_heOperation.has_value ()) size += m_heOperation->GetSerializedSize (); size += m_muEdcaParameterSet.GetSerializedSize (); if (m_ehtCapability.has_value ()) size += m_ehtCapability->GetSerializedSize (); if (m_reducedNeighborReport != nullptr) size += m_reducedNeighborReport->GetSerializedSize (); @@ -618,7 +618,7 @@ MgtProbeResponseHeader::Print (std::ostream &os) const if (m_vhtCapability.has_value ()) os << "VHT Capabilities=" << *m_vhtCapability << " , "; if (m_vhtOperation.has_value ()) os << "VHT Operation=" << *m_vhtOperation << " , "; if (m_heCapability.has_value ()) os << "HE Capabilities=" << *m_heCapability << " , "; - os << "HE Operation=" << m_heOperation << " , "; + if (m_heOperation.has_value ()) os << "HE Operation=" << *m_heOperation << " , "; if (m_ehtCapability.has_value ()) os << "EHT Capabilities=" << *m_ehtCapability; } @@ -641,7 +641,7 @@ MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const if (m_vhtCapability.has_value ()) i = m_vhtCapability->Serialize (i); if (m_vhtOperation.has_value ()) i = m_vhtOperation->Serialize (i); if (m_heCapability.has_value ()) i = m_heCapability->Serialize (i); - i = m_heOperation.Serialize (i); + if (m_heOperation.has_value ()) i = m_heOperation->Serialize (i); i = m_muEdcaParameterSet.Serialize (i); if (m_ehtCapability.has_value ()) i = m_ehtCapability->Serialize (i); if (m_reducedNeighborReport != nullptr) i = m_reducedNeighborReport->Serialize (i); @@ -668,7 +668,7 @@ MgtProbeResponseHeader::Deserialize (Buffer::Iterator start) i = WifiInformationElement::DeserializeIfPresent (m_vhtCapability, i); i = WifiInformationElement::DeserializeIfPresent (m_vhtOperation, i); i = WifiInformationElement::DeserializeIfPresent (m_heCapability, i); - i = m_heOperation.DeserializeIfPresent (i); + i = WifiInformationElement::DeserializeIfPresent (m_heOperation, i); i = m_muEdcaParameterSet.DeserializeIfPresent (i); i = WifiInformationElement::DeserializeIfPresent (m_ehtCapability, i); i = (m_reducedNeighborReport = Create ())->DeserializeIfPresent (tmp = i); @@ -1428,7 +1428,7 @@ MgtAssocResponseHeader::SetHeOperation (HeOperation&& heOperation) m_heOperation = std::move (heOperation); } -const HeOperation& +const std::optional& MgtAssocResponseHeader::GetHeOperation (void) const { return m_heOperation; @@ -1564,7 +1564,7 @@ MgtAssocResponseHeader::GetSerializedSize (void) const if (m_vhtCapability.has_value ()) size += m_vhtCapability->GetSerializedSize (); if (m_vhtOperation.has_value ()) size += m_vhtOperation->GetSerializedSize (); if (m_heCapability.has_value ()) size += m_heCapability->GetSerializedSize (); - size += m_heOperation.GetSerializedSize (); + if (m_heOperation.has_value ()) size += m_heOperation->GetSerializedSize (); size += m_muEdcaParameterSet.GetSerializedSize (); if (m_ehtCapability.has_value ()) size += m_ehtCapability->GetSerializedSize (); if (m_multiLinkElement != nullptr) size += m_multiLinkElement->GetSerializedSize (); @@ -1584,7 +1584,7 @@ MgtAssocResponseHeader::Print (std::ostream &os) const if (m_vhtCapability.has_value ()) os << "VHT Capabilities=" << *m_vhtCapability << " , "; if (m_vhtOperation.has_value ()) os << "VHT Operation=" << *m_vhtOperation << " , "; if (m_heCapability.has_value ()) os << "HE Capabilities=" << *m_heCapability << " , "; - os << "HE Operation=" << m_heOperation << " , "; + if (m_heOperation.has_value ()) os << "HE Operation=" << *m_heOperation << " , "; if (m_ehtCapability.has_value ()) os << "EHT Capabilities=" << *m_ehtCapability; } @@ -1605,7 +1605,7 @@ MgtAssocResponseHeader::Serialize (Buffer::Iterator start) const if (m_vhtCapability.has_value ()) i = m_vhtCapability->Serialize (i); if (m_vhtOperation.has_value ()) i = m_vhtOperation->Serialize (i); if (m_heCapability.has_value ()) i = m_heCapability->Serialize (i); - i = m_heOperation.Serialize (i); + if (m_heOperation.has_value ()) i = m_heOperation->Serialize (i); i = m_muEdcaParameterSet.Serialize (i); if (m_ehtCapability.has_value ()) i = m_ehtCapability->Serialize (i); if (m_multiLinkElement != nullptr) i = m_multiLinkElement->Serialize (i); @@ -1628,7 +1628,7 @@ MgtAssocResponseHeader::Deserialize (Buffer::Iterator start) i = WifiInformationElement::DeserializeIfPresent (m_vhtCapability, i); i = WifiInformationElement::DeserializeIfPresent (m_vhtOperation, i); i = WifiInformationElement::DeserializeIfPresent (m_heCapability, i); - i = m_heOperation.DeserializeIfPresent (i); + i = WifiInformationElement::DeserializeIfPresent (m_heOperation, i); i = m_muEdcaParameterSet.DeserializeIfPresent (i); i = WifiInformationElement::DeserializeIfPresent (m_ehtCapability, i); m_multiLinkElement = Create (WIFI_MAC_MGT_ASSOCIATION_RESPONSE); diff --git a/src/wifi/model/mgt-headers.h b/src/wifi/model/mgt-headers.h index 9b9b8cdb9..d00c76177 100644 --- a/src/wifi/model/mgt-headers.h +++ b/src/wifi/model/mgt-headers.h @@ -502,11 +502,11 @@ public: */ const std::optional& GetHeCapabilities (void) const; /** - * Return the HE operation. + * Return the HE operation, if present. * - * \return HE operation + * \return HE operation, if present */ - const HeOperation& GetHeOperation (void) const; + const std::optional& GetHeOperation (void) const; /** * Return the EHT capabilities, if present. * @@ -721,7 +721,7 @@ private: ErpInformation m_erpInformation; //!< ERP information EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set std::optional m_heCapability; //!< HE capabilities - HeOperation m_heOperation; //!< HE operation + std::optional m_heOperation; //!< HE operation MuEdcaParameterSet m_muEdcaParameterSet; //!< MU EDCA Parameter Set std::optional m_ehtCapability; //!< EHT capabilities Ptr m_multiLinkElement; //!< Multi-Link Element @@ -956,11 +956,11 @@ public: */ const std::optional& GetHeCapabilities (void) const; /** - * Return the HE operation. + * Return the HE operation, if present. * - * \return HE operation + * \return HE operation, if present */ - const HeOperation& GetHeOperation (void) const; + const std::optional& GetHeOperation (void) const; /** * Return the EHT capabilities, if present. * @@ -1201,7 +1201,7 @@ private: std::optional m_vhtCapability; //!< VHT capabilities std::optional m_vhtOperation; //!< VHT operation std::optional m_heCapability; //!< HE capabilities - HeOperation m_heOperation; //!< HE operation + std::optional m_heOperation; //!< HE operation ErpInformation m_erpInformation; //!< ERP information EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set MuEdcaParameterSet m_muEdcaParameterSet; //!< MU EDCA Parameter Set diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 5e3224d38..78f1df646 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -1153,7 +1153,6 @@ StaWifiMac::UpdateApInfo (const MgtFrameType& frame, const Mac48Address& apAddr, if (heCapabilities.has_value () && heCapabilities->GetSupportedMcsAndNss () != 0) { GetWifiRemoteStationManager (linkId)->AddStationHeCapabilities (apAddr, *heCapabilities); - HeOperation heOperation = frame.GetHeOperation (); for (const auto & mcs : GetWifiPhy (linkId)->GetMcsList (WIFI_MOD_CLASS_HE)) { if (heCapabilities->IsSupportedRxMcs (mcs.GetMcsValue ())) @@ -1161,7 +1160,10 @@ StaWifiMac::UpdateApInfo (const MgtFrameType& frame, const Mac48Address& apAddr, GetWifiRemoteStationManager (linkId)->AddSupportedMcs (apAddr, mcs); } } - GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ())); + if (const auto& heOperation = frame.GetHeOperation (); heOperation.has_value ()) + { + GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation->GetBssColor ())); + } } const MuEdcaParameterSet& muEdcaParameters = frame.GetMuEdcaParameterSet ();