智传网优云课堂,专注分享IT技术
与IT技术爱好者一起共同学习进步

Linux怎么测试网络带宽之speedtest

1. 前言

本文主要介绍Linux怎么测试互联网带宽速度,在以下教程中,我们将重点介绍speedtest这个测试工具。

2. speedtest功能介绍

Speedtest用于测试连接互联网速度。Speedtest测试网络上传/下载速度还是挺不错的,windows下非常方便。Linux下也可以很方便的使用命令行speedtest来测试。speedtest是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于Speedtest.net的基础架构来测量网络的上/下行速率。

此程序是基于Python开发的脚本程序,利用了speedtest.net的服务来测量出上下行的宽带。Speedtest-cli能根据机房离测速服务器的物理距离来列出测速服务器,或者针对某一服务器进行测速,同时还能为你生成一个URL以便你分享你的测速结果。

speedtest功能介绍

要在Linux上安装最新版本的speedtest-cli,你必须安装2.4-3.4或者更高版本的Python。

3. 安装speedtest

以CentOS7.5最小化安装为例,默认情况并没有集成speedtest测试套件,需要手动安装:

安装speedtest和需要额外添加python依赖包

[root@zcwyou ~]# yum -y install python2-speedtest-cli python-setuptools

安装speedtest和依赖关系

成功安装speedtest

4. speedtest选项

-h, --help       显示帮助信息
--share          生成图片测试结果,并给出图片的URL链接。
--simple         输出简单的结果,
--list           根据距离显示speedtest.net的测试服务器列表。
--server=SERVER  指定列表中id的服务器来做测试。
--mini=MINI      Speedtest迷你服务器的地址
--source=SOURCE 绑定源IP,当服务器有多个IP时可用
--version        查询speedtest的版本

5. 使用speedtest测试网络速度,并使用默认选项

[root@zcwyou ~]# speedtest

Retrieving speedtest.net configuration…
Testing from ShenZhen Sunrise Technology Co.,Ltd. (202.46.36.30)…
Retrieving speedtest.net server list…
Selecting best server based on ping…
Hosted by CSL (Tai Po) [10.65 km]: 26.525 ms
Testing download speed……………………………………………………………………..
Download: 359.36 Mbit/s
Testing upload speed……………………………………………………………………………………….
Upload: 62.42 Mbit/s

ping值测试26.525ms,下载速度359.36 Mbit/s,上传速度Upload: 62.42 Mbit/s

speedtest默认输出

6. 根据服务器地址显示最近的测试服务器

使用选项--list

[root@zcwyou ~]# speedtest --list |more

Retrieving speedtest.net configuration…
4515) China Mobile,Guangdong (Shenzhen, China) [0.00 km]
21003) Huawei (Shenzhen, China) [0.00 km]
14903) CSL (Tai Po, Hong Kong) [10.65 km]
14429) W Professional Services Limited (New Territories, Hong Kong) [18.14 km]
13538) CSL (Kwai Chung, Hong Kong) [18.52 km]
16176) HGC Global Communications Limited (Shatin, Hong Kong) [18.58 km]
17130) Telin (Hong kong, Hong Kong) [26.83 km]
18745) FPT Telecom (Chai Wan, Hong Kong) [31.27 km]
10267) Interoute VDC (Hong Kong, China) [31.69 km]
21182) Gemnet LLC (Hong Kong, Hong Kong) [31.69 km]
2993) Website Solution Limited (Hong Kong, China) [31.69 km]
1536) STC (Hong Kong, China) [31.69 km]
12990) QTS Data Centers (Hong Kong, China) [31.69 km]
19036) SmarTone (Hong Kong, China) [31.69 km]

7. 人为选择测试服务器

比如选择21003号服务器,使用选项--server

[root@zcwyou ~]# speedtest --server 21003

Retrieving speedtest.net configuration…
Testing from ShenZhen Sunrise Technology Co.,Ltd. (202.46.36.30)…
Retrieving speedtest.net server list…
Selecting best server based on ping…
Hosted by Huawei (Shenzhen) [0.00 km]: 343.378 ms
Testing download speed……………………………………………………………………..
Download: 88.33 Mbit/s
Testing upload speed……………………………………………………………………………………….
Upload: 19.51 Mbit/s
ping值测试343.378 ms,下载速度88.33 Mbit/s,上传速度Upload: 19.51 Mbit/s

speedtest指定测试服务器

8. 生成图片测试报告

使用选项--share

[root@zcwyou ~]# speedtest --share

Retrieving speedtest.net configuration…
Testing from ShenZhen Sunrise Technology Co.,Ltd. (202.46.36.30)…
Retrieving speedtest.net server list…
Selecting best server based on ping…
Hosted by CSL (Tai Po) [10.65 km]: 22.27 ms
Testing download speed……………………………………………………………………..
Download: 312.04 Mbit/s
Testing upload speed……………………………………………………………………………………….
Upload: 364.03 Mbit/s
Share results: http://www.speedtest.net/result/7803614493.png

用浏览器打开测试报告
http://www.speedtest.net/result/7803614493.png

Linux带宽测试报告

9. 总结

speedtest是一个常用的公网带宽测试工具,手机上也有相应的APP,它会自动连接最近机房的服务器并进行上传和下载速度测试,最终给出报告。结果可以作为参考,但建议应该结合多种测试工具和多个测试服务器点进行综合判断。

赞(0)
未经允许不得转载:Linux入门学习到精通 » Linux怎么测试网络带宽之speedtest
分享到: 更多 (0)

学习QQ群:557371664

关注微信公众号自助视频学习

评论 抢沙发

评论前必须登录!