如何在 linux 服务器上从命令行测试网络速度(无 gui)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4297835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:09:22  来源:igfitidea点击:

How do i test the net speed from the command-line on a linux server(no gui)?

linuxnetworkingcommand-line

提问by Shinnok

I am looking for ways to test the net speed on a linux box with no GUI from the command line. I am not interested in tools like bmon/iftop/wget/curl especially from the upload side of things, for download it is pretty easy with wget on different targets and servers(places). But i am more interested in the upload side of things, which is the most important part of a server's bandwidth. I want to test the upload speed on different servers and places around the world just like you could do it by visiting speedtest.net using a browser with flash. If that tool can handle download speeds too that way then all the better then.

我正在寻找在没有 GUI 的 linux 机器上从命令行测试网络速度的方法。我对 bmon/iftop/wget/curl 之类的工具不感兴趣,尤其是在上传方面,对于下载,在不同的目标和服务器(地点)上使用 wget 非常容易。但我对上传方面更感兴趣,这是服务器带宽中最重要的部分。我想测试世界各地不同服务器和地方的上传速度,就像您可以通过使用带 Flash 的浏览器访问 speedtest.net 来测试一样。如果该工具也能以这种方式处理下载速度,那就更好了。

采纳答案by Thomas

I'm not aware of a way to do this without a cooperating remote server. If you upload data, it has to go somewhere... Sites like speedtest.net do exactly that (they have a data sink somewhere).

如果没有合作的远程服务器,我不知道有什么方法可以做到这一点。如果你上传数据,它必须去某个地方......像speedtest.net这样的网站就是这样做的(他们在某处有一个数据接收器)。

Provided you do have ssh access to a remote server with a download link somewhat faster than the upload link you want to test, you may achieve this rather simply with netcat :

如果您确实可以通过 ssh 访问远程服务器,并且下载链接比您要测试的上传链接快一些,那么您可以使用 netcat 来实现这一点:

On your remote server (let's assume IP 1.2.3.4) :

在您的远程服务器上(假设 IP 为 1.2.3.4):

$ nc -kl 12345 > /dev/null

On the machine you want to test :

在您要测试的机器上:

$ time nc 1.2.3.4 12345 < large-file
$ stat -c'%s' large-file

Divide the file size by the "real" time and you have an estimation of your speed.

将文件大小除以“实时”时间,您就可以估算出您的速度。

Note that you only need to run nc once on the server, and it will accept any number of sequential tests. If you only want it to work once (for security reasons or whatever), omit the -k flag.

请注意,您只需在服务器上运行 nc 一次,它将接受任意数量的顺序测试。如果您只希望它工作一次(出于安全原因或其他原因),请省略 -k 标志。

回答by Borealid

iperfis a tool designed for this.

iperf是为此设计的工具。

You run it on both sides of the connection and it can measure bandwidth either way, with TCP or UDP, and has many tweakable parameters.

你在连接的两端运行它,它可以用 TCP 或 UDP 的任何一种方式测量带宽,并且有许多可调整的参数。

回答by BlackBear

I don't think that exists some command-line tool for this kind of test, but someone seems to have your same question, take a look at the solutions suggested there..

我不认为存在用于这种测试的一些命令行工具,但似乎有人有 同样的问题,看看那里建议的解决方案..

回答by Aaron J Smith

I took this from another post I found here and thought I would pass it on:

我从我在这里找到的另一篇文章中获取了这个,并认为我会传递它:

It looks like there is a tool available on sourceforge that uses speedtest.net from the terminal.

看起来 sourceforge 上有一个工具可以从终端使用 speedtest.net。

Terminal speedtest: http://sourceforge.net/projects/tespeed/

终端速度测试:http: //sourceforge.net/projects/tespeed/

回答by wael34218

This is a great tool tespeed. It tests your upload and download speeds with great details.

这是一个很棒的工具tespeed。它非常详细地测试您的上传和下载速度。

回答by sarath

speed testing using iperf is advisable if you want a command line tool for that. Iperf is an awesome tool because of the following reasons:

如果您想要一个命令行工具,建议使用 iperf 进行速度测试。Iperf 是一个很棒的工具,原因如下:

  • It allows you to make parallel connections. It also can modify window
  • size It reports the gitter and dropped packets.
  • Refer the below link for the complete explanation.
  • 它允许您进行并行连接。它也可以修改窗口
  • size 它报告 gitter 和丢弃的数据包。
  • 有关完整说明,请参阅以下链接。

Network speed test using iperf

使用iperf测试网速