fix: BBR bandwidth estimation edge case

from 89429598bf
This commit is contained in:
wwqgtxx
2023-10-07 17:30:03 +08:00
parent d8fe7a52d6
commit 5a1800d642
4 changed files with 20 additions and 7 deletions

View File

@ -43,6 +43,9 @@ func (p *Pacer) Budget(now time.Time) congestion.ByteCount {
return p.maxBurstSize()
}
budget := p.budgetAtLastSent + (p.getBandwidth()*congestion.ByteCount(now.Sub(p.lastSentTime).Nanoseconds()))/1e9
if budget < 0 { // protect against overflows
budget = congestion.ByteCount(1<<62 - 1)
}
return Min(p.maxBurstSize(), budget)
}