FILE / ScuroNeko/mtg

network/v2/sockopts_linux.go

Исходный файл и его история в репозитории.
FILE 60ab083defb21b78055e7ae8aeea6b4b39069759
Files
mtg/network/v2/sockopts_linux.go
T
9seconds 88f33debab Use TCP BBR in a best-effort mode
This small commits conditionally sets TCP BBR as a preferrable algorithm
for TCP congestion control
2026-04-07 14:54:56 +02:00

20 lines
560 B
Go

//go:build linux
package network
import (
"syscall"
"golang.org/x/sys/unix"
)
func setCongestionControl(conn syscall.RawConn) {
conn.Control(func(fd uintptr) { //nolint: errcheck
// BBR provides better throughput over lossy and high-latency links compared
// to the default cubic, which is especially beneficial for mobile and
// home internet clients. This is best-effort: silently ignored if the
// kernel does not have tcp_bbr available.
unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr") //nolint: errcheck
})
}