首先安装编译所需的依赖包和软件包:
apt -y update
apt -y install build-essential libncurses-dev libssl-dev libelf-dev bison bc flex rsync debhelper dwarves git
获取源码:
git clone -b v3 https://github.com/google/bbr.git
cd bbr/
复制系统默认的内核配置文件:
cp /boot/config-$(uname -r) .config
执行如下命令保留旧.config文件中的所有选项,并将新选项设置为推荐(即默认)值:
make olddefconfig
打开配置菜单:
make menuconfig
依次进入 Networking support-> Networking options-> TCP: advanced congestion control->,把BBR TCP选项设置为编译成模块:
为节约编译时间和减少硬盘占用,建议关闭DEBUG功能,依次进入Kernel hacking->Compile-time checks and compiler options->Debug information (Disable debug information)->,按下图所示设置为Disable debug information:
编译并创建deb软件包:
make bindeb-pkg -j$(nproc)
编译完成后在上级目录安装新的内核并重启:
cd ..
apt install ./linux-image-6.4.0+_6.4.0-g6e321d1c986a-1_amd64.deb
apt install ./linux-headers-6.4.0+_6.4.0-g6e321d1c986a-1_amd64.deb
systemctl reboot
查看tcp_bbr模块信息:
modinfo tcp_bbr
可以看到版本是3:
启用BBRv3:
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
sysctl -p
执行下面的命令检查BBR模块是否启动成功:
lsmod
如有类似回显说明正常: