iperf3网络测试工具的安装与使用

1.官网及下载路径:

iperf3 homepage at: http://software.es.net/iperf/
Report bugs to: https://github.com/esnet/iperf

2.iperf3命令选项

[ubuntu @meta]$ iperf3 
iperf3: parameter error - must either be a client (-c) or server (-s)

Usage: iperf [-s|-c host] [options]
       iperf [-h|--help] [-v|--version]

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
  -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
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)
  -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, 8 KB for UDP)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run in reverse mode (server sends, client receives)
  -w, --window    #[KMG]    TCP window size (socket buffer size)
  -C, --linux-congestion <algo>  set TCP congestion control algorithm (Linux only)
  -M, --set-mss   #         set TCP maximum segment size (MTU - 40 bytes)
  -N, --nodelay             set TCP 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

[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: http://software.es.net/iperf/
Report bugs to:     https://github.com/esnet/iperf

3.iperf3的测试例子

测试1:
一台电脑本地回环测试
打开两个终端t1和t2,在t1中输入命令:iperf3 -s 在t2中输入命令: iperf3 -c 127.0.0.1 -t 5
本例中t2向t1发送5秒中的数据包
测试2:
一台电脑的实际网卡:
打开两个终端t1和t2,在t1中输入命令:iperf3 -s 在t2中输入命令: iperf3 -c 10.219.119.21
测试3:
两台电脑之间发包测试,在电脑A中打开终端t1,在电脑B中打开终端t2,确保两台电脑在同一个局域网中并假设t1的IP地址为192.168.1.123,t2的IP地址为192.168.1.124
在t1中输入命令: iperf3 -s 在t2中输入命令: iperf3 -c 192.168.1.123 -t 5
如果出现错误iperf3: error - unable to connect to server: No route to host,请修改电脑A的防火墙规则。

防火墙规则修改方法:
防火墙会阻止两台电脑之间的通信。centos7.0自带的防火墙为firewalld,可以先把firewalld删除,再安装iptalbes。
在t1中输入以下两条的命令来停用firewalld: 
1.删除firewalld的命令如下
sudo systemctl stop firewalld //关闭
sudo systemctl disable firewalld //禁止开机启动
2.安装iptables的命令如下 
sudo yum install -y iptables-services.x86_64 iptables-devel.x86_64
重新测试iperf3,在t1中输入命令: 
sudo iptables -I INPUT 1 -s 192.168.1.124 -j ACCEPT
sudo service iptables save
iperf3 -s
在t2中输入命令: 
iperf3 -c 192.168.1.123 -t 5

4.iperf3卸载
查看所有已经安装的软件:
sudo yum list installed
删除iperf3:
sudo yum -y remove iperf3.x86_64

猜你喜欢

转载自www.cnblogs.com/hellokitty2/p/9350606.html