wifi: Move setting of PHY headers in a seperate function for all WifiPpdu child classes

This commit is contained in:
Sébastien Deronne
2022-11-28 18:55:44 +01:00
committed by Sébastien Deronne
parent 49befbc216
commit 7179427b49
8 changed files with 64 additions and 3 deletions

View File

@@ -47,6 +47,13 @@ HtPpdu::HtPpdu(Ptr<const WifiPsdu> 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<const WifiPsdu> 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);
}

View File

@@ -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

View File

@@ -40,6 +40,13 @@ DsssPpdu::DsssPpdu(Ptr<const WifiPsdu> 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());

View File

@@ -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

View File

@@ -45,11 +45,18 @@ OfdmPpdu::OfdmPpdu(Ptr<const WifiPsdu> 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
{

View File

@@ -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

View File

@@ -46,6 +46,13 @@ VhtPpdu::VhtPpdu(Ptr<const WifiPsdu> 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<double>(ppduDuration.GetNanoSeconds() - (20 * 1000)) / 1000) / 4.0) *
3) -

View File

@@ -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