freebsd:freebsd_bbr
这是本文档旧的修订版!
轻松在现代 FreeBSD 中启用 BBR 功能
从 14.1 开始 tcphpts, tcp_rack, tcp_bbr 都已经默认编译为模块, 需要用直接加载就可以了, 不需要重新编译内核.
加载模块
kldload tcphpts kldload tcp_bbr
系统启动自动加载模块
可以在 /etc/rc.conf 加入以下内容
kld_list="tcphpts tcp_bbr"
检查模块加载成功
运行以下命令, 看到有 BBR 一行, 并且有使用情况
sysctl net.inet.tcp.functions_available
切换 TCP 默认实现方式为 BBR
运行以下命令
sysctl net.inet.tcp.functions_default=bbr
过早启动的程序使用 BBR
默认在切换前启动的程序并不会使用到切换后的 bbr, 一种方法是重启程序
另一种是使用特定设置, 15.1 以前使用 sysctl
sysctl net.inet.tcp.functions_inherit_listen_socket_stack=0
15.1 及以后运行以下命令
tcpsso -S freebsd TCP_FUNCTION_BLK bbr
一些优化参数
20241205: 关闭 net.inet.tcp.bbr.measure.use_google 后, 大多数情况不会出现断流, 极小概率在某个系统出现极低速(该问题是接收端其他bug导致)
net.inet.tcp.bbr.measure.use_google=0
20260719: 可以通过优化 net.inet.tcp.bbr.cwnd.tar_rtt net.inet.tcp.bbr.cwnd.highspeed_min net.inet.tcp.bbr.cwnd.max_target_limit net.inet.tcp.bbr.probertt.cwnd, 使其在快速网络中接近 linux 的水平, 但是还是没 linux 能打
- 1Gbps
net.inet.tcp.bbr.cwnd.tar_rtt=3 # 1Gbps net.inet.tcp.bbr.cwnd.highspeed_min=128 net.inet.tcp.bbr.cwnd.max_target_limit=16 net.inet.tcp.bbr.probertt.cwnd=16 net.inet.tcp.sendbuf_inc=262144 net.inet.tcp.sendbuf_max=16777216 net.inet.tcp.sendspace=4194304
- 2.5Gbps
net.inet.tcp.bbr.cwnd.tar_rtt=3 # 1Gbps kern.ipc.maxsockbuf=33554432 net.inet.tcp.bbr.cwnd.highspeed_min=256 net.inet.tcp.bbr.cwnd.max_target_limit=16 net.inet.tcp.bbr.probertt.cwnd=32 net.inet.tcp.sendbuf_inc=524288 net.inet.tcp.sendbuf_max=33554432 net.inet.tcp.sendspace=2097152
- 10Gbps
net.inet.tcp.bbr.cwnd.tar_rtt=3 # 10Gbps kern.ipc.maxsockbuf=67108864 net.inet.tcp.bbr.cwnd.highspeed_min=512 net.inet.tcp.bbr.cwnd.max_target_limit=32 net.inet.tcp.bbr.probertt.cwnd=128 net.inet.tcp.sendbuf_inc=1048576 net.inet.tcp.sendbuf_max=67108864 net.inet.tcp.sendspace=4194304
freebsd/freebsd_bbr.1784393093.txt.gz · 最后更改: 由 Hshh
