『iperf3 』服务器连接速度测试(2023/02/16 最新版)
  XNNIEyXQkqUG 2023年11月02日 42 0



文章目录

  • 一、简介
  • 1.1 我的测速需求
  • 1.2 iperf
  • 二、安装iperf
  • 2.1 windows中下载与构建
  • 2.2 Ubuntu中下载与构建
  • 三、测速
  • 3.1 连接速度测试
  • 3.2 服务器网速测试


一、简介

1.1 我的测速需求

我目前有2个需求:

  1. 测试服务器的上传、下载速度;
  2. 测试与服务器的连接网速。

一般来说,服务器的带宽在购买服务器时就确定了(购买按流量计费的服务器除外),但额定带宽与实际带宽往往有一些出入。

而服务器与本地主机连接的带宽通常取决于两者中带宽较小的那个;但我有一个国外的服务器,连接的网速还与物理距离等多种因素有关。

第一个需求,可以使用speedtest等来实现,不是文章主要内容,放在文末吧。

1.2 iperf

iperf 是一种用于主动测量 IP 网络上可实现的最大带宽的工具。它支持调整与时序、协议和缓冲区相关的各种参数。对于每个测试,它都会报告测得的吞吐量/比特率、丢失和其他参数。最新版本称为iperf3

The iperf series of tools perform active measurements to determine the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, protocols, and buffers. For each test it reports the measured throughput, loss, and other parameters.

最新release版本是2023年2月发布的3.13。

github项目地址:https://github.com/esnet/iperf

官网:https://software.es.net/iperf/#

『iperf3 』服务器连接速度测试(2023/02/16 最新版)_github

二、安装iperf

官网只有源码的压缩包,需要下载下来,自己构建,很简单的。

在测试的两台主机分别安装iperf即可。最好安装一样的版本,安装最新iperf3即可。

2.1 windows中下载与构建

在这个仓库下载windows版:https://github.com/ar51an/iperf3-win-builds/releases

下载完后,解压即可,不用安装。

『iperf3 』服务器连接速度测试(2023/02/16 最新版)_运维_02


当然你也可以下载源码,自己构建。

2.2 Ubuntu中下载与构建

(1)下载文件,是个压缩包

wget  https://downloads.es.net/pub/iperf/iperf-3-current.tar.gz

(没有wget自己apt安装一下,压缩包不要可以删了)

(2)解压文件

按照这个命令格式来就行,不一样复制我的是吧,可能名称啥的不一样。

tar -zxvf iperf-3-current.tar.gz

(3)进入解压后的文件夹

cd /root/iperf-3.13

(4)运行配置:

./configure

(5)编译

make

(6) 安装

make install

*(7) 删除不要的文件

cd.. &&rm iperf-3-current.tar.gz && rm -r iperf-3.13

三、测速

3.1 连接速度测试

iperf使用tcp的5201端口,如果打开了防火墙,放行此端口就可以了。

root@cquptlei:~# ufw allow 5201/tcp
Rule added
Rule added (v6)

在服务器的管理后台也看一下,比如:腾讯云

『iperf3 』服务器连接速度测试(2023/02/16 最新版)_服务器_03


测速过程为:

一个作为server,一个作为client。

  1. 服务器开始监听(ubuntu中直接运行下列命令):
iperf3 -s
  1. 本地主机连接测速(windows进入iperf文件目录下在使用下面命令,或者你把目录添加到环境变量也行)
iperf3 -c 服务器ip

一般来说,只能是服务器做server,因为本地电脑一般没有公网ip

示例1: 腾讯云服务器连接速度测试
服务器:

root@CQUPTLEI:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from x.x.x.x, port 1088
[  5] local 10.0.8.5 port 5201 connected to x.x.x.x port 1089
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  4.00 MBytes  33.6 Mbits/sec                  
[  5]   1.00-2.00   sec  5.25 MBytes  44.0 Mbits/sec                  
[  5]   2.00-3.00   sec  5.25 MBytes  44.0 Mbits/sec                  
[  5]   3.00-4.00   sec  2.18 MBytes  18.2 Mbits/sec                  
[  5]   4.00-5.00   sec  4.95 MBytes  41.5 Mbits/sec                  
[  5]   5.00-6.00   sec   990 KBytes  8.11 Mbits/sec                  
[  5]   6.00-7.00   sec  1.19 MBytes  9.94 Mbits/sec                  
[  5]   7.00-8.00   sec  1.64 MBytes  13.8 Mbits/sec                  
[  5]   8.00-9.00   sec  2.10 MBytes  17.6 Mbits/sec                  
[  5]   9.00-10.00  sec  2.53 MBytes  21.2 Mbits/sec                  
[  5]  10.00-10.04  sec   111 KBytes  24.5 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.04  sec  30.2 MBytes  25.2 Mbits/sec                  receiver

本地电脑:

D:\iperf>iperf3 -c x.x.x.x
Connecting to host x.x.x.x, port 5201
[  4] local x.x.x.x port 7057 connected to x.x.x.x port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  4.25 MBytes  35.6 Mbits/sec
[  4]   1.00-2.00   sec  5.25 MBytes  44.0 Mbits/sec
[  4]   2.00-3.00   sec  5.25 MBytes  44.1 Mbits/sec
[  4]   3.00-4.00   sec  2.12 MBytes  17.8 Mbits/sec
[  4]   4.00-5.00   sec  5.00 MBytes  42.0 Mbits/sec
[  4]   5.00-6.00   sec   896 KBytes  7.34 Mbits/sec
[  4]   6.00-7.00   sec  1.25 MBytes  10.5 Mbits/sec
[  4]   7.00-8.00   sec  1.62 MBytes  13.6 Mbits/sec
[  4]   8.00-9.00   sec  2.12 MBytes  17.8 Mbits/sec
[  4]   9.00-10.00  sec  2.50 MBytes  21.0 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  30.2 MBytes  25.4 Mbits/sec                  sender
[  4]   0.00-10.00  sec  30.2 MBytes  25.3 Mbits/sec                  receiver

iperf Done.

示例2: 美国服务器连接速度测试

『iperf3 』服务器连接速度测试(2023/02/16 最新版)_运维_04

可以看到连接速度很低(我的服务器带宽是1G),主要原因是延迟和bgp。

3.2 服务器网速测试

现在测试服务器本身的上传和下载速度。

比如美国的服务器,它本身的带宽很高,但是与我的电脑连接速度可能很慢,甚至被block。

使用speedtest测速即可。

官网:speedtest.net

安装命令行工具:

sudo apt-get install curl
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
sudo apt-get install speedtest

使用:

speedtest

或者列出最近的测试服务器:

speedtest -L

如:

Closest servers:

    ID  Name                           Location             Country
==============================================================================
 33893  Airlink Internet Inc           Los Angeles, CA      United States
 52470  Host Sailor Ltd                Los Angeles, CA      United States
 14236  Frontier                       Los Angeles, CA      United States
 12191  Nitel                          Los Angeles, CA      United States
 18401  Windstream                     Los Angeles, CA      United States
 17249  Wiline Networks                Los Angeles, CA      United States
 37498  Netprotect                     Los Angeles, CA      United States

然后指定测试服务器ip进行测试:

speedtest -s ID

『iperf3 』服务器连接速度测试(2023/02/16 最新版)_服务器_05




把 永 远 爱 你 写 进 诗 的 结 尾 ~


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

XNNIEyXQkqUG