mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-16 06:01:21 +08:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package common
|
|
|
|
import (
|
|
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
|
|
|
"github.com/metacubex/quic-go"
|
|
c "github.com/metacubex/quic-go/congestion"
|
|
)
|
|
|
|
const (
|
|
DefaultStreamReceiveWindow = 15728640 // 15 MB/s
|
|
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
|
)
|
|
|
|
func SetCongestionController(quicConn quic.Connection, cc string, cwnd int) {
|
|
if cwnd == 0 {
|
|
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":
|
|
quicConn.SetCongestionControl(
|
|
congestion.NewBBRSender(
|
|
congestion.DefaultClock{},
|
|
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
|
|
c.ByteCount(cwnd)*congestion.InitialMaxDatagramSize,
|
|
congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize,
|
|
),
|
|
)
|
|
}
|
|
}
|