From c5b0f00bb288804da369c6b494673b3880b1e17b Mon Sep 17 00:00:00 2001 From: Toby Date: Mon, 12 Jan 2026 13:34:59 +0800 Subject: [PATCH] fix: logic issues with BBR impl https://github.com/apernet/hysteria/commit/98872a4f38aae655ad7f4059cdf2af5d10bd0c0f --- transport/tuic/congestion_v2/bandwidth_sampler.go | 2 +- transport/tuic/congestion_v2/bbr_sender.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/transport/tuic/congestion_v2/bandwidth_sampler.go b/transport/tuic/congestion_v2/bandwidth_sampler.go index d546aec5..2cca8999 100644 --- a/transport/tuic/congestion_v2/bandwidth_sampler.go +++ b/transport/tuic/congestion_v2/bandwidth_sampler.go @@ -200,7 +200,7 @@ func (m *maxAckHeightTracker) Update( // Compute how many extra bytes were delivered vs max bandwidth. extraBytesAcked := m.aggregationEpochBytes - expectedBytesAcked newEvent := extraAckedEvent{ - extraAcked: expectedBytesAcked, + extraAcked: extraBytesAcked, bytesAcked: m.aggregationEpochBytes, timeDelta: aggregationDelta, } diff --git a/transport/tuic/congestion_v2/bbr_sender.go b/transport/tuic/congestion_v2/bbr_sender.go index ac17c355..99e85e90 100644 --- a/transport/tuic/congestion_v2/bbr_sender.go +++ b/transport/tuic/congestion_v2/bbr_sender.go @@ -23,7 +23,7 @@ import ( // const ( - minBps = 65536 // 64 kbps + minBps = 65536 // 64 KB/s invalidPacketNumber = -1 initialCongestionWindowPackets = 32 @@ -543,7 +543,7 @@ func (b *bbrSender) bandwidthEstimate() Bandwidth { } func (b *bbrSender) bandwidthForPacer() congestion.ByteCount { - bps := congestion.ByteCount(float64(b.bandwidthEstimate()) * b.congestionWindowGain / float64(BytesPerSecond)) + bps := congestion.ByteCount(float64(b.PacingRate()) / float64(BytesPerSecond)) if bps < minBps { // We need to make sure that the bandwidth value for pacer is never zero, // otherwise it will go into an edge case where HasPacingBudget = false