use default RTT (100ms) for 0-RTT if no prior estimate (#5388)

* utils: initialize the {Smoothed, Latest, Min}RTT to 100ms

* utils: use time.Duration.Nanoseconds instead of uint64

No functional change expected.

* congestion: better check to avoid division by zero
This commit is contained in:
Marten Seemann
2025-10-16 15:32:46 +08:00
committed by GitHub
parent 5e5100b40c
commit 42b198b8d1
14 changed files with 157 additions and 143 deletions

View File

@@ -278,8 +278,8 @@ func (c *cubicSender) isCwndLimited(bytesInFlight protocol.ByteCount) bool {
func (c *cubicSender) BandwidthEstimate() Bandwidth {
srtt := c.rttStats.SmoothedRTT()
if srtt == 0 {
// If we haven't measured an rtt, the bandwidth estimate is unknown.
return infBandwidth
// This should never happen, but if it does, avoid division by zero.
srtt = protocol.TimerGranularity
}
return BandwidthFromDelta(c.GetCongestionWindow(), srtt)
}

View File

@@ -162,7 +162,6 @@ func TestCubicSenderExponentialSlowStart(t *testing.T) {
// At startup make sure we can send.
require.True(t, sender.sender.CanSend(0))
require.Zero(t, sender.sender.TimeUntilSend(0))
require.Equal(t, infBandwidth, sender.sender.BandwidthEstimate())
const numberOfAcks = 20
for range numberOfAcks {