wifi: Make ERP Information IE optional in mgt frames

This commit is contained in:
Stefano Avallone
2022-07-12 22:01:31 +02:00
parent e57b2aed9f
commit ed62e86e5a
6 changed files with 39 additions and 88 deletions

View File

@@ -463,21 +463,20 @@ ErpInformation
ApWifiMac::GetErpInformation (uint8_t linkId) const
{
NS_LOG_FUNCTION (this << +linkId);
NS_ASSERT (GetErpSupported (linkId));
ErpInformation information;
information.SetErpSupported (1);
if (GetErpSupported (linkId))
information.SetNonErpPresent (m_numNonErpStations > 0);
information.SetUseProtection (GetUseNonErpProtection ());
if (m_shortPreambleEnabled)
{
information.SetNonErpPresent (m_numNonErpStations > 0);
information.SetUseProtection (GetUseNonErpProtection ());
if (m_shortPreambleEnabled)
{
information.SetBarkerPreambleMode (0);
}
else
{
information.SetBarkerPreambleMode (1);
}
information.SetBarkerPreambleMode (0);
}
else
{
information.SetBarkerPreambleMode (1);
}
return information;
}

View File

@@ -496,7 +496,7 @@ MgtProbeResponseHeader::SetErpInformation (ErpInformation&& erpInformation)
m_erpInformation = std::move (erpInformation);
}
const ErpInformation&
const std::optional<ErpInformation>&
MgtProbeResponseHeader::GetErpInformation (void) const
{
return m_erpInformation;
@@ -589,7 +589,7 @@ MgtProbeResponseHeader::GetSerializedSize (void) const
size += m_ssid.GetSerializedSize ();
size += m_rates.GetSerializedSize ();
size += m_dsssParameterSet.GetSerializedSize ();
size += m_erpInformation.GetSerializedSize ();
if (m_erpInformation.has_value ()) size += m_erpInformation->GetSerializedSize ();
size += m_rates.extended.GetSerializedSize ();
size += m_edcaParameterSet.GetSerializedSize ();
size += m_extendedCapability.GetSerializedSize ();
@@ -610,9 +610,9 @@ void
MgtProbeResponseHeader::Print (std::ostream &os) const
{
os << "ssid=" << m_ssid << ", "
<< "rates=" << m_rates << ", "
<< "ERP information=" << m_erpInformation << ", "
<< "Extended Capabilities=" << m_extendedCapability << " , ";
<< "rates=" << m_rates << ", ";
if (m_erpInformation.has_value ()) os << "ERP information=" << *m_erpInformation << ", ";
os << "Extended Capabilities=" << m_extendedCapability << " , ";
if (m_htCapability.has_value ()) os << "HT Capabilities=" << *m_htCapability << " , ";
if (m_htOperation.has_value ()) os << "HT Operation=" << *m_htOperation << " , ";
if (m_vhtCapability.has_value ()) os << "VHT Capabilities=" << *m_vhtCapability << " , ";
@@ -632,7 +632,7 @@ MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const
i = m_ssid.Serialize (i);
i = m_rates.Serialize (i);
i = m_dsssParameterSet.Serialize (i);
i = m_erpInformation.Serialize (i);
if (m_erpInformation.has_value ()) i = m_erpInformation->Serialize (i);
i = m_rates.extended.Serialize (i);
i = m_edcaParameterSet.Serialize (i);
i = m_extendedCapability.Serialize (i);
@@ -659,7 +659,7 @@ MgtProbeResponseHeader::Deserialize (Buffer::Iterator start)
i = m_ssid.Deserialize (i);
i = m_rates.Deserialize (i);
i = m_dsssParameterSet.DeserializeIfPresent (i);
i = m_erpInformation.DeserializeIfPresent (i);
i = WifiInformationElement::DeserializeIfPresent (m_erpInformation, i);
i = m_rates.extended.DeserializeIfPresent (i);
i = m_edcaParameterSet.DeserializeIfPresent (i);
i = m_extendedCapability.DeserializeIfPresent (i);
@@ -1488,7 +1488,7 @@ MgtAssocResponseHeader::SetErpInformation (ErpInformation&& erpInformation)
m_erpInformation = std::move (erpInformation);
}
const ErpInformation&
const std::optional<ErpInformation>&
MgtAssocResponseHeader::GetErpInformation (void) const
{
return m_erpInformation;
@@ -1555,7 +1555,7 @@ MgtAssocResponseHeader::GetSerializedSize (void) const
size += m_code.GetSerializedSize ();
size += 2; //aid
size += m_rates.GetSerializedSize ();
size += m_erpInformation.GetSerializedSize ();
if (m_erpInformation.has_value ()) size += m_erpInformation->GetSerializedSize ();
size += m_rates.extended.GetSerializedSize ();
size += m_edcaParameterSet.GetSerializedSize ();
size += m_extendedCapability.GetSerializedSize ();
@@ -1576,9 +1576,9 @@ MgtAssocResponseHeader::Print (std::ostream &os) const
{
os << "status code=" << m_code << ", "
<< "aid=" << m_aid << ", "
<< "rates=" << m_rates << ", "
<< "ERP information=" << m_erpInformation << ", "
<< "Extended Capabilities=" << m_extendedCapability << " , ";
<< "rates=" << m_rates << ", ";
if (m_erpInformation.has_value ()) os << "ERP information=" << *m_erpInformation << ", ";
os << "Extended Capabilities=" << m_extendedCapability << " , ";
if (m_htCapability.has_value ()) os << "HT Capabilities=" << *m_htCapability << " , ";
if (m_htOperation.has_value ()) os << "HT Operation=" << *m_htOperation << " , ";
if (m_vhtCapability.has_value ()) os << "VHT Capabilities=" << *m_vhtCapability << " , ";
@@ -1596,7 +1596,7 @@ MgtAssocResponseHeader::Serialize (Buffer::Iterator start) const
i = m_code.Serialize (i);
i.WriteHtolsbU16 (m_aid);
i = m_rates.Serialize (i);
i = m_erpInformation.Serialize (i);
if (m_erpInformation.has_value ()) i = m_erpInformation->Serialize (i);
i = m_rates.extended.Serialize (i);
i = m_edcaParameterSet.Serialize (i);
i = m_extendedCapability.Serialize (i);
@@ -1619,7 +1619,7 @@ MgtAssocResponseHeader::Deserialize (Buffer::Iterator start)
i = m_code.Deserialize (i);
m_aid = i.ReadLsbtohU16 ();
i = m_rates.Deserialize (i);
i = m_erpInformation.DeserializeIfPresent (i);
i = WifiInformationElement::DeserializeIfPresent (m_erpInformation, i);
i = m_rates.extended.DeserializeIfPresent (i);
i = m_edcaParameterSet.DeserializeIfPresent (i);
i = m_extendedCapability.DeserializeIfPresent (i);

View File

@@ -528,11 +528,11 @@ public:
*/
uint16_t GetAssociationId (void) const;
/**
* Return the ERP information.
* Return the ERP information, if present.
*
* \return the ERP information
* \return the ERP information, if present
*/
const ErpInformation& GetErpInformation (void) const;
const std::optional<ErpInformation>& GetErpInformation (void) const;
/**
* Return the EDCA Parameter Set.
*
@@ -718,7 +718,7 @@ private:
std::optional<HtOperation> m_htOperation; //!< HT operation
std::optional<VhtCapabilities> m_vhtCapability; //!< VHT capabilities
std::optional<VhtOperation> m_vhtOperation; //!< VHT operation
ErpInformation m_erpInformation; //!< ERP information
std::optional<ErpInformation> m_erpInformation; //!< ERP information
EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set
std::optional<HeCapabilities> m_heCapability; //!< HE capabilities
std::optional<HeOperation> m_heOperation; //!< HE operation
@@ -968,11 +968,11 @@ public:
*/
const std::optional<EhtCapabilities>& GetEhtCapabilities (void) const;
/**
* Return the ERP information.
* Return the ERP information, if present.
*
* \return the ERP information
* \return the ERP information, if present
*/
const ErpInformation& GetErpInformation (void) const;
const std::optional<ErpInformation>& GetErpInformation (void) const;
/**
* Return the EDCA Parameter Set.
*
@@ -1202,7 +1202,7 @@ private:
std::optional<VhtOperation> m_vhtOperation; //!< VHT operation
std::optional<HeCapabilities> m_heCapability; //!< HE capabilities
std::optional<HeOperation> m_heOperation; //!< HE operation
ErpInformation m_erpInformation; //!< ERP information
std::optional<ErpInformation> m_erpInformation; //!< ERP information
EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set
MuEdcaParameterSet m_muEdcaParameterSet; //!< MU EDCA Parameter Set
std::optional<EhtCapabilities> m_ehtCapability; //!< EHT capabilities

View File

@@ -23,8 +23,7 @@
namespace ns3 {
ErpInformation::ErpInformation ()
: m_erpInformation (0),
m_erpSupported (0)
: m_erpInformation (0)
{
}
@@ -34,12 +33,6 @@ ErpInformation::ElementId () const
return IE_ERP_INFORMATION;
}
void
ErpInformation::SetErpSupported (uint8_t erpSupported)
{
m_erpSupported = erpSupported;
}
void
ErpInformation::SetBarkerPreambleMode (uint8_t barkerPreambleMode)
{
@@ -79,37 +72,13 @@ ErpInformation::GetNonErpPresent (void) const
uint8_t
ErpInformation::GetInformationFieldSize () const
{
NS_ASSERT (m_erpSupported);
return 1;
}
Buffer::Iterator
ErpInformation::Serialize (Buffer::Iterator i) const
{
if (!m_erpSupported)
{
return i;
}
return WifiInformationElement::Serialize (i);
}
uint16_t
ErpInformation::GetSerializedSize () const
{
if (!m_erpSupported)
{
return 0;
}
return WifiInformationElement::GetSerializedSize ();
}
void
ErpInformation::SerializeInformationField (Buffer::Iterator start) const
{
if (m_erpSupported)
{
start.WriteU8 (m_erpInformation);
}
start.WriteU8 (m_erpInformation);
}
uint8_t

View File

@@ -43,20 +43,6 @@ public:
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 an ERP 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 ERP supported field.
*
* \param erpSupported the ERP supported field in the ErpInformation information element
*/
void SetErpSupported (uint8_t erpSupported);
/**
* Set the Barker_Preamble_Mode field in the ErpInformation information element.
*
@@ -98,9 +84,6 @@ public:
private:
uint8_t m_erpInformation; ///< ERP information
/// This is used to decide whether this element should be added to the frame or not
bool m_erpSupported;
};
/**

View File

@@ -1070,11 +1070,11 @@ StaWifiMac::UpdateApInfo (const MgtFrameType& frame, const Mac48Address& apAddr,
}
bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
if (GetErpSupported (linkId))
if (const auto& erpInformation = frame.GetErpInformation ();
erpInformation.has_value () && GetErpSupported (linkId))
{
const ErpInformation& erpInformation = frame.GetErpInformation ();
isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
if (erpInformation.GetUseProtection () != 0)
isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode ();
if (erpInformation->GetUseProtection () != 0)
{
GetWifiRemoteStationManager (linkId)->SetUseNonErpProtection (true);
}