Loading... # 多功能测速脚本 [](https://github.com/i-abc/Speedtest#%E5%A4%9A%E5%8A%9F%E8%83%BD%E6%B5%8B%E9%80%9F%E8%84%9A%E6%9C%AC) 兼容 [speedtest-cli](https://www.speedtest.net/zh-Hans/apps/cli)、[bim-core](https://github.com/veoco/bim-core)、[speedtest-go](https://github.com/showwin/speedtest-go)、[librespeed-cli](https://github.com/librespeed/speedtest-cli)、[iperf3](https://github.com/esnet/iperf)。 脚本自带丰富的测试项目任君挑选,使用者还能自定义想要的测试项目。 目录:👉 [效果展示](https://github.com/i-abc/Speedtest#%E6%95%88%E6%9E%9C%E5%B1%95%E7%A4%BA)、[使用方法](https://github.com/i-abc/Speedtest#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95)、[基本功能](https://github.com/i-abc/Speedtest#%E5%9F%BA%E6%9C%AC%E5%8A%9F%E8%83%BD)、[进阶功能](https://github.com/i-abc/Speedtest#%E8%BF%9B%E9%98%B6%E5%8A%9F%E8%83%BD) # 效果展示 [](https://github.com/i-abc/Speedtest#%E6%95%88%E6%9E%9C%E5%B1%95%E7%A4%BA) <details><summary>大陆三网+教育网 IPv4 多线程测速 (点击展开或收起)</summary> ``` span ``` </details> <details><summary>大陆三网+教育网 IPv4 单线程测速</summary> ``` ``` </details> <details><summary>各大洲 IPV4 八线程测速</summary> ``` ``` </details> <details><summary>IPV4 UDP 可用性测试</summary> ``` ``` </details> <details><summary>大陆教育网 IPv4 多线程测速</summary> ``` ``` </details> <details><summary>大陆教育网 IPv6 多线程测速</summary> ``` ``` </details> # 使用方法 [](https://github.com/i-abc/Speedtest#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) [![](https://camo.githubusercontent.com/a767f35b177e5f66a5cdc40dcc647701ab35723c959ca70d3fb49e5264830d32/68747470733a2f2f696d672e736869656c64732e696f2f776562736974653f75726c3d6874747073253341253246253246626173682e696375253246737065656474657374266c6162656c3d626173682e6963752532467370656564746573742663616368655365636f6e64733d333030)](https://bash.icu/speedtest) ```shell bash <(curl -sL bash.icu/speedtest) ``` 或 ```shell bash <(curl -sL https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) ``` # 基本功能 [](https://github.com/i-abc/Speedtest#%E5%9F%BA%E6%9C%AC%E5%8A%9F%E8%83%BD) 脚本自带丰富的测试项目: 0. [自定义测速节点](https://github.com/i-abc/Speedtest/tree/main#%E8%BF%9B%E9%98%B6%E5%8A%9F%E8%83%BD) 1. 大陆三网+教育网 IPv4 多线程测速 2. 大陆三网+教育网 IPv4 单线程测速 3. 大陆教育网 IPv6 多线程测速 4. 各大洲 IPV4 八线程测速 5. 各大洲 IPV6 八线程测速 6. IPV4 UDP 可用测试测试 7. 大陆教育网 IPv4 多线程测速 8. 大陆电信 IPv4 多线程测速 9. 大陆电信 IPv4 单线程测速 10. 大陆移动 IPv4 多线程测速 11. 大陆移动 IPv4 单线程测速 12. 大陆联通 IPv4 多线程测速 13. 大陆联通 IPv4 单线程测速 14. 各大洲 IPV4 32线程测速 15. 各大洲 IPV4 单线程测速 16. 各大洲 IPV6 32线程测速 17. 各大洲 IPV6 单线程测速 持续更新中…… # 进阶功能 [](https://github.com/i-abc/Speedtest#%E8%BF%9B%E9%98%B6%E5%8A%9F%E8%83%BD) 自定义自己想要的测试项目,很简单的。 我们会有两张表,节点表 (必需)、节点集合表 (非必需)。 ## 节点表 (必需) [](https://github.com/i-abc/Speedtest#%E8%8A%82%E7%82%B9%E8%A1%A8-%E5%BF%85%E9%9C%80) 节点表分为四个区域,分别是提示语区、测试类型区、节点名区、测试参数区;后三区组成三列,彼此之间用英文逗号 `,` 分隔,如下图所示: [![](https://github.com/i-abc/Speedtest/raw/main/images/1.png)](https://github.com/i-abc/Speedtest/raw/main/images/1.png) ### 示例 [](https://github.com/i-abc/Speedtest#%E7%A4%BA%E4%BE%8B) ``` 节点表 模板示例,v2023-09-08 speedtest-cli ,联通 郑州 cli ,-o 5gtest.shangdu.com bim-core ,联通 郑州 bimc ,http://5gtest.shangdu.com:8080/download http://5gtest.shangdu.com:8080/upload speedtest-go ,联通 郑州 go ,--custom-url http://5gtest.shangdu.com:8080/speedtest/upload.php --ping-mode http speedtest-go ,联通 郑州 八线程 ,--custom-url http://5gtest.shangdu.com:8080/speedtest/upload.php --ping-mode http -t 8 speedtest-go ,联通 郑州 只测上传 ,--custom-url http://5gtest.shangdu.com:8080/speedtest/upload.php --ping-mode http --no-download librespeed-cli,教育 南京 ,--server-json https://jihulab.com/i-abc/speedtest/-/raw/node/china-education.json --server 1 --no-icmp librespeed-cli,教育 南京 只测上传 ,--server-json https://jihulab.com/i-abc/speedtest/-/raw/node/china-education.json --server 1 --no-icmp --no-download iperf3 ,联通 宿迁 只测上传 ,-c 103.239.244.210 -p 22222 iperf3 ,联通 宿迁 只测下载 ,-c 103.239.244.210 -p 22222 -R iperf3 ,联通 宿迁 八线程 ,-c 103.239.244.210 -p 22222 -P 8 iperf3 ,联通 宿迁 测UDP ,-c 103.239.244.210 -p 22222 -u iperf3 ,联通 宿迁 测双向 ,-c 103.239.244.210 -p 22222 --up-and-down ``` ### 1区:提示语区 (可选) [](https://github.com/i-abc/Speedtest#1%E5%8C%BA%E6%8F%90%E7%A4%BA%E8%AF%AD%E5%8C%BA-%E5%8F%AF%E9%80%89) 提示语位于节点表开头,可以在这里写上任何话,比如使用说明、备注、自家广告等,当然也可以不写。 ### 3区:节点名区 [](https://github.com/i-abc/Speedtest#3%E5%8C%BA%E8%8A%82%E7%82%B9%E5%90%8D%E5%8C%BA) 显而易见,这里就是写对应节点的名字。 由于中英文字符编码很难处理,所以如果想要输出美观还得麻烦大家敲空格对齐,当然不对齐对测试无影响。 提示语区、节点名区会直接反映到输出,它们在输出、节点表之间的关系如下图所示: [![](https://github.com/i-abc/Speedtest/raw/main/images/2.png)](https://github.com/i-abc/Speedtest/raw/main/images/2.png) ### 2区:测试类型区 [](https://github.com/i-abc/Speedtest#2%E5%8C%BA%E6%B5%8B%E8%AF%95%E7%B1%BB%E5%9E%8B%E5%8C%BA) 我们有五种类型,分别是 [speedtest-cli](https://www.speedtest.net/zh-Hans/apps/cli)、[bim-core](https://github.com/veoco/bim-core)、[speedtest-go](https://github.com/showwin/speedtest-go)、[librespeed-cli](https://github.com/librespeed/speedtest-cli)、[iperf3](https://github.com/esnet/iperf),选一种即可,每种都有不同的特点,具体说明请往下看。 这部分加空格对齐不是必须的,不加对输出无任何影响,当然像我一样的强迫症可以加空格对齐。 ### 4区:测试参数区 [](https://github.com/i-abc/Speedtest#4%E5%8C%BA%E6%B5%8B%E8%AF%95%E5%8F%82%E6%95%B0%E5%8C%BA) 我们脚本兼容 [speedtest-cli](https://www.speedtest.net/zh-Hans/apps/cli)、[bim-core](https://github.com/veoco/bim-core)、[speedtest-go](https://github.com/showwin/speedtest-go)、[librespeed-cli](https://github.com/librespeed/speedtest-cli)、[iperf3](https://github.com/esnet/iperf),我挑选了部分对测试有用的参数应用到了脚本里,大家可以按需使用。 | **类型** | **测速点提供商** | **只单向测速** | **指定IPv6测速** | **单连接测速** | **UDP测试** | **不使用 ICMP Ping** | **指定测试时长** | | -------------- | ---------------- | -------------- | ---------------- | -------------- | ----------- | -------------------- | ---------------- | | speedtest-cli | speedtest.net | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | | bim-core | speedtest.net | ❌ | ✔️ | ✔️ | ❌ | ❌ | ❌ | | speedtest-go | speedtest.net | ✔️ | ❌ | ✔️ | ❌ | ✔️ | ❌ | | librespeed-cli | 公共、自建 | ✔️ | ✔️ | ❌ | ❌ | ✔️ | ✔️ | | iperf3 | 公共、自建 | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ✔️ | **使用 [speedtest.net](https://www.speedtest.net/) 时,多连接测速推荐 speedtest-cli、单连接测速推荐 bim-core。** #### 1️⃣ speedtest-cli [](https://github.com/i-abc/Speedtest#1%EF%B8%8F%E2%83%A3-speedtest-cli) [speedtest-cli](https://www.speedtest.net/zh-Hans/apps/cli):[speedtest.net](https://www.speedtest.net/) 官方 CLI,功能单一。 | 参数 | 作用 | 示例 | | -------- | ---------------- | --------------------- | | -s value | 通过 id 指定节点 | -s 36646 | | -o value | 通过域名指定节点 | -o 5gtest.shangdu.com | `-s` 和 `-o` 二选一,`-o` 后面参数为纯域名,不含 http(s)、端口号;推荐 `-o`。 节点 id、域名可在 [https://www.speedtest.net/api/ios-config.php](https://www.speedtest.net/api/ios-config.php) 查阅。 例如:`<server url="http://5gtest.shangdu.com:8080/speedtest/upload.php" lat="34.3287" lon="109.0337" name="Zhengzhou" sponsor="China Unicom HeNan 5G" id="36646" />`,则 id 为 `36646`,域名为 `5gtest.shangdu.com`。 #### 2️⃣ bim-core [](https://github.com/i-abc/Speedtest#2%EF%B8%8F%E2%83%A3-bim-core) [bim-core](https://github.com/veoco/bim-core):针对 [speedtest.net](https://www.speedtest.net/) 开发的第三方,功能较多,能实现单线程、指定 IPv6 测速。 | 参数 | 作用 | 示例 | | ------------- | -------------- | ---------------------------------------------------------------------------------- | | download\_url | 节点的下载链接 | [http://5gtest.shangdu.com:8080/download](http://5gtest.shangdu.com:8080/download) | | upload\_url | 节点的上传链接 | [http://5gtest.shangdu.com:8080/upload](http://5gtest.shangdu.com:8080/upload) | | -m | 启用八线程测速 | -m | | -6 | 仅使用 IPv6 | -6 | download\_url 和 upload\_url 两者都要,且 download\_url 在前、upload\_url 在后,含 http(s)、端口、分别以 `/download`、`/upload` 结尾。 节点链接可在 [https://www.speedtest.net/api/ios-config.php](https://www.speedtest.net/api/ios-config.php) 查阅。 例如:`<server url="http://5gtest.shangdu.com:8080/speedtest/upload.php" lat="34.3287" lon="109.0337" name="Zhengzhou" sponsor="China Unicom HeNan 5G" id="36646" />`,则 download\_url 为 `http://5gtest.shangdu.com:8080/download`,则 upload\_url 为 `http://5gtest.shangdu.com:8080/upload`。 #### 3️⃣ speedtest-go [](https://github.com/i-abc/Speedtest#3%EF%B8%8F%E2%83%A3-speedtest-go) [speedtest-go](https://github.com/showwin/speedtest-go):针对 [speedtest.net](https://www.speedtest.net/) 开发的第三方,功能较多,能实现指定线程、禁用某方向测速。 | 参数 | 作用 | 示例 | | ------------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------- | | -s value | 通过 id 指定节点 | -s 36646 | | --custom-url value | 通过链接指定节点 | --custom-url[http://5gtest.shangdu.com:8080/speedtest/upload.php](http://5gtest.shangdu.com:8080/speedtest/upload.php) | | -t value | 设置并发连接数 | -t 8 | | -m | 启用多服务器模式 | -m | | --no-download | 禁用下载测试 | --no-download | | --no-upload | 禁用上传测试 | --no-upload | | --ping-mode value | 选择一种 Ping 的方法 | --ping-mode http | `-s` 和 `--custom-url` 二选一,`--custom-url` 后面参数为完整链接,含 http(s)、端口、以 `/upload.php` 结尾;推荐 `--custom-url`。 `--ping-mode http` 推荐加上。 节点 id、链接可在 [https://www.speedtest.net/api/ios-config.php](https://www.speedtest.net/api/ios-config.php) 查阅。 例如:`<server url="http://5gtest.shangdu.com:8080/speedtest/upload.php" lat="34.3287" lon="109.0337" name="Zhengzhou" sponsor="China Unicom HeNan 5G" id="36646" />`,则 id 为 `36646`,链接为 `http://5gtest.shangdu.com:8080/speedtest/upload.php`。 #### 4️⃣ librespeed-cli [](https://github.com/i-abc/Speedtest#4%EF%B8%8F%E2%83%A3-librespeed-cli) [librespeed-cli](https://github.com/librespeed/speedtest-cli) | 参数 | 作用 | 示例 | | ------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | --server-json value | 远程 JSON 的服务端列表 | --server-json[https://jihulab.com/i-abc/speedtest/-/raw/node/china-education.json](https://jihulab.com/i-abc/speedtest/-/raw/node/china-education.json) | | --local-json value | 本地 JSON 的服务端列表 | --local-json /root/librespeed.json | | --server value | 通过 JSON 中的 ID 指定服务端 | --server 1 | | -4 | 仅使用 IPv4 (默认 false) | -4 | | -6 | 仅使用 IPv6 (默认 false) | -6 | | --no-download | 禁用下载测试 (默认 false) | --no-download | | --no-upload | 禁用上传测试 (默认 false) | --no-upload | | --no-icmp | 不使用 ICMP Ping。ICMP 在 Linux 下工作不稳定 (默认 false) | --no-icmp | | --duration | 测试的持续时间 (秒) (默认 15) | --duration 20 | `--no-icmp` 推荐加上。 现成的、优质的 librespeed 服务端较少,而且需要自己写服务端列表 JSON,JSON 写法参照 [官方](https://github.com/librespeed/speedtest-cli#use-a-custom-backend-server-list);如果是个人搭建测速、个人使用,推荐 iperf3。 #### 5️⃣ iperf3 [](https://github.com/i-abc/Speedtest#5%EF%B8%8F%E2%83%A3-iperf3) [iperf3](https://github.com/esnet/iperf) | 参数 | 作用 | 示例 | | ------------- | -------------------------------- | ------------------ | | -c ip/host | 指定服务端 | -c 103.239.244.210 | | -p value | 指定服务端端口 | -p 22222 | | -P value | 设置并发连接数 | -P 8 | | -t value | 测试的持续时间 (秒) (默认 10) | -t 20 | | -O value | 前 N 秒的数据不计入最终结果 | -O 3 | | -R | 反向模式,服务器发送、客户端接收 | -R | | -4 | 仅使用 IPv4 | -4 | | -6 | 仅使用 IPv6 | -6 | | -u | UDP测试 | -u | | --up-and-down | 双向测试 (自创选项) | --up-and-down | 当服务端端口为默认的 5201 时,`-p` 可不加;`-p` 除了 `-p 22222` 指定一个端口,还能 `-p 5200-5209` 指定一个范围内的端口。 iperf3 默认是客户端发送、服务端接收,也就是测上传;想测下载可加 `-R` 开启反向模式;但 iperf3 只支持单向,所以脚本里自创了 `--up-and-down` 选项,加上后可测双向;`--up-and-down` 与 `-R` 二选一,**且 `--up-and-down` 在本脚本以外的地方不可用,非官方选项**。 现成的、优质的 iperf3 服务端很多,可在 [iPerf3 Server List](https://iperf3serverlist.net/) 查阅;自建 iperf3 服务端也简单,用包管理器就行了。 ## 节点集合表 (非必需) [](https://github.com/i-abc/Speedtest#%E8%8A%82%E7%82%B9%E9%9B%86%E5%90%88%E8%A1%A8-%E9%9D%9E%E5%BF%85%E9%9C%80) 当你有很多节点表时可以组一个节点表合集,如下图所示,当然这不是必需的。 [![](https://github.com/i-abc/Speedtest/raw/main/images/3.png)](https://github.com/i-abc/Speedtest/raw/main/images/3.png) ### 示例 [](https://github.com/i-abc/Speedtest#%E7%A4%BA%E4%BE%8B-1) ``` 1. 节点示例 /root/GitHub/speedtest/node-template-1.txt 2. 示例1 /root/GitHub/speedtest/node-template-01.txt 3. 示例2 /root/GitHub/speedtest/node-template-02.txt ``` 每两行为一组,每组中的第一行以序号加英文点 `.` 开头,第二行为节点表链接,链接可为远程 http 或本地绝对路径。 节点集合表与输出之间的关系如下图所示: [![](https://github.com/i-abc/Speedtest/raw/main/images/5.png)](https://github.com/i-abc/Speedtest/raw/main/images/5.png) ## 使用自定义的表 [](https://github.com/i-abc/Speedtest#%E4%BD%BF%E7%94%A8%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E8%A1%A8) 我们现在有了节点表、节点集合表,那么该如何使用呢? 只需选择时输入序号 `0`,然后填写链接或本地绝对路径即可;链接为节点表就立即开始测试,链接为节点集合表就还会出现选择节点的提示。 [![](https://github.com/i-abc/Speedtest/raw/main/images/6.png)](https://github.com/i-abc/Speedtest/raw/main/images/6.png) 最后修改:2024 年 06 月 13 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏