From 7ee21c2cf83602f6eb9da7487a3e903f3d1f49ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Thu, 22 Aug 2019 13:49:40 +0200 Subject: [PATCH] wifi: Add methods to convert L-SIG length to HE TB PPDU duration and vice versa --- src/wifi/model/wifi-phy.cc | 31 +++++++++++++++++++++++++++++++ src/wifi/model/wifi-phy.h | 17 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 188c2c309..434f2888d 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -4845,6 +4845,37 @@ WifiPhy::GetBand (uint16_t /*bandWidth*/, uint8_t /*bandIndex*/) return band; } +uint16_t +WifiPhy::ConvertHeTbPpduDurationToLSigLength (Time ppduDuration, WifiPhyBand band) +{ + uint8_t sigExtension = 0; + if (band == WIFI_PHY_BAND_2_4GHZ) + { + sigExtension = 6; + } + uint8_t m = 2; //HE TB PPDU so m is set to 2 + uint16_t length = ((ceil ((static_cast (ppduDuration.GetNanoSeconds () - (20 * 1000) - (sigExtension * 1000)) / 1000) / 4.0) * 3) - 3 - m); + return length; +} + +Time +WifiPhy::ConvertLSigLengthToHeTbPpduDuration (uint16_t length, WifiTxVector txVector, WifiPhyBand band) +{ + Time tSymbol = NanoSeconds (12800 + txVector.GetGuardInterval ()); + Time preambleDuration = CalculatePhyPreambleAndHeaderDuration (txVector); + uint8_t sigExtension = 0; + if (band == WIFI_PHY_BAND_2_4GHZ) + { + sigExtension = 6; + } + uint8_t m = 2; //HE TB PPDU so m is set to 2 + //Equation 27-11 of IEEE P802.11ax/D4.0 + Time calculatedDuration = MicroSeconds (((ceil (static_cast (length + 3 + m) / 3)) * 4) + 20 + sigExtension); + uint32_t nSymbols = floor (static_cast ((calculatedDuration - preambleDuration).GetNanoSeconds () - (sigExtension * 1000)) / tSymbol.GetNanoSeconds ()); + Time ppduDuration = preambleDuration + (nSymbols * tSymbol) + MicroSeconds (sigExtension); + return ppduDuration; +} + int64_t WifiPhy::AssignStreams (int64_t stream) { diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 6b4990e74..42869282d 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -340,6 +340,23 @@ public: */ Time GetLastRxEndTime (void) const; + /** + * \param ppduDuration the duration of the HE TB PPDU + * \param band the frequency band being used + * + * \return the L-SIG length value corresponding to that HE TB PPDU duration. + */ + static uint16_t ConvertHeTbPpduDurationToLSigLength (Time ppduDuration, WifiPhyBand band); + + /** + * \param length the L-SIG length value + * \param txVector the TXVECTOR used for the transmission of this HE TB PPDU + * \param band the frequency band being used + * + * \return the duration of the HE TB PPDU corresponding to that L-SIG length value. + */ + static Time ConvertLSigLengthToHeTbPpduDuration (uint16_t length, WifiTxVector txVector, WifiPhyBand band); + /** * \param size the number of bytes in the packet to send * \param txVector the TXVECTOR used for the transmission of this packet