Skip to content

Commit 7ec3479

Browse files
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
1 parent 535bd90 commit 7ec3479

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/wifi/model/ht/ht-phy.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ HtPhy::GetPayloadDuration(uint32_t size,
319319
case LAST_MPDU_IN_AGGREGATE: {
320320
// last packet in an A-MPDU
321321
uint32_t totalSize = totalAmpduSize + size;
322-
numSymbols = lrint(
323-
stbc * ceil((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
322+
numSymbols =
323+
stbc * ceil((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
324324
NS_ASSERT(totalAmpduNumSymbols <= numSymbols);
325325
numSymbols -= totalAmpduNumSymbols;
326326
if (incFlag)
@@ -336,7 +336,7 @@ HtPhy::GetPayloadDuration(uint32_t size,
336336
// The number of OFDM symbols in the data field when BCC encoding
337337
// is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
338338
numSymbols =
339-
lrint(stbc * ceil((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
339+
stbc * ceil((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol));
340340
break;
341341
}
342342
default:

src/wifi/model/non-ht/dsss-phy.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ DsssPhy::GetPayloadDuration(uint32_t size,
183183
double& /* totalAmpduNumSymbols */,
184184
uint16_t /* staId */) const
185185
{
186-
return MicroSeconds(
187-
lrint(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(MHz_u{22}) / 1.0e6))));
186+
return MicroSeconds(ceil((size * 8.0) / (txVector.GetMode().GetDataRate(MHz_u{22}) / 1.0e6)));
188187
}
189188

190189
Ptr<WifiPpdu>

src/wifi/model/non-ht/ofdm-phy.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ OfdmPhy::GetPayloadDuration(uint32_t size,
260260

261261
// The number of OFDM symbols in the data field when BCC encoding
262262
// is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
263-
double numSymbols =
264-
lrint(ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol)));
263+
double numSymbols = ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol));
265264

266265
Time payloadDuration =
267266
FemtoSeconds(static_cast<uint64_t>(numSymbols * symbolDuration.GetFemtoSeconds()));
@@ -617,7 +616,7 @@ OfdmPhy::CalculateDataRate(Time symbolDuration,
617616
double codingRate)
618617
{
619618
double symbolRate = (1e9 / static_cast<double>(symbolDuration.GetNanoSeconds()));
620-
return lrint(ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
619+
return ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate);
621620
}
622621

623622
uint16_t

0 commit comments

Comments
 (0)