Hugo博客公告弹窗

TCP调优一键脚本:限速方式

脚本

请注意,调参后能跑多少速度是由你的网络环境和线路的优劣决定的,线路垃圾再怎么调也没用

注意:每个时段都会不一样,至于效果嘛,就当个娱乐看吧。

脚本:

curl -sS -O https://raw.githubusercontent.com/woniu336/open_shell/main/network_optimizer.sh && chmod +x network_optimizer.sh && ./network_optimizer.sh

脚本特色:

  • 自动获取网口名称

  • 仅替换核心参数,不影响原有的 sysctl.conf其余参数

  • 可恢复成原始设置

  • 只需要上调和下调带宽大小即可

查看配置实际加载顺序: 最后加载的会覆盖前面的参数

sudo sysctl --system

验证是否应用了新的参数

sysctl -a | grep net.ipv4.tcp_rmem
sysctl -a | grep net.ipv4.tcp_wmem

服务端安装

apt update
apt install iperf3

防火墙放行端口

sudo ufw allow 5201/tcp
sudo ufw allow 5201/udp

使用命令

iperf3 -s

============

客户端下载:

https://github.com/ar51an/iperf3-win-builds/releases/download/3.17.1/iperf-3.17.1-win64.zip

客户端使用命令

iperf3 -c 服务端ip -R -t 30 -p 5201

多线程

iperf3 -c 服务端ip -p 5201 -t 30 -P 10 -R

然后在本机发起测速。其中 -c 参数表示客户端并指定测速服务器地址,-p 指定服务器端口,-t 指定测试时长(单位秒),-P 指定并发连接数(越高越能测试到速度极限),-R 表示下载测速(不加参数则测试上传速度)。如果要测试 UDP 连接,追加 -u 参数。

实战

  1. vmiss伦敦9929

我是在晚上11点左右测试的(高峰期),我的vmiss-伦敦9929,上行带宽200 Mbps,使用脚本限制带宽,我从180下调到150,来回反复测试,每次重传都非常的高,我干脆把带宽下调到100,惊喜来了,重传控制在了100以内,反复测试了几次都是如此

  1. ovh-加拿大

    原本的100M带宽口子,我限制在70M,

=========

vmiss伦敦9929:

Server listening on 5201 (test #15)
-----------------------------------------------------------

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   582 KBytes  4.77 Mbits/sec    0    145 KBytes
[  5]   1.00-2.00   sec  8.18 MBytes  68.6 Mbits/sec    0   1.90 MBytes
[  5]   2.00-3.00   sec  27.5 MBytes   231 Mbits/sec    0   7.39 MBytes
[  5]   3.00-4.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.14 MBytes
[  5]   4.00-5.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.38 MBytes
[  5]   5.00-6.00   sec  12.5 MBytes   105 Mbits/sec    0   6.25 MBytes
[  5]   6.00-7.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.25 MBytes
[  5]   7.00-8.00   sec  11.2 MBytes  94.4 Mbits/sec    4   6.25 MBytes
[  5]   8.00-9.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.24 MBytes
[  5]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.25 MBytes
[  5]  10.00-10.22  sec  2.50 MBytes  93.3 Mbits/sec    0   6.25 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.22  sec   119 MBytes  97.4 Mbits/sec    4             sender
-----------------------------------------------------------
Server listening on 5201 (test #16)
-----------------------------------------------------------

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   897 KBytes  7.35 Mbits/sec    0    167 KBytes
[  5]   1.00-2.00   sec  5.37 MBytes  45.1 Mbits/sec    0   1.45 MBytes
[  5]   2.00-3.00   sec  27.5 MBytes   231 Mbits/sec    0   7.02 MBytes
[  5]   3.00-4.00   sec  12.5 MBytes   105 Mbits/sec    0   5.99 MBytes
[  5]   4.00-5.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.00 MBytes
[  5]   5.00-6.00   sec  11.2 MBytes  94.4 Mbits/sec    0   5.71 MBytes
[  5]   6.00-7.00   sec  12.5 MBytes   105 Mbits/sec    0   5.94 MBytes
[  5]   7.00-8.00   sec  11.2 MBytes  94.4 Mbits/sec    0   5.94 MBytes
[  5]   8.00-9.00   sec  11.2 MBytes  94.4 Mbits/sec    0   5.93 MBytes
[  5]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.94 MBytes
[  5]  10.00-11.00  sec  10.0 MBytes  83.9 Mbits/sec   35   5.94 MBytes
[  5]  11.00-12.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.95 MBytes
[  5]  12.00-13.00  sec  10.0 MBytes  83.9 Mbits/sec    0   5.93 MBytes
[  5]  13.00-14.00  sec  12.5 MBytes   105 Mbits/sec   21   5.94 MBytes
[  5]  14.00-15.00  sec  11.2 MBytes  94.4 Mbits/sec   10   5.86 MBytes
[  5]  15.00-16.00  sec  11.2 MBytes  94.4 Mbits/sec   13   5.89 MBytes
[  5]  16.00-17.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.84 MBytes
[  5]  17.00-18.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.65 MBytes
[  5]  18.00-19.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.94 MBytes
[  5]  19.00-20.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.95 MBytes
[  5]  20.00-20.22  sec  2.50 MBytes  97.0 Mbits/sec    0   5.95 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-20.22  sec   229 MBytes  94.9 Mbits/sec   79             sender
-----------------------------------------------------------
Server listening on 5201 (test #17)
-----------------------------------------------------------

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   582 KBytes  4.77 Mbits/sec    0    150 KBytes
[  5]   1.00-2.00   sec  8.31 MBytes  69.7 Mbits/sec    0   2.08 MBytes
[  5]   2.00-3.00   sec  26.2 MBytes   220 Mbits/sec    6   7.24 MBytes
[  5]   3.00-4.00   sec  12.5 MBytes   105 Mbits/sec    0   6.09 MBytes
[  5]   4.00-5.00   sec  7.50 MBytes  62.9 Mbits/sec   54   2.59 MBytes
[  5]   5.00-6.00   sec  13.8 MBytes   115 Mbits/sec   47   6.14 MBytes
[  5]   6.00-7.00   sec  10.0 MBytes  83.9 Mbits/sec    0   6.18 MBytes
[  5]   7.00-8.00   sec  12.5 MBytes   105 Mbits/sec    0   6.19 MBytes
[  5]   8.00-9.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.15 MBytes
[  5]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.09 MBytes
[  5]  10.00-11.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.09 MBytes
[  5]  11.00-12.00  sec  12.5 MBytes   105 Mbits/sec    0   5.47 KBytes
[  5]  12.00-13.00  sec  6.25 MBytes  52.4 Mbits/sec    0   5.64 MBytes
[  5]  13.00-14.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.19 MBytes
[  5]  14.00-15.00  sec  10.0 MBytes  83.9 Mbits/sec   20   2.48 MBytes
[  5]  15.00-16.00  sec  12.5 MBytes   105 Mbits/sec    0   6.13 MBytes
[  5]  16.00-17.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.18 MBytes
[  5]  17.00-18.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.20 MBytes
[  5]  18.00-19.00  sec  11.2 MBytes  94.4 Mbits/sec    3   6.18 MBytes
[  5]  19.00-20.00  sec  11.2 MBytes  94.4 Mbits/sec    0   6.19 MBytes
[  5]  20.00-20.22  sec  2.50 MBytes  96.5 Mbits/sec    0   6.19 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-20.22  sec   225 MBytes  93.4 Mbits/sec  130             sender
-----------------------------------------------------------
Server listening on 5201 (test #18)
-----------------------------------------------------------

[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   897 KBytes  7.35 Mbits/sec    0    167 KBytes
[  5]   1.00-2.00   sec  5.37 MBytes  45.1 Mbits/sec    0   1.44 MBytes
[  5]   2.00-3.00   sec  28.8 MBytes   241 Mbits/sec    0   6.99 MBytes
[  5]   3.00-4.00   sec  10.0 MBytes  83.9 Mbits/sec    0   5.44 MBytes
[  5]   4.00-5.00   sec  12.5 MBytes   105 Mbits/sec    0   5.93 MBytes
[  5]   5.00-6.00   sec  11.2 MBytes  94.4 Mbits/sec    0   5.78 MBytes
[  5]   6.00-7.00   sec  8.75 MBytes  73.4 Mbits/sec   21   5.70 MBytes
[  5]   7.00-8.00   sec  12.5 MBytes   105 Mbits/sec    0   6.00 MBytes
[  5]   8.00-9.00   sec  11.2 MBytes  94.4 Mbits/sec    0   6.01 MBytes
[  5]   9.00-10.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.95 MBytes
[  5]  10.00-11.00  sec  11.2 MBytes  94.4 Mbits/sec    0   5.97 MBytes
[  5]  11.00-12.00  sec  12.5 MBytes   105 Mbits/sec    0   5.97 MBytes
[  5]  12.00-13.00  sec  10.0 MBytes  83.9 Mbits/sec   39   5.94 MBytes
[  5]  13.00-14.00  sec  12.5 MBytes   105 Mbits/sec    2   5.91 MBytes
[  5]  14.00-15.00  sec  10.0 MBytes  83.9 Mbits/sec    0   5.95 MBytes
[  5]  15.00-16.00  sec  12.5 MBytes   105 Mbits/sec    0   5.97 MBytes
[  5]  16.00-17.00  sec  8.75 MBytes  73.4 Mbits/sec    0   5.94 MBytes
[  5]  17.00-18.00  sec  8.75 MBytes  73.4 Mbits/sec    0   4.91 MBytes
[  5]  18.00-19.00  sec  11.2 MBytes  94.4 Mbits/sec    0   4.92 MBytes
[  5]  19.00-20.00  sec  8.75 MBytes  73.4 Mbits/sec   15   5.44 MBytes
[  5]  20.00-20.23  sec  0.00 Bytes  0.00 bits/sec    6   5.95 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-20.23  sec   219 MBytes  90.7 Mbits/sec   83             sender
-----------------------------------------------------------
Server listening on 5201 (test #19)

=========

ovh- 加拿大


[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   520 KBytes  4.26 Mbits/sec    0    118 KBytes
[  5]   1.00-2.00   sec  2.76 MBytes  23.2 Mbits/sec    0    751 KBytes
[  5]   2.00-3.00   sec  22.5 MBytes   189 Mbits/sec    0   5.59 MBytes
[  5]   3.00-4.00   sec  7.50 MBytes  62.9 Mbits/sec    0   4.00 MBytes
[  5]   4.00-5.00   sec  8.75 MBytes  73.4 Mbits/sec    0   4.66 MBytes
[  5]   5.00-6.00   sec  7.50 MBytes  62.9 Mbits/sec    0   4.62 MBytes
[  5]   6.00-7.00   sec  7.50 MBytes  62.9 Mbits/sec    0   4.63 MBytes
[  5]   7.00-8.00   sec  8.75 MBytes  73.4 Mbits/sec    0   4.49 MBytes
[  5]   8.00-9.00   sec  7.50 MBytes  62.9 Mbits/sec    0   4.38 MBytes
[  5]   9.00-10.00  sec  8.75 MBytes  73.4 Mbits/sec    0   4.40 MBytes
[  5]  10.00-11.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.60 MBytes
[  5]  11.00-12.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.61 MBytes
[  5]  12.00-13.00  sec  8.75 MBytes  73.4 Mbits/sec    0   4.62 MBytes
[  5]  13.00-14.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.43 MBytes
[  5]  14.00-15.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.41 MBytes
[  5]  15.00-16.00  sec  8.75 MBytes  73.4 Mbits/sec    0   4.42 MBytes
[  5]  16.00-17.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.49 MBytes
[  5]  17.00-18.00  sec  7.50 MBytes  62.9 Mbits/sec    0   4.51 MBytes
[  5]  18.00-19.00  sec  8.75 MBytes  73.4 Mbits/sec    0   4.50 MBytes
[  5]  19.00-20.00  sec  6.25 MBytes  52.4 Mbits/sec    0   4.41 MBytes
[  5]  20.00-20.28  sec  0.00 Bytes  0.00 bits/sec    0   4.40 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-20.28  sec   160 MBytes  66.0 Mbits/sec    0             sender
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
CC BY-NC-SA 4.0 转载请注明
最后更新于 2025-01-15 13:02
clarity统计