Skip to content

Commit

Permalink
chore: sync hysteria2 bbr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Jun 5, 2024
1 parent 7b3c9e9 commit 063836f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions transport/tuic/congestion_v2/bbr_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const (
// Flag.
defaultStartupFullLossCount = 8
quicBbr2DefaultLossThreshold = 0.02
maxBbrBurstPackets = 3
maxBbrBurstPackets = 10
)

type bbrMode int
Expand Down Expand Up @@ -334,6 +334,8 @@ func (b *bbrSender) OnPacketSent(
}

b.sampler.OnPacketSent(sentTime, packetNumber, bytes, bytesInFlight, isRetransmittable)

b.maybeAppLimited(bytesInFlight)
}

// CanSend implements the SendAlgorithm interface.
Expand Down Expand Up @@ -413,8 +415,6 @@ func (b *bbrSender) OnCongestionEventEx(priorInFlight congestion.ByteCount, even
// packet in lost_packets.
var lastPacketSendState sendTimeState

b.maybeApplimited(priorInFlight)

// Update bytesInFlight
b.bytesInFlight = priorInFlight
for _, p := range ackedPackets {
Expand Down Expand Up @@ -541,7 +541,7 @@ func (b *bbrSender) setDrainGain(drainGain float64) {
b.drainGain = drainGain
}

// What's the current estimated bandwidth in bytes per second.
// Get the current bandwidth estimate. Note that Bandwidth is in bits per second.
func (b *bbrSender) bandwidthEstimate() Bandwidth {
return b.maxBandwidth.GetBest()
}
Expand Down Expand Up @@ -700,14 +700,13 @@ func (b *bbrSender) checkIfFullBandwidthReached(lastPacketSendState *sendTimeSta
}
}

func (b *bbrSender) maybeApplimited(bytesInFlight congestion.ByteCount) {
func (b *bbrSender) maybeAppLimited(bytesInFlight congestion.ByteCount) {
congestionWindow := b.GetCongestionWindow()
if bytesInFlight >= congestionWindow {
return
}
availableBytes := congestionWindow - bytesInFlight
drainLimited := b.mode == bbrModeDrain && bytesInFlight > congestionWindow/2
if !drainLimited || availableBytes > maxBbrBurstPackets*b.maxDatagramSize {
if availableBytes > maxBbrBurstPackets*b.maxDatagramSize {
b.sampler.OnAppLimited()
}
}
Expand Down

0 comments on commit 063836f

Please sign in to comment.