0. 简介
iPerf3是一款网络测试工具,主要用来测试网络带宽、丢包率和吞吐量等。
1. 安装
iPerf3的安装比较简单,当然,也可以直接去官网下载安装包安装。
1.1 Mac
利用brew安装即可:
$ brew install iperf3
1.2 Linux
利用yum或者apt工具安装:
$ apt-get install iperf3
2. 使用
2.1 iPerf常用参数
下面介绍iPerf比较常见的参数,其他的,还请通过iperf3 --help查看。
| 参数 | 描述 |
|---|---|
-s/--server | iPerf服务器模式,默认端口5201 |
-c/--client | 指定客户端模式,后面跟<host>;若服务器模式,表指定固定客户端ip |
-i/--interval | 每次报告之间的时间间隔,单位s |
-p/--port | 指定服务端监听或者客户端连接的端口 |
-u/--udp | 表示采用UDP协议发送报文,不带该参数表示默认TCP协议 |
-t/--time | 表示数据传输的总时间,默认10s |
2.2 测试
服务端
$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
先在服务端起个服务,然后设置客户端。
客户端
$ iperf3 -c 10.117.49.12 -t 60 -d
send_parameters:
{
"tcp": true,
"omit": 0,
"time": 60,
"parallel": 1,
"len": 131072,
"pacing_timer": 1000,
"client_version": "3.7"
}
Connecting to host 10.117.49.12, port 5201
SNDBUF is 16384, expecting 0
RCVBUF is 131072, expecting 0
Congestion algorithm is cubic
[ 5] local 10.117.48.230 port 53994 connected to 10.117.49.12 port 5201
sent 87600 bytes of 131072, total 87600
sent 0 bytes of 131072, total 87600
sent 0 bytes of 131072, total 87600
...
最后客户端的结果显示:
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-60.00 sec 8.89 MBytes 1.24 Mbits/sec 606 sender
[ 5] 0.00-60.00 sec 8.63 MBytes 1.21 Mbits/sec receiver
iperf Done.
其中,上行是1.24 Mbits/sec,下载是1.21 Mbits/sec。