安装
大部分系统标配工具:
yum install -y iperf3
参数
常用的参数如下,其他参数请-h
Server or Client:-p, --port # server port to listen on/connect to-f, --format [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits-i, --interval # seconds between periodic throughput reports-F, --file name xmit/recv the specified file-A, --affinity n/n,m set CPU affinity-B, --bind <host> bind to the interface associated with the address <host>
Server specific:-s, --server run in server mode
Client specific:-c, --client <host> run in client mode, connecting to <host>-u, --udp use UDP rather than TCP-t, --time # time in seconds to transmit for (default 10 secs)-l, --length #[KMG] length of buffer to read or write(default 128 KB for TCP, dynamic or 1460 for UDP)-P, --parallel # number of parallel client streams to run-R, --reverse run in reverse mode (server sends, client receives)-4, --version4 only use IPv4--get-server-output get results from server
简单案例
host1执行
# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
host2执行
# iperf3 -c host1 -f m -i 1 -t 5 -P 1 -4 --get-server-output
Connecting to host host1, port 5201
[ 5] local host2 port 53270 connected to host1 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 497 MBytes 4165 Mbits/sec 0 1.77 MBytes
[ 5] 1.00-2.00 sec 494 MBytes 4151 Mbits/sec 0 2.07 MBytes
[ 5] 2.00-3.00 sec 501 MBytes 4203 Mbits/sec 0 2.07 MBytes
[ 5] 3.00-4.00 sec 486 MBytes 4074 Mbits/sec 0 2.07 MBytes
[ 5] 4.00-5.00 sec 499 MBytes 4197 Mbits/sec 0 2.07 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-5.00 sec 2.42 GBytes 4158 Mbits/sec 0 sender
[ 5] 0.00-5.00 sec 2.42 GBytes 4156 Mbits/sec receiverServer output:
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from host2, port 53268
[ 5] local host1 port 5201 connected to host2 port 53270
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 496 MBytes 4.16 Gbits/sec
[ 5] 1.00-2.00 sec 494 MBytes 4.15 Gbits/sec
[ 5] 2.00-3.00 sec 501 MBytes 4.21 Gbits/sec
[ 5] 3.00-4.00 sec 486 MBytes 4.08 Gbits/sec
[ 5] 4.00-5.00 sec 500 MBytes 4.19 Gbits/sec
[ 5] 5.00-5.00 sec 252 KBytes 4.08 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-5.00 sec 2.42 GBytes 4.16 Gbits/sec receiveriperf Done.
压测方法
-l参数可以控制发包大小,默认是128KB的包,可以用tcpdump抓下应用发包大小,做下模拟。
抓包看包大小平均值:
tcpdump -ttt -n -i eth1 -s 0 host aaa and host bbb and tcp -w s.pcap
tcpdump -t -nn -r s.pcap | grep -v ', length 0' | awk '{sum += $NF; count++} END {print sum/count}'
-P参数可以控制并发量,要压测的话需要多一些并发。