msquic icon indicating copy to clipboard operation
msquic copied to clipboard

Calculation of SendAllowance in BBR is Wrong

Open lrfeng1 opened this issue 10 months ago • 4 comments

Describe the bug

In the BbrCongestionControlGetSendAllowance function,we expect a result in BYTES to indicate that how many bytes can be sent next time. And in this function, "SendAllowance = (uint32_t)(BandwidthEst * Bbr->PacingGain * TimeSinceLastSend / GAIN_UNIT);" is used to calculate the value of SendAllowance.

However, from the codes, we know that,BandwidthEst is in bps (bit per second), TimeSinceLastSend is in us(micro second),PacingGain/GAIN_UNIT will be 1 or 1.25 or 0.75,we can ignore its unit.

Obiviously, when pacing is executing, we cannot get a value in BYTES in this function, we have to use a formula "bit per micro sec * micro sec / 8" to get a value in bytes.

Affected OS

  • [ ] Windows
  • [ ] Linux
  • [ ] macOS
  • [ ] Other (specify below)

Additional OS information

No response

MsQuic version

main

Steps taken to reproduce bug

it can easily be seen in the codes. I found it in the following case.When I manually set the BandwidthEst to 6Gbps, i found that the actual throughput is too low and it is limited by the SendAllowance value. So I found that the SendAllowance calculation is wrong. this is because that 32-bit SendAllowance is not enough is this case (6G bps * 1 * several micro seconds), so when the 64-bit result is cut to 32-bit, the SendAllowacne result turns too small.

Expected behavior

a right value of SendAllowance

Actual outcome

a wrong value of SendAllowance

Additional details

No response

lrfeng1 avatar Mar 04 '25 09:03 lrfeng1

@anrossi Hi, May I ask if this is indeed a Bug?

lrfeng1 avatar Mar 06 '25 14:03 lrfeng1

It sounds like a bug from your description, but I haven't had time to dig in and investigate it further

anrossi avatar Mar 17 '25 18:03 anrossi

Feel free to suggest a PR, @lrfeng1.

nibanks avatar Mar 17 '25 19:03 nibanks

Copilot: elevate the type of SendAllowance to 64-bit

csujedihy avatar Jul 10 '25 20:07 csujedihy