From e9da125f90ce2889173cff85c753b3d7d2eb2028 Mon Sep 17 00:00:00 2001 From: Rediet Date: Tue, 24 Nov 2020 15:31:50 +0100 Subject: [PATCH] wifi: Use pointer to print PPDU's content So as to be able to call overridden implementations of PrintPayload --- src/wifi/model/he-ppdu.cc | 2 +- src/wifi/model/wifi-phy.cc | 6 +++--- src/wifi/model/wifi-ppdu.cc | 19 +++++++++++++------ src/wifi/model/wifi-ppdu.h | 13 +++++++++++-- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/wifi/model/he-ppdu.cc b/src/wifi/model/he-ppdu.cc index 5cbb29dea..ce4b264fa 100644 --- a/src/wifi/model/he-ppdu.cc +++ b/src/wifi/model/he-ppdu.cc @@ -224,7 +224,7 @@ HePpdu::PrintPayload (void) const } else { - ss << "PSDU=" << m_psdus.at (SU_STA_ID); + ss << "PSDU=" << m_psdus.at (SU_STA_ID) << " "; } return ss.str (); } diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index cd696186d..e4f641f0f 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2419,7 +2419,7 @@ WifiPhy::StartReceivePreamble (Ptr ppdu, RxPowerWattPerChannelBand rxP [] (const std::pair& p1, const std::pair& p2) { return p1.second < p2.second; }); - NS_LOG_FUNCTION (this << *ppdu << it->second); + NS_LOG_FUNCTION (this << ppdu << it->second); WifiTxVector txVector = ppdu->GetTxVector (); Time rxDuration = ppdu->GetTxDuration (); @@ -2577,7 +2577,7 @@ WifiPhy::StartReceivePreamble (Ptr ppdu, RxPowerWattPerChannelBand rxP void WifiPhy::DropPreambleEvent (Ptr ppdu, WifiPhyRxfailureReason reason, Time endRx, uint16_t measurementChannelWidth) { - NS_LOG_FUNCTION (this << *ppdu << reason << endRx << measurementChannelWidth); + NS_LOG_FUNCTION (this << ppdu << reason << endRx << measurementChannelWidth); NotifyRxDrop (GetAddressedPsduInPpdu (ppdu), reason); auto it = m_currentPreambleEvents.find (std::make_pair (ppdu->GetUid (), ppdu->GetPreamble ())); if (it != m_currentPreambleEvents.end ()) @@ -2615,7 +2615,7 @@ WifiPhy::StartReceiveOfdmaPayload (Ptr event) [] (const std::pair& p1, const std::pair& p2) { return p1.second < p2.second; }); - NS_LOG_FUNCTION (this << event << *ppdu << it->second); + NS_LOG_FUNCTION (this << event << ppdu << it->second); NS_ASSERT (m_currentEvent != 0); auto itEvent = m_beginOfdmaPayloadRxEvents.find (GetStaId (ppdu)); /** diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index 7ee03c16a..734775223 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -132,18 +132,19 @@ WifiPpdu::GetTxDuration (void) const void WifiPpdu::Print (std::ostream& os) const { - os << "preamble=" << m_preamble + os << "[ preamble=" << m_preamble << ", modulation=" << m_modulation << ", truncatedTx=" << (m_truncatedTx ? "Y" : "N") - << ", uid=" << m_uid - << "," << PrintPayload (); + << ", UID=" << m_uid + << ", " << PrintPayload () + << "]"; } std::string WifiPpdu::PrintPayload (void) const { std::ostringstream ss; - ss << "PSDU=" << GetPsdu (); + ss << "PSDU=" << GetPsdu () << " "; return ss.str (); } @@ -154,9 +155,15 @@ WifiPpdu::Copy (void) const return Create (GetPsdu (), GetTxVector ()); } -std::ostream & operator << (std::ostream &os, const WifiPpdu &ppdu) +std::ostream & operator << (std::ostream &os, const Ptr &ppdu) { - ppdu.Print (os); + ppdu->Print (os); + return os; +} + +std::ostream & operator << (std::ostream &os, const Ptr &ppdu) +{ + ppdu->Print (os); return os; } diff --git a/src/wifi/model/wifi-ppdu.h b/src/wifi/model/wifi-ppdu.h index 7e9a2d48a..82992c241 100644 --- a/src/wifi/model/wifi-ppdu.h +++ b/src/wifi/model/wifi-ppdu.h @@ -177,10 +177,19 @@ private: * \brief Stream insertion operator. * * \param os the stream - * \param ppdu the PPDU + * \param ppdu the const pointer to the PPDU * \returns a reference to the stream */ -std::ostream& operator<< (std::ostream& os, const WifiPpdu &ppdu); +std::ostream& operator<< (std::ostream& os, const Ptr &ppdu); + +/** + * \brief Stream insertion operator. + * + * \param os the stream + * \param ppdu the pointer to the PPDU + * \returns a reference to the stream + */ +std::ostream& operator<< (std::ostream& os, const Ptr &ppdu); /** * \brief Stream insertion operator.