『iperf3 』服务器连接速度测试

简介: 『iperf3 』服务器连接速度测试

文章目录


一、简介

1.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。

96318c3c0c19ad3ae175e230822cbad0_4a969183292c4d3ba1efc329e521a6d5.png

二、安装iperf

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

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

2.1 windows中下载与构建

下载windows版

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

bb10a4c65396e2314b19a7ca0c3bdb8c_03b428485010450497a7f2a1c096c367.png

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

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)

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

5954ed0150a1f6b007a8f9fad96a1428_5e818b21d4fd42d29c345a5128b037dc.png

测速过程为:


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


服务器开始监听(ubuntu中直接运行下列命令):

iperf3 -s

本地主机连接测速(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: 美国服务器连接速度测试

c978c6b2b5e898a4624d5403b26c28a8_0a1a53075150458bb401ee2e3660d914.png

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

3.2 服务器网速测试

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

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

使用speedtest测速即可。

安装命令行工具:

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

e84fba63354d751d1e91de4a2a5b5b40_1b2f4c04be1d4eadb5de4c870b667145.png

相关文章
|
6天前
|
关系型数据库 MySQL 数据库
6-2|测试连接数据库的命令
6-2|测试连接数据库的命令
|
9天前
|
JavaScript 前端开发
vue配合axios连接express搭建的node服务器接口_简单案例
文章介绍了如何使用Express框架搭建一个简单的Node服务器,并使用Vue结合Axios进行前端开发和接口调用,同时讨论了开发过程中遇到的跨域问题及其解决方案。
12 0
vue配合axios连接express搭建的node服务器接口_简单案例
|
2月前
|
关系型数据库 MySQL 网络安全
有关使用Navicat 无法成功连接腾讯云服务器上Mysql的问题解决
这篇文章提供了解决Navicat无法连接腾讯云服务器上MySQL问题的步骤,包括调整防火墙设置、更新MySQL权限和检查远程连接配置。
有关使用Navicat 无法成功连接腾讯云服务器上Mysql的问题解决
|
2月前
|
数据可视化 Ubuntu Linux
PyCharm连接远程服务器配置的全过程
相信很多人都遇见过这种情况:实验室成员使用同一台服务器,每个人拥有自己的独立账号,我们可以使用服务器更好的配置完成实验,毕竟自己哪有money拥有自己的3090呢。 通常服务器系统采用Linux,而我们平常使用频繁的是Windows系统,二者在操作方面存在很大的区别,比如我们实验室的服务器采用Ubuntu系统,创建远程交互任务时可以使用Terminal终端或者VNC桌面化操作,我觉得VNC很麻烦,所以采用Terminal进行实验,但是Terminal操作给我最不好的体验就是无法可视化中间实验结果,而且实验前后的数据上传和下载工作也让我头疼不已。
|
2月前
|
网络安全
mac下通过ssh脚本实现免账号密码连接运服务器
mac下通过ssh脚本实现免账号密码连接运服务器
36 3
|
2月前
|
监控 网络安全 数据安全/隐私保护
Mac服务器ssh连接工具
Mac服务器ssh连接工具
59 2
|
2月前
|
网络安全 数据安全/隐私保护
VSC通过 SSH 连接到远程服务器时,每次都需要输入密码
VSC通过 SSH 连接到远程服务器时,每次都需要输入密码
196 0
|
2月前
|
Linux 网络安全 网络架构
如何处理在学校Linux连接不上服务器
如何处理在学校Linux连接不上服务器
39 0
|
2月前
|
网络协议 安全 架构师
详解 | 一台服务器最大能支持多少条TCP连接?
详解 | 一台服务器最大能支持多少条TCP连接?
百万并发连接的实践测试02
百万并发连接的实践测试02

热门文章

最新文章

下一篇
无影云桌面