wifi: Information Elements should define Print() instead of ostream operator

This commit is contained in:
Stefano Avallone
2023-03-24 18:49:19 +01:00
committed by Stefano Avallone
parent 747b1bf94e
commit e74ffdff6d
24 changed files with 147 additions and 251 deletions

View File

@@ -423,6 +423,12 @@ EhtCapabilities::ElementIdExt() const
return IE_EXT_EHT_CAPABILITIES;
}
void
EhtCapabilities::Print(std::ostream& os) const
{
os << "EHT Capabilities="; // TODO
}
uint16_t
EhtCapabilities::GetInformationFieldSize() const
{
@@ -726,11 +732,4 @@ EhtCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16_t le
return count;
}
std::ostream&
operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities)
{
// TODO
return os;
}
} // namespace ns3

View File

@@ -261,6 +261,7 @@ class EhtCapabilities : public WifiInformationElement
// Implementations of pure virtual methods, or overridden from base class.
WifiInformationElementId ElementId() const override;
WifiInformationElementId ElementIdExt() const override;
void Print(std::ostream& os) const override;
/**
* Set the maximum MPDU length.
@@ -347,22 +348,12 @@ class EhtCapabilities : public WifiInformationElement
void SerializeInformationField(Buffer::Iterator start) const override;
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
friend std::ostream& operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities);
bool m_is2_4Ghz; //!< flag indicating whether PHY is operating in 2.4 GHz based on other IEs
//!< contained in the same management frame
std::optional<HeCapabilities>
m_heCapabilities; //!< HE capabilities contained in the same management frame if present
};
/**
* output stream output operator
* \param os the output stream
* \param ehtCapabilities the EHT capabilities
* \returns the output stream
*/
std::ostream& operator<<(std::ostream& os, const EhtCapabilities& ehtCapabilities);
} // namespace ns3
#endif /* EHT_CAPABILITIES_H */

View File

@@ -27,6 +27,33 @@
namespace ns3
{
void
EhtOperation::Print(std::ostream& os) const
{
os << "EHT Operation=" << +m_params.opInfoPresent << "|" << +m_params.disabledSubchBmPresent
<< "|" << +m_params.defaultPeDur << "|" << +m_params.grpBuIndLimit << "|"
<< +m_params.grpBuExp << "|[";
for (const auto& maxRxNss : m_mcsNssSet.maxRxNss)
{
os << +maxRxNss << "|";
}
os << "]|[";
for (const auto& maxTxNss : m_mcsNssSet.maxTxNss)
{
os << +maxTxNss << "|";
}
os << "]";
if (m_opInfo.has_value())
{
os << "|" << +m_opInfo->control.channelWidth << "|" << +m_opInfo->ccfs0 << "|"
<< +m_opInfo->ccfs1;
if (m_opInfo->disabledSubchBm.has_value())
{
os << "|" << m_opInfo->disabledSubchBm.value();
}
}
}
void
EhtOperation::EhtOpParams::Serialize(Buffer::Iterator& start) const
{
@@ -260,34 +287,4 @@ EhtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t lengt
<< +count << ")");
return length;
}
std::ostream&
operator<<(std::ostream& os, const EhtOperation& ehtOperation)
{
os << +ehtOperation.m_params.opInfoPresent << "|"
<< +ehtOperation.m_params.disabledSubchBmPresent << "|"
<< +ehtOperation.m_params.defaultPeDur << "|" << +ehtOperation.m_params.grpBuIndLimit << "|"
<< +ehtOperation.m_params.grpBuExp << "|[";
for (const auto& maxRxNss : ehtOperation.m_mcsNssSet.maxRxNss)
{
os << +maxRxNss << "|";
}
os << "]|[";
for (const auto& maxTxNss : ehtOperation.m_mcsNssSet.maxTxNss)
{
os << +maxTxNss << "|";
}
os << "]";
if (ehtOperation.m_opInfo.has_value())
{
os << "|" << +ehtOperation.m_opInfo->control.channelWidth << "|"
<< +ehtOperation.m_opInfo->ccfs0 << "|" << +ehtOperation.m_opInfo->ccfs1;
if (ehtOperation.m_opInfo->disabledSubchBm.has_value())
{
os << "|" << ehtOperation.m_opInfo->disabledSubchBm.value();
}
}
return os;
}
} // namespace ns3

View File

@@ -161,6 +161,7 @@ class EhtOperation : public WifiInformationElement
EhtOperation();
WifiInformationElementId ElementId() const override;
WifiInformationElementId ElementIdExt() const override;
void Print(std::ostream& os) const override;
/**
* Set the max Rx NSS for input MCS index range
@@ -187,16 +188,6 @@ class EhtOperation : public WifiInformationElement
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
};
/**
* output stream output operator
*
* \param os output stream
* \param ehtOperation the EHT operation
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const EhtOperation& ehtOperation);
} // namespace ns3
#endif /* EHT_OPERATION_H */

View File

@@ -91,6 +91,12 @@ ExtendedCapabilities::ElementId() const
return IE_EXTENDED_CAPABILITIES;
}
void
ExtendedCapabilities::Print(std::ostream& os) const
{
os << "Extended Capabilities=" << +GetExtendedCapabilitiesByte1();
}
void
ExtendedCapabilities::SetHtSupported(uint8_t htSupported)
{
@@ -373,11 +379,4 @@ ExtendedCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16
return length;
}
std::ostream&
operator<<(std::ostream& os, const ExtendedCapabilities& extendedCapabilities)
{
os << +extendedCapabilities.GetExtendedCapabilitiesByte1();
return os;
}
} // namespace ns3

View File

@@ -41,6 +41,7 @@ class ExtendedCapabilities : public WifiInformationElement
uint16_t GetInformationFieldSize() const override;
void SerializeInformationField(Buffer::Iterator start) const override;
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
void Print(std::ostream& os) const override;
/**
* Set the HT Supported flag.
*
@@ -226,16 +227,6 @@ class ExtendedCapabilities : public WifiInformationElement
///< element should be added to the frame or not
};
/**
* output stream output operator
*
* \param os output stream
* \param extendedCapabilities the extended capabilities
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const ExtendedCapabilities& extendedCapabilities);
} // namespace ns3
#endif /* EXTENDED_CAPABILITIES_H */

View File

@@ -136,6 +136,14 @@ HeCapabilities::ElementIdExt() const
return IE_EXT_HE_CAPABILITIES;
}
void
HeCapabilities::Print(std::ostream& os) const
{
os << "HE Capabilities=" << GetHeMacCapabilitiesInfo1() << "|" << +GetHeMacCapabilitiesInfo2()
<< "|" << GetHePhyCapabilitiesInfo1() << "|" << GetHePhyCapabilitiesInfo2() << "|"
<< +GetHePhyCapabilitiesInfo3() << "|" << GetSupportedMcsAndNss();
}
uint16_t
HeCapabilities::GetInformationFieldSize() const
{
@@ -609,16 +617,4 @@ HeCapabilities::GetMaxAmpduLength() const
return std::min<uint32_t>((1UL << (20 + m_maxAmpduLengthExponent)) - 1, 6500631);
}
std::ostream&
operator<<(std::ostream& os, const HeCapabilities& heCapabilities)
{
os << heCapabilities.GetHeMacCapabilitiesInfo1() << "|"
<< +heCapabilities.GetHeMacCapabilitiesInfo2() << "|"
<< heCapabilities.GetHePhyCapabilitiesInfo1() << "|"
<< heCapabilities.GetHePhyCapabilitiesInfo2() << "|"
<< +heCapabilities.GetHePhyCapabilitiesInfo3() << "|"
<< heCapabilities.GetSupportedMcsAndNss();
return os;
}
} // namespace ns3

View File

@@ -38,6 +38,7 @@ class HeCapabilities : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
WifiInformationElementId ElementIdExt() const override;
void Print(std::ostream& os) const override;
/**
* Set the HE MAC Capabilities Info field in the HE Capabilities information element.
@@ -333,14 +334,6 @@ class HeCapabilities : public WifiInformationElement
std::vector<uint8_t> m_rxBwMap; //!< receive BW map
};
/**
* output stream output operator
* \param os the output stream
* \param heCapabilities the HE capabilities
* \returns the output stream
*/
std::ostream& operator<<(std::ostream& os, const HeCapabilities& heCapabilities);
} // namespace ns3
#endif /* HE_CAPABILITY_H */

View File

@@ -48,6 +48,12 @@ HeOperation::ElementIdExt() const
return IE_EXT_HE_OPERATION;
}
void
HeOperation::Print(std::ostream& os) const
{
os << "HE Operation=" << GetHeOperationParameters() << "|" << GetBasicHeMcsAndNssSet();
}
uint16_t
HeOperation::GetInformationFieldSize() const
{
@@ -152,11 +158,4 @@ HeOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t length
return length;
}
std::ostream&
operator<<(std::ostream& os, const HeOperation& HeOperation)
{
os << HeOperation.GetHeOperationParameters() << "|" << HeOperation.GetBasicHeMcsAndNssSet();
return os;
}
} // namespace ns3

View File

@@ -40,6 +40,7 @@ class HeOperation : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
WifiInformationElementId ElementIdExt() const override;
void Print(std::ostream& os) const override;
/**
* Set the HE Operation Parameters field in the HE Operation information element.
@@ -101,16 +102,6 @@ class HeOperation : public WifiInformationElement
// TODO: VHT Operation Information subfields not defined in the standard yet.
};
/**
* output stream output operator
*
* \param os output stream
* \param HeOperation the HE operation
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const HeOperation& HeOperation);
} // namespace ns3
#endif /* HE_OPERATION_H */

View File

@@ -97,6 +97,17 @@ HtCapabilities::ElementId() const
return IE_HT_CAPABILITIES;
}
void
HtCapabilities::Print(std::ostream& os) const
{
os << "HT Capabilities=" << bool(GetLdpc()) << "|" << bool(GetSupportedChannelWidth()) << "|"
<< bool(GetShortGuardInterval20()) << "|";
for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
{
os << IsSupportedMcs(i) << " ";
}
}
void
HtCapabilities::SetLdpc(uint8_t ldpc)
{
@@ -506,16 +517,4 @@ HtCapabilities::DeserializeInformationField(Buffer::Iterator start, uint16_t len
return length;
}
std::ostream&
operator<<(std::ostream& os, const HtCapabilities& htcapabilities)
{
os << bool(htcapabilities.GetLdpc()) << "|" << bool(htcapabilities.GetSupportedChannelWidth())
<< "|" << bool(htcapabilities.GetShortGuardInterval20()) << "|";
for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
{
os << htcapabilities.IsSupportedMcs(i) << " ";
}
return os;
}
} // namespace ns3

View File

@@ -271,6 +271,7 @@ class HtCapabilities : public WifiInformationElement
uint16_t GetInformationFieldSize() const override;
void SerializeInformationField(Buffer::Iterator start) const override;
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
void Print(std::ostream& os) const override;
// HT Capabilities Info field
uint8_t m_ldpc; ///< LDPC
@@ -350,16 +351,6 @@ class HtCapabilities : public WifiInformationElement
uint8_t m_reservedASel; ///< reserved ASEL
};
/**
* output stream output operator
*
* \param os output stream
* \param htcapabilities the HT capabilities
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const HtCapabilities& htcapabilities);
} // namespace ns3
#endif /* HT_CAPABILITY_H */

View File

@@ -62,6 +62,23 @@ HtOperation::ElementId() const
return IE_HT_OPERATION;
}
void
HtOperation::Print(std::ostream& os) const
{
os << "HT Operation=" << bool(GetPrimaryChannel()) << "|" << +GetSecondaryChannelOffset() << "|"
<< bool(GetStaChannelWidth()) << "|" << bool(GetRifsMode()) << "|" << +GetHtProtection()
<< "|" << bool(GetNonGfHtStasPresent()) << "|" << bool(GetObssNonHtStasPresent()) << "|"
<< bool(GetDualBeacon()) << "|" << bool(GetDualCtsProtection()) << "|"
<< bool(GetStbcBeacon()) << "|" << bool(GetLSigTxopProtectionFullSupport()) << "|"
<< bool(GetPcoActive()) << "|" << bool(GetPhase()) << "|" << GetRxHighestSupportedDataRate()
<< "|" << bool(GetTxMcsSetDefined()) << "|" << bool(GetTxRxMcsSetUnequal()) << "|"
<< +GetTxMaxNSpatialStreams() << "|" << bool(GetTxUnequalModulation()) << "|";
for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
{
os << IsSupportedMcs(i) << " ";
}
}
uint16_t
HtOperation::GetInformationFieldSize() const
{
@@ -456,26 +473,4 @@ HtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t length
return length;
}
std::ostream&
operator<<(std::ostream& os, const HtOperation& htOperation)
{
os << bool(htOperation.GetPrimaryChannel()) << "|" << +htOperation.GetSecondaryChannelOffset()
<< "|" << bool(htOperation.GetStaChannelWidth()) << "|" << bool(htOperation.GetRifsMode())
<< "|" << +htOperation.GetHtProtection() << "|" << bool(htOperation.GetNonGfHtStasPresent())
<< "|" << bool(htOperation.GetObssNonHtStasPresent()) << "|"
<< bool(htOperation.GetDualBeacon()) << "|" << bool(htOperation.GetDualCtsProtection())
<< "|" << bool(htOperation.GetStbcBeacon()) << "|"
<< bool(htOperation.GetLSigTxopProtectionFullSupport()) << "|"
<< bool(htOperation.GetPcoActive()) << "|" << bool(htOperation.GetPhase()) << "|"
<< htOperation.GetRxHighestSupportedDataRate() << "|"
<< bool(htOperation.GetTxMcsSetDefined()) << "|" << bool(htOperation.GetTxRxMcsSetUnequal())
<< "|" << +htOperation.GetTxMaxNSpatialStreams() << "|"
<< bool(htOperation.GetTxUnequalModulation()) << "|";
for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
{
os << htOperation.IsSupportedMcs(i) << " ";
}
return os;
}
} // namespace ns3

View File

@@ -54,6 +54,7 @@ class HtOperation : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
void Print(std::ostream& os) const override;
/**
* Set the Primary Channel field in the HT Operation information element.
@@ -394,16 +395,6 @@ class HtOperation : public WifiInformationElement
uint8_t m_rxMcsBitmask[MAX_SUPPORTED_MCS]; ///< receive MCS bitmask
};
/**
* output stream output operator
*
* \param os output stream
* \param htOperation the HT operation
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const HtOperation& htOperation);
} // namespace ns3
#endif /* HT_OPERATION_H */

View File

@@ -51,6 +51,12 @@ Ssid::Ssid(std::string s)
}
}
void
Ssid::Print(std::ostream& os) const
{
os << "ssid=" << PeekString();
}
bool
Ssid::IsEqual(const Ssid& o) const
{
@@ -114,13 +120,6 @@ Ssid::DeserializeInformationField(Buffer::Iterator start, uint16_t length)
ATTRIBUTE_HELPER_CPP(Ssid);
std::ostream&
operator<<(std::ostream& os, const Ssid& ssid)
{
os << ssid.PeekString();
return os;
}
std::istream&
operator>>(std::istream& is, Ssid& ssid)
{

View File

@@ -48,6 +48,7 @@ class Ssid : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
void Print(std::ostream& os) const override;
/**
* Check if the two SSIDs are equal.
@@ -82,15 +83,6 @@ class Ssid : public WifiInformationElement
uint8_t m_length; //!< Length of the SSID
};
/**
* Serialize SSID to the given ostream
*
* \param os the output stream
* \param ssid the SSID
*
* \return std::ostream
*/
std::ostream& operator<<(std::ostream& os, const Ssid& ssid);
/**
* Serialize from the given istream to this SSID.
*

View File

@@ -57,6 +57,26 @@ SupportedRates::operator=(const SupportedRates& rates)
return (*this);
}
void
SupportedRates::Print(std::ostream& os) const
{
os << "rates=[";
for (uint8_t i = 0; i < GetNRates(); i++)
{
uint32_t rate = GetRate(i);
if (IsBasicRate(rate))
{
os << "*";
}
os << rate / 1000000 << "mbs";
if (i < GetNRates() - 1)
{
os << " ";
}
}
os << "]";
}
void
SupportedRates::AddSupportedRate(uint64_t bs)
{
@@ -258,25 +278,4 @@ ExtendedSupportedRatesIE::DeserializeInformationField(Buffer::Iterator start, ui
return length;
}
std::ostream&
operator<<(std::ostream& os, const SupportedRates& rates)
{
os << "[";
for (uint8_t i = 0; i < rates.GetNRates(); i++)
{
uint32_t rate = rates.GetRate(i);
if (rates.IsBasicRate(rate))
{
os << "*";
}
os << rate / 1000000 << "mbs";
if (i < rates.GetNRates() - 1)
{
os << " ";
}
}
os << "]";
return os;
}
} // namespace ns3

View File

@@ -98,6 +98,7 @@ class SupportedRates : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
void Print(std::ostream& os) const override;
/**
* Assignment operator
@@ -198,16 +199,6 @@ class SupportedRates : public WifiInformationElement
uint8_t m_rates[MAX_SUPPORTED_RATES]; //!< List of supported bit rates (divided by 500000)
};
/**
* Serialize SupportedRates to the given ostream.
*
* \param os output stream
* \param rates the SupportedRates
*
* \return std::ostream
*/
std::ostream& operator<<(std::ostream& os, const SupportedRates& rates);
} // namespace ns3
#endif /* SUPPORTED_RATES_H */

View File

@@ -63,6 +63,12 @@ VhtCapabilities::ElementId() const
return IE_VHT_CAPABILITIES;
}
void
VhtCapabilities::Print(std::ostream& os) const
{
os << "VHT Capabilities=" << GetVhtCapabilitiesInfo() << "|" << GetSupportedMcsAndNssSet();
}
uint16_t
VhtCapabilities::GetInformationFieldSize() const
{
@@ -384,13 +390,4 @@ VhtCapabilities::GetRxHighestSupportedLgiDataRate() const
return m_rxHighestSupportedLongGuardIntervalDataRate;
}
std::ostream&
operator<<(std::ostream& os, const VhtCapabilities& vhtCapabilities)
{
os << vhtCapabilities.GetVhtCapabilitiesInfo() << "|"
<< vhtCapabilities.GetSupportedMcsAndNssSet();
return os;
}
} // namespace ns3

View File

@@ -38,6 +38,7 @@ class VhtCapabilities : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
void Print(std::ostream& os) const override;
/**
* Set the VHT Capabilities Info field in the VHT Capabilities information element.
@@ -241,16 +242,6 @@ class VhtCapabilities : public WifiInformationElement
///< guard interval data rate
};
/**
* output stream output operator
*
* \param os the output stream
* \param vhtCapabilities the VHT capabilities
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const VhtCapabilities& vhtCapabilities);
} // namespace ns3
#endif /* VHT_CAPABILITY_H */

View File

@@ -36,6 +36,13 @@ VhtOperation::ElementId() const
return IE_VHT_OPERATION;
}
void
VhtOperation::Print(std::ostream& os) const
{
os << "VHT Operation=" << +GetChannelWidth() << "|" << +GetChannelCenterFrequencySegment0()
<< "|" << +GetChannelCenterFrequencySegment1() << "|" << GetBasicVhtMcsAndNssSet();
}
uint16_t
VhtOperation::GetInformationFieldSize() const
{
@@ -129,14 +136,4 @@ VhtOperation::DeserializeInformationField(Buffer::Iterator start, uint16_t lengt
return length;
}
std::ostream&
operator<<(std::ostream& os, const VhtOperation& VhtOperation)
{
os << +VhtOperation.GetChannelWidth() << "|"
<< +VhtOperation.GetChannelCenterFrequencySegment0() << "|"
<< +VhtOperation.GetChannelCenterFrequencySegment1() << "|"
<< VhtOperation.GetBasicVhtMcsAndNssSet();
return os;
}
} // namespace ns3

View File

@@ -39,6 +39,7 @@ class VhtOperation : public WifiInformationElement
// Implementations of pure virtual methods of WifiInformationElement
WifiInformationElementId ElementId() const override;
void Print(std::ostream& os) const override;
/**
* Set the Channel Width field in the VHT Operation information element.
@@ -115,16 +116,6 @@ class VhtOperation : public WifiInformationElement
uint16_t m_basicVhtMcsAndNssSet; ///< basic VHT MCS NSS set
};
/**
* output stream output operator
*
* \param os the output stream
* \param VhtOperation the VHT operation
*
* \returns output stream
*/
std::ostream& operator<<(std::ostream& os, const VhtOperation& VhtOperation);
} // namespace ns3
#endif /* VHT_OPERATION_H */

View File

@@ -261,4 +261,11 @@ WifiInformationElement::operator==(const WifiInformationElement& a) const
return (memcmp(myIe.PeekData(), hisIe.PeekData(), ieSize) == 0);
}
std::ostream&
operator<<(std::ostream& os, const WifiInformationElement& element)
{
element.Print(os);
return os;
}
} // namespace ns3

View File

@@ -423,6 +423,15 @@ class WifiInformationElement : public SimpleRefCount<WifiInformationElement>
virtual uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) = 0;
};
/**
* \brief Stream insertion operator.
*
* \param os the output stream
* \param element the Information Element
* \returns a reference to the stream
*/
std::ostream& operator<<(std::ostream& os, const WifiInformationElement& element);
} // namespace ns3
/***************************************************************