Skip to content

Commit

Permalink
Merge pull request #973 from apernet/fix-cwnd-undersize
Browse files Browse the repository at this point in the history
fix: cwnd undersize in extremely-low rtt scenarios
  • Loading branch information
tobyxdd authored Mar 11, 2024
2 parents 02baab1 + 9c51995 commit 16ec455
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/internal/congestion/brutal/brutal.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ func (b *BrutalSender) HasPacingBudget(now time.Time) bool {
}

func (b *BrutalSender) CanSend(bytesInFlight congestion.ByteCount) bool {
return bytesInFlight < b.GetCongestionWindow()
return bytesInFlight <= b.GetCongestionWindow()
}

func (b *BrutalSender) GetCongestionWindow() congestion.ByteCount {
rtt := b.rttStats.SmoothedRTT()
if rtt <= 0 {
return 10240
}
return congestion.ByteCount(float64(b.bps) * rtt.Seconds() * congestionWindowMultiplier / b.ackRate)
cwnd := congestion.ByteCount(float64(b.bps) * rtt.Seconds() * congestionWindowMultiplier / b.ackRate)
if cwnd < b.maxDatagramSize {
cwnd = b.maxDatagramSize
}
return cwnd
}

func (b *BrutalSender) OnPacketSent(sentTime time.Time, bytesInFlight congestion.ByteCount,
Expand Down

0 comments on commit 16ec455

Please sign in to comment.