diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 9d8c73312..0e013a5df 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -316,7 +316,7 @@ HePhy::GetSymbolDuration (const WifiTxVector& txVector) const { uint16_t gi = txVector.GetGuardInterval (); NS_ASSERT (gi == 800 || gi == 1600 || gi == 3200); - return NanoSeconds (12800 + gi); + return GetSymbolDuration (NanoSeconds (gi)); } void @@ -1229,7 +1229,7 @@ HePhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInter { NS_ASSERT (guardInterval == 800 || guardInterval == 1600 || guardInterval == 3200); NS_ASSERT (nss <= 8); - return HtPhy::CalculateDataRate (12.8, guardInterval, + return HtPhy::CalculateDataRate (GetSymbolDuration (NanoSeconds (guardInterval)), GetUsableSubcarriers (channelWidth), static_cast (log2 (GetConstellationSize (mcsValue))), HtPhy::GetCodeRatio (GetCodeRate (mcsValue)), nss); @@ -1258,6 +1258,12 @@ HePhy::GetUsableSubcarriers (uint16_t channelWidth) } } +Time +HePhy::GetSymbolDuration (Time guardInterval) +{ + return NanoSeconds (12800) + guardInterval; +} + uint64_t HePhy::GetNonHtReferenceRate (uint8_t mcsValue) { diff --git a/src/wifi/model/he/he-phy.h b/src/wifi/model/he/he-phy.h index 77904d77d..cb1b2cbd7 100644 --- a/src/wifi/model/he/he-phy.h +++ b/src/wifi/model/he/he-phy.h @@ -422,12 +422,19 @@ protected: * and lookup in Table 10-10 of IEEE P802.11ax/D6.0. */ static uint64_t CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellationSize); + /** * \param channelWidth the channel width in MHz - * \return he number of usable subcarriers for data + * \return the number of usable subcarriers for data */ static uint16_t GetUsableSubcarriers (uint16_t channelWidth); + /** + * \param guardInterval the guard interval duration + * \return the symbol duration + */ + static Time GetSymbolDuration (Time guardInterval); + uint64_t m_previouslyTxPpduUid; //!< UID of the previously sent PPDU, used by AP to recognize response HE TB PPDUs uint64_t m_currentHeTbPpduUid; //!< UID of the HE TB PPDU being received diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index b35c1fb38..e13f1cb54 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -666,19 +666,20 @@ HtPhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInter { NS_ASSERT (guardInterval == 800 || guardInterval == 400); NS_ASSERT (nss <= 4); - return CalculateDataRate (3.2, guardInterval, + return CalculateDataRate (GetSymbolDuration (NanoSeconds (guardInterval)), GetUsableSubcarriers (channelWidth), static_cast (log2 (GetHtConstellationSize (mcsValue))), GetCodeRatio (GetHtCodeRate (mcsValue)), nss); } uint64_t -HtPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval, - uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, +HtPhy::CalculateDataRate (Time symbolDuration, uint16_t usableSubCarriers, + uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss) { - return nss * OfdmPhy::CalculateDataRate (symbolDuration, guardInterval, - usableSubCarriers, numberOfBitsPerSubcarrier, + return nss * OfdmPhy::CalculateDataRate (symbolDuration, + usableSubCarriers, + numberOfBitsPerSubcarrier, codingRate); } @@ -688,6 +689,12 @@ HtPhy::GetUsableSubcarriers (uint16_t channelWidth) return (channelWidth == 40) ? 108 : 52; } +Time +HtPhy::GetSymbolDuration (Time guardInterval) +{ + return NanoSeconds (3200) + guardInterval; +} + uint64_t HtPhy::GetNonHtReferenceRate (uint8_t mcsValue) { diff --git a/src/wifi/model/ht/ht-phy.h b/src/wifi/model/ht/ht-phy.h index e025b1813..53e8bbc19 100644 --- a/src/wifi/model/ht/ht-phy.h +++ b/src/wifi/model/ht/ht-phy.h @@ -505,8 +505,7 @@ protected: /** * Calculates data rate from the supplied parameters. * - * \param symbolDuration the symbol duration (in us) excluding guard interval - * \param guardInterval the considered guard interval duration in nanoseconds + * \param symbolDuration the symbol duration * \param usableSubCarriers the number of usable subcarriers for data * \param numberOfBitsPerSubcarrier the number of data bits per subcarrier * \param codingRate the coding rate @@ -514,15 +513,28 @@ protected: * * \return the data bit rate of this signal in bps. */ - static uint64_t CalculateDataRate (double symbolDuration, uint16_t guardInterval, - uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, + static uint64_t CalculateDataRate (Time symbolDuration, uint16_t usableSubCarriers, + uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss); + /** * \param channelWidth the channel width in MHz - * \return he number of usable subcarriers for data + * \return the symbol duration excluding guard interval + */ + static Time GetSymbolDuration (uint16_t channelWidth); + + /** + * \param channelWidth the channel width in MHz + * \return the number of usable subcarriers for data */ static uint16_t GetUsableSubcarriers (uint16_t channelWidth); + /** + * \param guardInterval the guard interval duration + * \return the symbol duration + */ + static Time GetSymbolDuration (Time guardInterval); + uint8_t m_maxMcsIndexPerSs; //!< the maximum MCS index per spatial stream as defined by the standard uint8_t m_maxSupportedMcsIndexPerSs; //!< the maximum supported MCS index per spatial stream uint8_t m_bssMembershipSelector; //!< the BSS membership selector diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index d74895f8f..bc556520e 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -568,32 +568,42 @@ OfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth) uint64_t OfdmPhy::CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth) { - double symbolDuration = 3.2; //in us - uint16_t guardInterval = 800; //in ns - if (channelWidth == 10) - { - symbolDuration = 6.4; - guardInterval = 1600; - } - else if (channelWidth == 5) - { - symbolDuration = 12.8; - guardInterval = 3200; - } - return CalculateDataRate (symbolDuration, guardInterval, - 48, static_cast (log2 (constellationSize)), + return CalculateDataRate (GetSymbolDuration (channelWidth), + GetUsableSubcarriers (), + static_cast (log2 (constellationSize)), GetCodeRatio (codeRate)); } uint64_t -OfdmPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval, - uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, - double codingRate) +OfdmPhy::CalculateDataRate (Time symbolDuration, uint16_t usableSubCarriers, + uint16_t numberOfBitsPerSubcarrier, double codingRate) { - double symbolRate = (1 / (symbolDuration + (static_cast (guardInterval) / 1000))) * 1e6; + double symbolRate = (1e9 / static_cast (symbolDuration.GetNanoSeconds ())); return lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate)); } +uint16_t +OfdmPhy::GetUsableSubcarriers (void) +{ + return 48; +} + +Time +OfdmPhy::GetSymbolDuration (uint16_t channelWidth) +{ + Time symbolDuration = MicroSeconds (4); + uint8_t bwFactor = 1; + if (channelWidth == 10) + { + bwFactor = 2; + } + else if (channelWidth == 5) + { + bwFactor = 4; + } + return bwFactor * symbolDuration; +} + bool OfdmPhy::IsAllowed (const WifiTxVector& /*txVector*/) { diff --git a/src/wifi/model/non-ht/ofdm-phy.h b/src/wifi/model/non-ht/ofdm-phy.h index 4033bc0ba..8bfa1e616 100644 --- a/src/wifi/model/non-ht/ofdm-phy.h +++ b/src/wifi/model/non-ht/ofdm-phy.h @@ -402,17 +402,27 @@ protected: /** * Calculates data rate from the supplied parameters. * - * \param symbolDuration the symbol duration (in us) excluding guard interval - * \param guardInterval the considered guard interval duration in nanoseconds + * \param symbolDuration the symbol duration * \param usableSubCarriers the number of usable subcarriers for data * \param numberOfBitsPerSubcarrier the number of data bits per subcarrier * \param codingRate the coding rate * * \return the data bit rate of this signal in bps. */ - static uint64_t CalculateDataRate (double symbolDuration, uint16_t guardInterval, - uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, - double codingRate); + static uint64_t CalculateDataRate (Time symbolDuration, uint16_t usableSubCarriers, + uint16_t numberOfBitsPerSubcarrier, double codingRate); + + /** + * \return the number of usable subcarriers for data + */ + static uint16_t GetUsableSubcarriers (void); + + + /** + * \param channelWidth the channel width in MHz + * \return the symbol duration + */ + static Time GetSymbolDuration (uint16_t channelWidth); private: /** diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index d5bf75ce0..2692cb4a1 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -470,7 +470,7 @@ VhtPhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInte NS_ASSERT (guardInterval == 800 || guardInterval == 400); NS_ASSERT (nss <= 8); NS_ASSERT_MSG (IsCombinationAllowed (mcsValue, channelWidth, nss), "VHT MCS " << +mcsValue << " forbidden at " << channelWidth << " MHz when NSS is " << +nss); - return HtPhy::CalculateDataRate (3.2, guardInterval, + return HtPhy::CalculateDataRate (GetSymbolDuration (NanoSeconds (guardInterval)), GetUsableSubcarriers (channelWidth), static_cast (log2 (GetConstellationSize (mcsValue))), HtPhy::GetCodeRatio (GetCodeRate (mcsValue)), nss);