diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index 0508b7abf..3af322aad 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -262,6 +262,20 @@ InterferenceHelper::CalculateChunkSuccessRate (double snir, Time duration, WifiM { return 1.0; } + uint64_t rate = mode.GetDataRate (txVector.GetChannelWidth ()); + uint64_t nbits = static_cast (rate * duration.GetSeconds ()); + double csr = m_errorRateModel->GetChunkSuccessRate (mode, txVector, snir, nbits); + return csr; +} + +double +InterferenceHelper::CalculatePayloadChunkSuccessRate (double snir, Time duration, WifiTxVector txVector) const +{ + if (duration.IsZero ()) + { + return 1.0; + } + WifiMode mode = txVector.GetMode (); uint64_t rate = mode.GetDataRate (txVector); uint64_t nbits = static_cast (rate * duration.GetSeconds ()); if (txVector.GetMode ().GetModulationClass () >= WIFI_MOD_CLASS_HT) @@ -303,21 +317,21 @@ InterferenceHelper::CalculatePayloadPer (Ptr event, NiChanges *ni, //Case 1: Both previous and current point to the windowed payload if (previous >= windowStart) { - psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, - noiseInterferenceW, - txVector.GetChannelWidth ()), - Min (windowEnd, current) - previous, - payloadMode, txVector); + psr *= CalculatePayloadChunkSuccessRate (CalculateSnr (powerW, + noiseInterferenceW, + txVector.GetChannelWidth ()), + Min (windowEnd, current) - previous, + txVector); NS_LOG_DEBUG ("Both previous and current point to the windowed payload: mode=" << payloadMode << ", psr=" << psr); } //Case 2: previous is before windowed payload and current is in the windowed payload else if (current >= windowStart) { - psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, - noiseInterferenceW, - txVector.GetChannelWidth ()), - Min (windowEnd, current) - windowStart, - payloadMode, txVector); + psr *= CalculatePayloadChunkSuccessRate (CalculateSnr (powerW, + noiseInterferenceW, + txVector.GetChannelWidth ()), + Min (windowEnd, current) - windowStart, + txVector); NS_LOG_DEBUG ("previous is before windowed payload and current is in the windowed payload: mode=" << payloadMode << ", psr=" << psr); } noiseInterferenceW = j->second.GetPower () - powerW; diff --git a/src/wifi/model/interference-helper.h b/src/wifi/model/interference-helper.h index 5c6626748..2c7166083 100644 --- a/src/wifi/model/interference-helper.h +++ b/src/wifi/model/interference-helper.h @@ -306,6 +306,17 @@ private: * \return the success rate */ double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const; + /** + * Calculate the success rate of the payload chunk given the SINR, duration, and Wi-Fi mode. + * The duration and mode are used to calculate how many bits are present in the chunk. + * + * \param snir SINR + * \param duration + * \param txVector + * + * \return the success rate + */ + double CalculatePayloadChunkSuccessRate (double snir, Time duration, WifiTxVector txVector) const; /** * Calculate the error rate of the given PLCP payload only in the provided time * window (thus enabling per MPDU PER information). The PLCP payload can be divided into