wifi: Add function to return the symbol duration
This commit is contained in:
@@ -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<uint16_t> (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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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<uint16_t> (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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<uint16_t> (log2 (constellationSize)),
|
||||
return CalculateDataRate (GetSymbolDuration (channelWidth),
|
||||
GetUsableSubcarriers (),
|
||||
static_cast<uint16_t> (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<double> (guardInterval) / 1000))) * 1e6;
|
||||
double symbolRate = (1e9 / static_cast<double> (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*/)
|
||||
{
|
||||
|
||||
@@ -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:
|
||||
/**
|
||||
|
||||
@@ -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<uint16_t> (log2 (GetConstellationSize (mcsValue))),
|
||||
HtPhy::GetCodeRatio (GetCodeRate (mcsValue)), nss);
|
||||
|
||||
Reference in New Issue
Block a user