Linux下使用Speedtest测试网速教程

Linux下使用Speedtest测试网速教程

文章目录:

  • 一、通过Speedtest官网直接测试网络速度
  • 二、通过下载源码,在命令行中测试网速
    • 1、下载安装
    • 2、Speedtest的参数使用:


有时候我们会需要测试一下当前本机的下载速度和上行速度,但是不行,Linux并没有自带这种技能,那就只能借助外力get此技能啦!!!


这里我们使用的是Speedtest工具,下面介绍该工具的两种测试网速的方法

  • 通过浏览器测试网速
  • 通过下载源码,在命令行中测试网速

一、通过Speedtest官网直接测试网络速度

  1. Speedtest的官方网址
    网址: https://www.speedtest.net/

通过浏览器打开该网址,点击Go 即可开启网速测试之旅
Linux下使用Speedtest测试网速教程_第1张图片

2、测试效果如下:
Linux下使用Speedtest测试网速教程_第2张图片
Linux下使用Speedtest测试网速教程_第3张图片

二、通过下载源码,在命令行中测试网速

这里用到一个Python工具speedtest,speedtest是一个用Python编写的轻量级Linux命令行工具,目前支持几乎所有的python版本Python 2.4-3.7。它基于Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest很简单——只需要下载其Python脚本文件。

1、下载安装

Speedtest的github的下载地址:

https://github.com/sivel/speedtest-cli

Speedtest有多种安装方式,选一种你喜欢的方式去安装它吧!方法如下:

  1. 直接用pip安装
pip install speedtest-cli
  1. 用easy_install 安装
easy_install speedtest-cli
  1. 用pip结合git下载安装
pip install git+https://github.com/sivel/speedtest-cli.git
  1. 用git先下载,然后在用python执行安装程序安装
git clone https://github.com/sivel/speedtest-cli.git
python speedtest-cli/setup.py install
  1. 用wget下载,不安装
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli
  1. 用curl下载,不安装
curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

2、Speedtest的参数使用:

$ speedtest-cli -h

usage: speedtest-cli [-h] [--no-download] [--no-upload] [--bytes] [--share]
                     [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
                     [--csv-header] [--json] [--list] [--server SERVER]
                     [--exclude EXCLUDE] [--mini MINI] [--source SOURCE]
                     [--timeout TIMEOUT] [--secure] [--no-pre-allocate]
                     [--version]

Command line interface for testing internet bandwidth using speedtest.net.
-https://github.com/sivel/speedtest-cli

optional arguments:
  -h, --help            show this help message and exit
  --no-download         Do not perform download test
  --no-upload           Do not perform upload test
  --bytes               Display values in bytes instead of bits. Does not
                        affect the image generated by --share, nor output from
                        --json or --csv
  --share               Generate and provide a URL to the speedtest.net share
                        results image, not displayed with --csv
  --simple              Suppress verbose output, only show basic information
  --csv                 Suppress verbose output, only show basic information
                        in CSV format. Speeds listed in bit/s and not affected
                        by --bytes
  --csv-delimiter CSV_DELIMITER
                        Single character delimiter to use in CSV output.
                        Default ","
  --csv-header          Print CSV headers
  --json                Suppress verbose output, only show basic information
                        in JSON format. Speeds listed in bit/s and not
                        affected by --bytes
  --list                Display a list of speedtest.net servers sorted by
                        distance
  --server SERVER       Specify a server ID to test against. Can be supplied
                        multiple times
  --exclude EXCLUDE     Exclude a server from selection. Can be supplied
                        multiple times
  --mini MINI           URL of the Speedtest Mini server
  --source SOURCE       Source IP address to bind to
  --timeout TIMEOUT     HTTP timeout in seconds. Default 10
  --secure              Use HTTPS instead of HTTP when communicating with
                        speedtest.net operated servers
  --no-pre-allocate     Do not pre allocate upload data. Pre allocation is
                        enabled by default to improve upload performance. To
                        support systems with insufficient memory, use this
                        option to avoid a MemoryError
  --version             Show the version number and exit

Reference:
1、https://blog.csdn.net/catoop/article/details/50350623
2、https://linux.cn/article-9558-1.html
3、https://blog.csdn.net/wh211212/article/details/52735229
4、https://blog.csdn.net/h952520296/article/details/78458072

在这里插入图片描述



在这里插入图片描述
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

你可能感兴趣的:(5—Linux学习)