From 7ec347902278114a10779888b2a10dff004bbec2 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Mon, 26 May 2025 22:25:43 +0200 Subject: [PATCH] wifi: Remove lrint calls Longs are 32-bit on Windows, differently from MacOS and Linux 64-bit, causing incorrect rounding of values when testing 320 MHz bands --- src/wifi/model/ht/ht-phy.cc | 6 +++--- src/wifi/model/non-ht/dsss-phy.cc | 3 +-- src/wifi/model/non-ht/ofdm-phy.cc | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index b954cc6f7..d32b54317 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -319,8 +319,8 @@ HtPhy::GetPayloadDuration(uint32_t size, case LAST_MPDU_IN_AGGREGATE: { // last packet in an A-MPDU uint32_t totalSize = totalAmpduSize + size; - numSymbols = lrint( - stbc * ceil((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol))); + numSymbols = + stbc * ceil((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)); NS_ASSERT(totalAmpduNumSymbols <= numSymbols); numSymbols -= totalAmpduNumSymbols; if (incFlag) @@ -336,7 +336,7 @@ HtPhy::GetPayloadDuration(uint32_t size, // The number of OFDM symbols in the data field when BCC encoding // is used is given in equation 19-32 of the IEEE 802.11-2016 standard. numSymbols = - lrint(stbc * ceil((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol))); + stbc * ceil((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)); break; } default: diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index a76354b08..c8ee6d890 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -183,8 +183,7 @@ DsssPhy::GetPayloadDuration(uint32_t size, double& /* totalAmpduNumSymbols */, uint16_t /* staId */) const { - return MicroSeconds( - lrint(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(MHz_u{22}) / 1.0e6)))); + return MicroSeconds(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(MHz_u{22}) / 1.0e6))); } Ptr diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index 9e83a360a..060040016 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -260,8 +260,7 @@ OfdmPhy::GetPayloadDuration(uint32_t size, // The number of OFDM symbols in the data field when BCC encoding // is used is given in equation 19-32 of the IEEE 802.11-2016 standard. - double numSymbols = - lrint(ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol))); + double numSymbols = ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol)); Time payloadDuration = FemtoSeconds(static_cast(numSymbols * symbolDuration.GetFemtoSeconds())); @@ -617,7 +616,7 @@ OfdmPhy::CalculateDataRate(Time symbolDuration, double codingRate) { double symbolRate = (1e9 / static_cast(symbolDuration.GetNanoSeconds())); - return lrint(ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate)); + return ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate); } uint16_t