chore: adjustable cwnd for cc in quic
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"github.com/Dreamacro/clash/transport/tuic/congestion"
|
||||
|
||||
"github.com/metacubex/quic-go"
|
||||
c "github.com/metacubex/quic-go/congestion"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -11,7 +12,8 @@ const (
|
||||
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
||||
)
|
||||
|
||||
func SetCongestionController(quicConn quic.Connection, cc string) {
|
||||
func SetCongestionController(quicConn quic.Connection, cc string, cwnd int) {
|
||||
CWND := c.ByteCount(cwnd)
|
||||
switch cc {
|
||||
case "cubic":
|
||||
quicConn.SetCongestionControl(
|
||||
@ -36,7 +38,7 @@ func SetCongestionController(quicConn quic.Connection, cc string) {
|
||||
congestion.NewBBRSender(
|
||||
congestion.DefaultClock{},
|
||||
congestion.GetInitialPacketSize(quicConn.RemoteAddr()),
|
||||
congestion.InitialCongestionWindow*congestion.InitialMaxDatagramSize,
|
||||
CWND*congestion.InitialMaxDatagramSize,
|
||||
congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize,
|
||||
),
|
||||
)
|
||||
|
@ -36,6 +36,7 @@ type ClientOption struct {
|
||||
MaxUdpRelayPacketSize int
|
||||
FastOpen bool
|
||||
MaxOpenStreams int64
|
||||
CWND int
|
||||
}
|
||||
|
||||
type clientImpl struct {
|
||||
@ -91,7 +92,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
common.SetCongestionController(quicConn, t.CongestionController)
|
||||
common.SetCongestionController(quicConn, t.CongestionController, t.CWND)
|
||||
|
||||
go func() {
|
||||
_ = t.sendAuthentication(quicConn)
|
||||
|
@ -33,6 +33,7 @@ type ServerOption struct {
|
||||
CongestionController string
|
||||
AuthenticationTimeout time.Duration
|
||||
MaxUdpRelayPacketSize int
|
||||
CWND int
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
@ -57,7 +58,7 @@ func (s *Server) Serve() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
common.SetCongestionController(conn, s.CongestionController)
|
||||
common.SetCongestionController(conn, s.CongestionController, s.CWND)
|
||||
h := &serverHandler{
|
||||
Server: s,
|
||||
quicConn: conn,
|
||||
|
@ -33,6 +33,7 @@ type ClientOption struct {
|
||||
ReduceRtt bool
|
||||
MaxUdpRelayPacketSize int
|
||||
MaxOpenStreams int64
|
||||
CWND int
|
||||
}
|
||||
|
||||
type clientImpl struct {
|
||||
@ -88,7 +89,7 @@ func (t *clientImpl) getQuicConn(ctx context.Context, dialer C.Dialer, dialFn co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
common.SetCongestionController(quicConn, t.CongestionController)
|
||||
common.SetCongestionController(quicConn, t.CongestionController, t.CWND)
|
||||
|
||||
go func() {
|
||||
_ = t.sendAuthentication(quicConn)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
|
||||
"net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -32,6 +33,7 @@ type ServerOption struct {
|
||||
CongestionController string
|
||||
AuthenticationTimeout time.Duration
|
||||
MaxUdpRelayPacketSize int
|
||||
CWND int
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
@ -56,7 +58,7 @@ func (s *Server) Serve() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
common.SetCongestionController(conn, s.CongestionController)
|
||||
common.SetCongestionController(conn, s.CongestionController, s.CWND)
|
||||
h := &serverHandler{
|
||||
Server: s,
|
||||
quicConn: conn,
|
||||
|
Reference in New Issue
Block a user