chore: add new bbr implementation

This commit is contained in:
wwqgtxx
2023-09-30 23:55:56 +08:00
parent fedad26c13
commit 828b5ad8bb
15 changed files with 2440 additions and 695 deletions

View File

@ -2,6 +2,7 @@ package common
import (
"github.com/Dreamacro/clash/transport/tuic/congestion"
congestionv2 "github.com/Dreamacro/clash/transport/tuic/congestion_v2"
"github.com/metacubex/quic-go"
c "github.com/metacubex/quic-go/congestion"
@ -17,23 +18,7 @@ func SetCongestionController(quicConn quic.Connection, cc string, cwnd int) {
cwnd = 32
}
switch cc {
case "cubic":
quicConn.SetCongestionControl(
congestion.NewCubicSender(
congestion.DefaultClock{},
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
false,
),
)
case "new_reno":
quicConn.SetCongestionControl(
congestion.NewCubicSender(
congestion.DefaultClock{},
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
true,
),
)
case "bbr":
case "bbr_meta_v1":
quicConn.SetCongestionControl(
congestion.NewBBRSender(
congestion.DefaultClock{},
@ -42,5 +27,15 @@ func SetCongestionController(quicConn quic.Connection, cc string, cwnd int) {
congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize,
),
)
case "bbr_meta_v2":
fallthrough
case "bbr":
quicConn.SetCongestionControl(
congestionv2.NewBbrSender(
congestionv2.DefaultClock{},
congestionv2.GetInitialPacketSize(quicConn.RemoteAddr()),
c.ByteCount(cwnd),
),
)
}
}