diff --git a/src/mesh/model/dot11s/airtime-metric.cc b/src/mesh/model/dot11s/airtime-metric.cc index 21ab6366c..82dd8ffb2 100644 --- a/src/mesh/model/dot11s/airtime-metric.cc +++ b/src/mesh/model/dot11s/airtime-metric.cc @@ -92,7 +92,7 @@ AirtimeLinkMetricCalculator::CalculateMetric(Mac48Address peerAddress, (uint32_t)((double)(/*Overhead + payload*/ // DIFS + SIFS + AckTxTime = 2 * SIFS + 2 * SLOT + AckTxTime 2 * mac->GetWifiPhy()->GetSifs() + 2 * mac->GetWifiPhy()->GetSlot() + - mac->GetWifiPhy()->GetAckTxTime() + + GetEstimatedAckTxTime(txVector) + WifiPhy::CalculateTxDuration(m_testFrame->GetSize(), txVector, mac->GetWifiPhy()->GetPhyBand())) diff --git a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc index 4376082d2..3fd41158b 100644 --- a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc @@ -1811,9 +1811,7 @@ MinstrelHtWifiManager::CalculateRetransmits(MinstrelHtWifiRemoteStation* station uint32_t cwMax = 1023; Time cwTime; Time txTime; - Time dataTxTime; const auto slotTime = GetPhy()->GetSlot(); - const auto ackTime = GetPhy()->GetSifs() + GetPhy()->GetBlockAckTxTime(); if (station->m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1) { @@ -1824,16 +1822,15 @@ MinstrelHtWifiManager::CalculateRetransmits(MinstrelHtWifiRemoteStation* station station->m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2; station->m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated = true; - dataTxTime = - GetFirstMpduTxTime( - groupId, - GetMcsSupported(station, - station->m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) + - GetMpduTxTime( - groupId, - GetMcsSupported(station, - station->m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) * - (station->m_avgAmpduLen - 1); + auto mode = + GetMcsSupported(station, station->m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex); + WifiTxVector txVector; + txVector.SetMode(mode); + txVector.SetPreambleType(GetPreambleForTransmission(mode.GetModulationClass())); + + const auto dataTxTime = GetFirstMpduTxTime(groupId, mode) + + GetMpduTxTime(groupId, mode) * (station->m_avgAmpduLen - 1); + const auto ackTime = GetPhy()->GetSifs() + GetEstimatedAckTxTime(txVector); /* Contention time for first 2 tries */ cwTime = (cw / 2) * slotTime; diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-wifi-manager.cc index 55980805a..dcf028460 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.cc @@ -1038,7 +1038,7 @@ MinstrelWifiManager::RateInit(MinstrelWifiRemoteStation* station) { NS_LOG_DEBUG(" Checking " << retries << " retries"); totalTxTimeWithGivenRetries = - CalculateTimeUnicastPacket(station->m_minstrelTable[i].perfectTxTime, 0, retries); + CalculateTimeUnicastPacket(GetSupported(station, i), 0, retries); NS_LOG_DEBUG(" totalTxTimeWithGivenRetries = " << totalTxTimeWithGivenRetries); if (totalTxTimeWithGivenRetries > MilliSeconds(6)) { @@ -1053,22 +1053,28 @@ MinstrelWifiManager::RateInit(MinstrelWifiRemoteStation* station) } Time -MinstrelWifiManager::CalculateTimeUnicastPacket(Time dataTransmissionTime, +MinstrelWifiManager::CalculateTimeUnicastPacket(WifiMode mode, uint32_t shortRetries, uint32_t longRetries) { - NS_LOG_FUNCTION(this << dataTransmissionTime << shortRetries << longRetries); + NS_LOG_FUNCTION(this << mode << shortRetries << longRetries); // See rc80211_minstrel.c // First transmission (Data + Ack timeout) - Time tt = dataTransmissionTime + GetPhy()->GetSifs() + GetPhy()->GetAckTxTime(); + WifiTxVector txVector; + txVector.SetMode(mode); + txVector.SetPreambleType( + GetPreambleForTransmission(mode.GetModulationClass(), GetShortPreambleEnabled())); + const auto oneTxTime = + GetCalcTxTime(mode) + GetPhy()->GetSifs() + GetEstimatedAckTxTime(txVector); + auto tt = oneTxTime; uint32_t cwMax = 1023; uint32_t cw = 31; for (uint32_t retry = 0; retry < longRetries; retry++) { // Add one re-transmission (Data + Ack timeout) - tt += dataTransmissionTime + GetPhy()->GetSifs() + GetPhy()->GetAckTxTime(); + tt += oneTxTime; // Add average back off (half the current contention window) tt += (cw / 2.0) * GetPhy()->GetSlot(); diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.h b/src/wifi/model/rate-control/minstrel-wifi-manager.h index 1ed3536c5..1fc0e6214 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.h +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.h @@ -314,14 +314,12 @@ class MinstrelWifiManager : public WifiRemoteStationManager * - Data transmission * - backoffs according to CW * - * @param dataTransmissionTime the data transmission time + * @param mode the WiFi mode used to transmit the data frame * @param shortRetries short retries * @param longRetries long retries * @returns the unicast packet time */ - Time CalculateTimeUnicastPacket(Time dataTransmissionTime, - uint32_t shortRetries, - uint32_t longRetries); + Time CalculateTimeUnicastPacket(WifiMode mode, uint32_t shortRetries, uint32_t longRetries); /** * Print Sample Table. diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 091552f69..003fb9fc8 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -389,8 +389,6 @@ WifiPhy::WifiPhy() m_sifs(), m_slot(), m_pifs(), - m_ackTxTime(), - m_blockAckTxTime(), m_powerRestricted(false), m_channelAccessRequested(false), m_txSpatialStreams(1), @@ -856,18 +854,6 @@ WifiPhy::GetPifs() const return m_pifs; } -Time -WifiPhy::GetAckTxTime() const -{ - return m_ackTxTime; -} - -Time -WifiPhy::GetBlockAckTxTime() const -{ - return m_blockAckTxTime; -} - void WifiPhy::Configure80211a() { @@ -880,7 +866,6 @@ WifiPhy::Configure80211a() SetPifs(GetSifs() + GetSlot()); // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties // of the PPDU causing the EIFS" of 802.11-2016 - m_ackTxTime = MicroSeconds(44); } void @@ -897,7 +882,6 @@ WifiPhy::Configure80211b() SetPifs(GetSifs() + GetSlot()); // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties // of the PPDU causing the EIFS" of 802.11-2016 - m_ackTxTime = MicroSeconds(304); } void @@ -925,7 +909,6 @@ WifiPhy::Configure80211p() SetSifs(MicroSeconds(32)); SetSlot(MicroSeconds(13)); SetPifs(GetSifs() + GetSlot()); - m_ackTxTime = MicroSeconds(88); } else if (GetChannelWidth() == MHz_u{5}) { @@ -935,7 +918,6 @@ WifiPhy::Configure80211p() SetSifs(MicroSeconds(64)); SetSlot(MicroSeconds(21)); SetPifs(GetSifs() + GetSlot()); - m_ackTxTime = MicroSeconds(176); } else { @@ -956,10 +938,6 @@ WifiPhy::Configure80211n() Configure80211a(); } AddPhyEntity(WIFI_MOD_CLASS_HT, Create(m_txSpatialStreams)); - - // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties - // of the PPDU causing the EIFS" of 802.11-2016 - m_blockAckTxTime = MicroSeconds(68); } void diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 741c04222..9f17ae4e8 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -429,18 +429,6 @@ class WifiPhy : public Object * @return the PIFS duration */ Time GetPifs() const; - /** - * Return the estimated Ack TX time for this PHY. - * - * @return the estimated Ack TX time - */ - Time GetAckTxTime() const; - /** - * Return the estimated BlockAck TX time for this PHY. - * - * @return the estimated BlockAck TX time - */ - Time GetBlockAckTxTime() const; /** * Get the maximum PSDU size in bytes for the given modulation class. @@ -1611,11 +1599,9 @@ class WifiPhy : public Object WifiPhyOperatingChannel m_operatingChannel; //!< Operating channel bool m_fixedPhyBand; //!< True to prohibit changing PHY band after initialization - Time m_sifs; //!< Short Interframe Space (SIFS) duration - Time m_slot; //!< Slot duration - Time m_pifs; //!< PCF Interframe Space (PIFS) duration - Time m_ackTxTime; //!< estimated Ack TX time - Time m_blockAckTxTime; //!< estimated BlockAck TX time + Time m_sifs; //!< Short Interframe Space (SIFS) duration + Time m_slot; //!< Slot duration + Time m_pifs; //!< PCF Interframe Space (PIFS) duration dBm_u m_rxSensitivity; //!< Receive sensitivity threshold dBm_u m_ccaEdThreshold; //!< Clear channel assessment (CCA) energy detection (ED) threshold diff --git a/src/wifi/test/wifi-txop-test.cc b/src/wifi/test/wifi-txop-test.cc index fe3bc1554..8044a7b4e 100644 --- a/src/wifi/test/wifi-txop-test.cc +++ b/src/wifi/test/wifi-txop-test.cc @@ -628,7 +628,7 @@ WifiTxopTest::CheckResults() tStart = m_txPsdus[2].txStart; auto apPhy = apDev->GetPhy(SINGLE_LINK_OP_ID); - auto eifsNoDifs = apPhy->GetSifs() + apPhy->GetAckTxTime(); + auto eifsNoDifs = apPhy->GetSifs() + GetEstimatedAckTxTime(m_txPsdus[1].txVector); NS_TEST_EXPECT_MSG_GT_OR_EQ( tStart - tEnd,