From 7179427b4994c8ee36b825cb0409711122aca0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 28 Nov 2022 18:55:44 +0100 Subject: [PATCH] wifi: Move setting of PHY headers in a seperate function for all WifiPpdu child classes --- src/wifi/model/ht/ht-ppdu.cc | 9 ++++++++- src/wifi/model/ht/ht-ppdu.h | 9 +++++++++ src/wifi/model/non-ht/dsss-ppdu.cc | 7 +++++++ src/wifi/model/non-ht/dsss-ppdu.h | 8 ++++++++ src/wifi/model/non-ht/ofdm-ppdu.cc | 11 +++++++++-- src/wifi/model/non-ht/ofdm-ppdu.h | 8 ++++++++ src/wifi/model/vht/vht-ppdu.cc | 7 +++++++ src/wifi/model/vht/vht-ppdu.h | 8 ++++++++ 8 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/wifi/model/ht/ht-ppdu.cc b/src/wifi/model/ht/ht-ppdu.cc index f45c1e13a..5b43ccf75 100644 --- a/src/wifi/model/ht/ht-ppdu.cc +++ b/src/wifi/model/ht/ht-ppdu.cc @@ -47,6 +47,13 @@ HtPpdu::HtPpdu(Ptr psdu, false) // don't instantiate LSigHeader of OfdmPpdu { NS_LOG_FUNCTION(this << psdu << txVector << txCenterFreq << ppduDuration << band << uid); + SetPhyHeaders(txVector, ppduDuration, psdu->GetSize()); +} + +void +HtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration, std::size_t psduSize) +{ + NS_LOG_FUNCTION(this << txVector << ppduDuration << psduSize); uint8_t sigExtension = 0; if (m_band == WIFI_PHY_BAND_2_4GHZ) { @@ -61,7 +68,7 @@ HtPpdu::HtPpdu(Ptr psdu, m_lSig.SetLength(length); m_htSig.SetMcs(txVector.GetMode().GetMcsValue()); m_htSig.SetChannelWidth(m_channelWidth); - m_htSig.SetHtLength(psdu->GetSize()); + m_htSig.SetHtLength(psduSize); m_htSig.SetAggregation(txVector.IsAggregation()); m_htSig.SetShortGuardInterval(txVector.GetGuardInterval() == 400); } diff --git a/src/wifi/model/ht/ht-ppdu.h b/src/wifi/model/ht/ht-ppdu.h index a96603696..bd02bc0bb 100644 --- a/src/wifi/model/ht/ht-ppdu.h +++ b/src/wifi/model/ht/ht-ppdu.h @@ -157,6 +157,15 @@ class HtPpdu : public OfdmPpdu private: WifiTxVector DoGetTxVector() const override; + /** + * Fill in the PHY headers. + * + * \param txVector the TXVECTOR that was used for this PPDU + * \param ppduDuration the transmission duration of this PPDU + * \param psduSize the size duration of the PHY payload (PSDU) + */ + void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration, std::size_t psduSize); + HtSigHeader m_htSig; //!< the HT-SIG PHY header }; // class HtPpdu diff --git a/src/wifi/model/non-ht/dsss-ppdu.cc b/src/wifi/model/non-ht/dsss-ppdu.cc index 41b2abf55..549e874c9 100644 --- a/src/wifi/model/non-ht/dsss-ppdu.cc +++ b/src/wifi/model/non-ht/dsss-ppdu.cc @@ -40,6 +40,13 @@ DsssPpdu::DsssPpdu(Ptr psdu, : WifiPpdu(psdu, txVector, txCenterFreq, uid) { NS_LOG_FUNCTION(this << psdu << txVector << txCenterFreq << ppduDuration << uid); + SetPhyHeaders(txVector, ppduDuration); +} + +void +DsssPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration) +{ + NS_LOG_FUNCTION(this << txVector << ppduDuration); m_dsssSig.SetRate(txVector.GetMode().GetDataRate(22)); Time psduDuration = ppduDuration - WifiPhy::CalculatePhyPreambleAndHeaderDuration(txVector); m_dsssSig.SetLength(psduDuration.GetMicroSeconds()); diff --git a/src/wifi/model/non-ht/dsss-ppdu.h b/src/wifi/model/non-ht/dsss-ppdu.h index 4d1db2a13..b9a4b63ac 100644 --- a/src/wifi/model/non-ht/dsss-ppdu.h +++ b/src/wifi/model/non-ht/dsss-ppdu.h @@ -117,6 +117,14 @@ class DsssPpdu : public WifiPpdu private: WifiTxVector DoGetTxVector() const override; + /** + * Fill in the PHY headers. + * + * \param txVector the TXVECTOR that was used for this PPDU + * \param ppduDuration the transmission duration of this PPDU + */ + void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); + DsssSigHeader m_dsssSig; //!< the DSSS SIG PHY header }; // class DsssPpdu diff --git a/src/wifi/model/non-ht/ofdm-ppdu.cc b/src/wifi/model/non-ht/ofdm-ppdu.cc index 84c2e82bc..1c0f56b51 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.cc +++ b/src/wifi/model/non-ht/ofdm-ppdu.cc @@ -45,11 +45,18 @@ OfdmPpdu::OfdmPpdu(Ptr psdu, NS_LOG_FUNCTION(this << psdu << txVector << txCenterFreq << band << uid); if (instantiateLSig) { - m_lSig.SetRate(txVector.GetMode().GetDataRate(txVector), m_channelWidth); - m_lSig.SetLength(psdu->GetSize()); + SetPhyHeaders(txVector, psdu->GetSize()); } } +void +OfdmPpdu::SetPhyHeaders(const WifiTxVector& txVector, std::size_t psduSize) +{ + NS_LOG_FUNCTION(this << txVector << psduSize); + m_lSig.SetRate(txVector.GetMode().GetDataRate(txVector), m_channelWidth); + m_lSig.SetLength(psduSize); +} + WifiTxVector OfdmPpdu::DoGetTxVector() const { diff --git a/src/wifi/model/non-ht/ofdm-ppdu.h b/src/wifi/model/non-ht/ofdm-ppdu.h index eada5fad5..413fd9800 100644 --- a/src/wifi/model/non-ht/ofdm-ppdu.h +++ b/src/wifi/model/non-ht/ofdm-ppdu.h @@ -128,6 +128,14 @@ class OfdmPpdu : public WifiPpdu private: WifiTxVector DoGetTxVector() const override; + + /** + * Fill in the PHY headers. + * + * \param txVector the TXVECTOR that was used for this PPDU + * \param psduSize the size duration of the PHY payload (PSDU) + */ + void SetPhyHeaders(const WifiTxVector& txVector, std::size_t psduSize); }; // class OfdmPpdu } // namespace ns3 diff --git a/src/wifi/model/vht/vht-ppdu.cc b/src/wifi/model/vht/vht-ppdu.cc index 9b014a7bc..c2a2e5a59 100644 --- a/src/wifi/model/vht/vht-ppdu.cc +++ b/src/wifi/model/vht/vht-ppdu.cc @@ -46,6 +46,13 @@ VhtPpdu::VhtPpdu(Ptr psdu, false) // don't instantiate LSigHeader of OfdmPpdu { NS_LOG_FUNCTION(this << psdu << txVector << txCenterFreq << ppduDuration << band << uid); + SetPhyHeaders(txVector, ppduDuration); +} + +void +VhtPpdu::SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration) +{ + NS_LOG_FUNCTION(this << txVector << ppduDuration); uint16_t length = ((ceil((static_cast(ppduDuration.GetNanoSeconds() - (20 * 1000)) / 1000) / 4.0) * 3) - diff --git a/src/wifi/model/vht/vht-ppdu.h b/src/wifi/model/vht/vht-ppdu.h index 0790950a1..9c82b9457 100644 --- a/src/wifi/model/vht/vht-ppdu.h +++ b/src/wifi/model/vht/vht-ppdu.h @@ -172,6 +172,14 @@ class VhtPpdu : public OfdmPpdu private: WifiTxVector DoGetTxVector() const override; + /** + * Fill in the PHY headers. + * + * \param txVector the TXVECTOR that was used for this PPDU + * \param ppduDuration the transmission duration of this PPDU + */ + void SetPhyHeaders(const WifiTxVector& txVector, Time ppduDuration); + VhtSigHeader m_vhtSig; //!< the VHT-SIG PHY header }; // class VhtPpdu