前言

群里吹水时看到群友讨论相同配置的Windows网速和Linux网速哪个更快,得出结论是Linux获胜,毕竟Linux的TCP拥塞控制算法更好,采用的是BBR算法,而Windows一直是老古董CUBIC。

不过,在Windows11 22H2之后,也可以为TCP开启BBR2的拥塞控制算法了——尽管有一些小小的问题

开启BBR2

首先查看自己电脑的默认控制算法:

1
2
3
4
5
6
7
8
9
10
11
12
╭──  PowerShell  False                         0ms [21:21]
╰─ ~
Get-NetTCPSetting | Select SettingName, CongestionProvider

SettingName CongestionProvider
----------- ------------------
Automatic
InternetCustom CUBIC
DatacenterCustom CUBIC
Compat NewReno
Datacenter CUBIC
Internet CUBIC

可以看到都是CUBIC,中间还混了个NewReno。记一下默认值,后面还原需要用。

因为Windows的BBR2有漏洞,尚未完善对环回接口大分段(Large MTU)的处理,会导致本地 TCP 握手或数据收发出现阻塞或超时。因此,要先关闭环回接口大分段。

1
2
3
4
5
6
7
8
9
10
╭──  PowerShell  False                         436ms [21:21]
╰─ ~
❯ netsh interface ip show global
查询活动状态...

常规全局参数
---------------------------------------------
...
环回大 Mtu : enable
...

可以看到,这个“环回大MTU”是enable,需要关闭。是disable也执行一遍命令。在管理员模式的Powershell中执行:

1
2
netsh int ipv4 set global loopbacklargemtu=disable
netsh int ipv6 set global loopbacklargemtu=disable

确保变为disable即可。

之后,管理员身份下执行BBR2开启代码,并重启电脑:

1
2
3
4
5
netsh int tcp set supplemental Template=InternetCustom   CongestionProvider=bbr2
netsh int tcp set supplemental Template=DatacenterCustom CongestionProvider=bbr2
netsh int tcp set supplemental Template=Compat CongestionProvider=bbr2
netsh int tcp set supplemental Template=Internet CongestionProvider=bbr2
netsh int tcp set supplemental Template=Datacenter CongestionProvider=bbr2

即可开启BBR2。

复原

根据上面的默认值执行代码即可:

1
2
3
4
5
netsh int tcp set supplemental Template=InternetCustom   CongestionProvider=CUBIC
netsh int tcp set supplemental Template=DatacenterCustom CongestionProvider=CUBIC
netsh int tcp set supplemental Template=Compat CongestionProvider=NewReno
netsh int tcp set supplemental Template=Internet CongestionProvider=CUBIC
netsh int tcp set supplemental Template=Datacenter CongestionProvider=CUBIC