Please enable Javascript to view the contents

网络性能测试工具 iperf

 ·  ☕ 2 分钟

1. 安装

Ubuntu

1
apt-get install -y iperf3

CentOS

1
yum install -y iperf3

2. 参数

iperf3 的原理是通过客户端给服务端发送数据包来分析网络,有两种运行模式,客户端和服务端。

iperf3 的参数分为三部分,公共参数,客户端参数,服务端参数。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
iperf3 -help

Server or Client:
  -p, --port      #         server port to listen on/connect to
  -f, --format    [kmgKMG]  format to report: Kbits, Mbits, KBytes, MBytes
  -i, --interval  #         seconds between periodic bandwidth reports
  -F, --file name           xmit/recv the specified file
  -A, --affinity n/n,m      set CPU affinity
  -B, --bind      <host>    bind to a specific interface
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  --logfile f               send output to a log file
  --forceflush              force flushing output at every interval
  -d, --debug               emit debugging output
  -v, --version             show version information and quit
  -h, --help                show this message and quit
Server specific:
  -s, --server              run in server mode
  -D, --daemon              run the server as a daemon
  -I, --pidfile file        write PID file
  -1, --one-off             handle one client connection then exit
Client specific:
  -c, --client    <host>    run in client mode, connecting to <host>
  -u, --udp                 use UDP rather than TCP
  -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  --fq-rate #[KMG]          enable fair-queuing based socket pacing in
                            bits/sec (Linux only)
  -t, --time      #         time in seconds to transmit for (default 10 secs)
  -n, --bytes     #[KMG]    number of bytes to transmit (instead of -t)
  -k, --blockcount #[KMG]   number of blocks (packets) to transmit (instead of -t or -n)
  -l, --len       #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, dynamic or 1 for UDP)
  --cport         <port>    bind to a specific client port (TCP and UDP, default: ephemeral port)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run in reverse mode (server sends, client receives)
  -w, --window    #[KMG]    set window size / socket buffer size
  -C, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)
  -M, --set-mss   #         set TCP/SCTP maximum segment size (MTU - 40 bytes)
  -N, --no-delay            set TCP/SCTP no delay, disabling Nagle's Algorithm
  -4, --version4            only use IPv4
  -6, --version6            only use IPv6
  -S, --tos N               set the IP 'type of service'
  -L, --flowlabel N         set the IPv6 flow label (only supported on Linux)
  -Z, --zerocopy            use a 'zero copy' method of sending data
  -O, --omit N              omit the first n seconds
  -T, --title str           prefix every output line with this string
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets

3. 测试

  • 服务端
1
iperf3 -s -i 1 -p 30000
  • 客户端

测试 TCP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
iperf3 -c 1.2.3.4 -p 30000 -i 1

Connecting to host 1.2.3.4, port 30000
[  4] local 2.3.4.5 port 44794 connected to 1.2.3.4 port 30000
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   911 MBytes  7.64 Gbits/sec   98   1.21 MBytes       
...
[  4]   9.00-10.00  sec   910 MBytes  7.63 Gbits/sec   13   1.16 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  9.18 GBytes  7.88 Gbits/sec  231             sender
[  4]   0.00-10.00  sec  9.17 GBytes  7.88 Gbits/sec                  receiver

测试 UDP,包大小 1460 bit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
iperf3 -c 1.2.3.4 -p 30000 -i 1 -u -l 1460

Connecting to host 1.2.3.4, port 30000
[  4] local 2.3.4.5 port 57562 connected to 1.2.3.4 port 30000
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec   116 KBytes   946 Kbits/sec  1183  
...
[  4]   9.00-10.00  sec   128 KBytes  1.05 Mbits/sec  1310  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-10.00  sec  1.24 MBytes  1.04 Mbits/sec  0.012 ms  33/12979 (0.25%)  
[  4] Sent 12979 datagrams

微信公众号
作者
微信公众号