chore: remove unused code

This commit is contained in:
wwqgtxx 2025-10-24 21:24:51 +08:00
parent 90f47a6d0c
commit fb1ae21fb7
7 changed files with 5 additions and 63 deletions

View File

@ -21,7 +21,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) {
case "cubic": case "cubic":
quicConn.SetCongestionControl( quicConn.SetCongestionControl(
congestion.NewCubicSender( congestion.NewCubicSender(
congestion.DefaultClock{},
congestion.GetInitialPacketSize(quicConn), congestion.GetInitialPacketSize(quicConn),
false, false,
), ),
@ -29,7 +28,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) {
case "new_reno": case "new_reno":
quicConn.SetCongestionControl( quicConn.SetCongestionControl(
congestion.NewCubicSender( congestion.NewCubicSender(
congestion.DefaultClock{},
congestion.GetInitialPacketSize(quicConn), congestion.GetInitialPacketSize(quicConn),
true, true,
), ),
@ -37,7 +35,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) {
case "bbr_meta_v1": case "bbr_meta_v1":
quicConn.SetCongestionControl( quicConn.SetCongestionControl(
congestion.NewBBRSender( congestion.NewBBRSender(
congestion.DefaultClock{},
congestion.GetInitialPacketSize(quicConn), congestion.GetInitialPacketSize(quicConn),
c.ByteCount(cwnd)*congestion.InitialMaxDatagramSize, c.ByteCount(cwnd)*congestion.InitialMaxDatagramSize,
congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize, congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize,
@ -48,7 +45,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) {
case "bbr": case "bbr":
quicConn.SetCongestionControl( quicConn.SetCongestionControl(
congestionv2.NewBbrSender( congestionv2.NewBbrSender(
congestionv2.DefaultClock{},
congestionv2.GetInitialPacketSize(quicConn), congestionv2.GetInitialPacketSize(quicConn),
c.ByteCount(cwnd), c.ByteCount(cwnd),
), ),

View File

@ -101,7 +101,6 @@ const (
type bbrSender struct { type bbrSender struct {
mode bbrMode mode bbrMode
clock Clock
rttStats congestion.RTTStatsProvider rttStats congestion.RTTStatsProvider
bytesInFlight congestion.ByteCount bytesInFlight congestion.ByteCount
// return total bytes of unacked packets. // return total bytes of unacked packets.
@ -232,14 +231,12 @@ type bbrSender struct {
} }
func NewBBRSender( func NewBBRSender(
clock Clock,
initialMaxDatagramSize, initialMaxDatagramSize,
initialCongestionWindow, initialCongestionWindow,
initialMaxCongestionWindow congestion.ByteCount, initialMaxCongestionWindow congestion.ByteCount,
) *bbrSender { ) *bbrSender {
b := &bbrSender{ b := &bbrSender{
mode: STARTUP, mode: STARTUP,
clock: clock,
sampler: NewBandwidthSampler(), sampler: NewBandwidthSampler(),
maxBandwidth: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter), maxBandwidth: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter),
maxAckHeight: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter), maxAckHeight: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter),

View File

@ -1,18 +0,0 @@
package congestion
import "time"
// A Clock returns the current time
type Clock interface {
Now() time.Time
}
// DefaultClock implements the Clock interface using the Go stdlib clock.
type DefaultClock struct{}
var _ Clock = DefaultClock{}
// Now gets the current time
func (DefaultClock) Now() time.Time {
return time.Now()
}

View File

@ -37,8 +37,6 @@ const betaLastMax float32 = 0.85
// Cubic implements the cubic algorithm from TCP // Cubic implements the cubic algorithm from TCP
type Cubic struct { type Cubic struct {
clock Clock
// Number of connections to simulate. // Number of connections to simulate.
numConnections int numConnections int
@ -67,9 +65,8 @@ type Cubic struct {
} }
// NewCubic returns a new Cubic instance // NewCubic returns a new Cubic instance
func NewCubic(clock Clock) *Cubic { func NewCubic() *Cubic {
c := &Cubic{ c := &Cubic{
clock: clock,
numConnections: defaultNumConnections, numConnections: defaultNumConnections,
} }
c.Reset() c.Reset()

View File

@ -23,7 +23,6 @@ type cubicSender struct {
rttStats congestion.RTTStatsProvider rttStats congestion.RTTStatsProvider
cubic *Cubic cubic *Cubic
pacer *pacer pacer *pacer
clock Clock
reno bool reno bool
@ -61,12 +60,10 @@ var (
// NewCubicSender makes a new cubic sender // NewCubicSender makes a new cubic sender
func NewCubicSender( func NewCubicSender(
clock Clock,
initialMaxDatagramSize congestion.ByteCount, initialMaxDatagramSize congestion.ByteCount,
reno bool, reno bool,
) *cubicSender { ) *cubicSender {
return newCubicSender( return newCubicSender(
clock,
reno, reno,
initialMaxDatagramSize, initialMaxDatagramSize,
initialCongestionWindow*initialMaxDatagramSize, initialCongestionWindow*initialMaxDatagramSize,
@ -75,7 +72,6 @@ func NewCubicSender(
} }
func newCubicSender( func newCubicSender(
clock Clock,
reno bool, reno bool,
initialMaxDatagramSize, initialMaxDatagramSize,
initialCongestionWindow, initialCongestionWindow,
@ -89,8 +85,7 @@ func newCubicSender(
initialMaxCongestionWindow: initialMaxCongestionWindow, initialMaxCongestionWindow: initialMaxCongestionWindow,
congestionWindow: initialCongestionWindow, congestionWindow: initialCongestionWindow,
slowStartThreshold: MaxByteCount, slowStartThreshold: MaxByteCount,
cubic: NewCubic(clock), cubic: NewCubic(),
clock: clock,
reno: reno, reno: reno,
maxDatagramSize: initialMaxDatagramSize, maxDatagramSize: initialMaxDatagramSize,
} }

View File

@ -96,7 +96,6 @@ const (
type bbrSender struct { type bbrSender struct {
rttStats congestion.RTTStatsProvider rttStats congestion.RTTStatsProvider
clock Clock
pacer *Pacer pacer *Pacer
mode bbrMode mode bbrMode
@ -244,12 +243,10 @@ type bbrSender struct {
var _ congestion.CongestionControl = &bbrSender{} var _ congestion.CongestionControl = &bbrSender{}
func NewBbrSender( func NewBbrSender(
clock Clock,
initialMaxDatagramSize congestion.ByteCount, initialMaxDatagramSize congestion.ByteCount,
initialCongestionWindowPackets congestion.ByteCount, initialCongestionWindowPackets congestion.ByteCount,
) *bbrSender { ) *bbrSender {
return newBbrSender( return newBbrSender(
clock,
initialMaxDatagramSize, initialMaxDatagramSize,
initialCongestionWindowPackets*initialMaxDatagramSize, initialCongestionWindowPackets*initialMaxDatagramSize,
congestion.MaxCongestionWindowPackets*initialMaxDatagramSize, congestion.MaxCongestionWindowPackets*initialMaxDatagramSize,
@ -257,13 +254,11 @@ func NewBbrSender(
} }
func newBbrSender( func newBbrSender(
clock Clock,
initialMaxDatagramSize, initialMaxDatagramSize,
initialCongestionWindow, initialCongestionWindow,
initialMaxCongestionWindow congestion.ByteCount, initialMaxCongestionWindow congestion.ByteCount,
) *bbrSender { ) *bbrSender {
b := &bbrSender{ b := &bbrSender{
clock: clock,
mode: bbrModeStartup, mode: bbrModeStartup,
sampler: newBandwidthSampler(roundTripCount(bandwidthWindowSize)), sampler: newBandwidthSampler(roundTripCount(bandwidthWindowSize)),
lastSentPacket: invalidPacketNumber, lastSentPacket: invalidPacketNumber,
@ -297,7 +292,7 @@ func newBbrSender(
} }
*/ */
b.enterStartupMode(b.clock.Now()) b.enterStartupMode()
b.setHighCwndGain(derivedHighCWNDGain) b.setHighCwndGain(derivedHighCWNDGain)
return b return b
@ -605,7 +600,7 @@ func (b *bbrSender) maybeUpdateMinRtt(now monotime.Time, sampleMinRtt time.Durat
} }
// Enters the STARTUP mode. // Enters the STARTUP mode.
func (b *bbrSender) enterStartupMode(now monotime.Time) { func (b *bbrSender) enterStartupMode() {
b.mode = bbrModeStartup b.mode = bbrModeStartup
// b.maybeTraceStateChange(logging.CongestionStateStartup) // b.maybeTraceStateChange(logging.CongestionStateStartup)
b.pacingGain = b.highGain b.pacingGain = b.highGain
@ -757,7 +752,7 @@ func (b *bbrSender) maybeEnterOrExitProbeRtt(now monotime.Time, isRoundStart, mi
if now.Sub(b.exitProbeRttAt) >= 0 && b.probeRttRoundPassed { if now.Sub(b.exitProbeRttAt) >= 0 && b.probeRttRoundPassed {
b.minRttTimestamp = now b.minRttTimestamp = now
if !b.isAtFullBandwidth { if !b.isAtFullBandwidth {
b.enterStartupMode(now) b.enterStartupMode()
} else { } else {
b.enterProbeBandwidthMode(now) b.enterProbeBandwidthMode(now)
} }

View File

@ -1,20 +0,0 @@
package congestion
import (
"github.com/metacubex/quic-go/monotime"
)
// A Clock returns the current time
type Clock interface {
Now() monotime.Time
}
// DefaultClock implements the Clock interface using the Go stdlib clock.
type DefaultClock struct{}
var _ Clock = DefaultClock{}
// Now gets the current time
func (DefaultClock) Now() monotime.Time {
return monotime.Now()
}