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

摘要:
防火墙规则修改方法:防火墙会阻止两台电脑之间的通信。centos7.0自带的防火墙为firewalld,可以先把firewalld删除,再安装iptalbes。

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      setCPU affinity
  -B, --bind      <host>    bind to a specific interface
  -V, --verbose             more detailed output
  -J, --json                output inJSON format
  -d, --debug               emit debugging output
  -v, --version             show version information and quit
  -h, --help                show thismessage and quit
Server specific:
  -s, --server              run inserver mode
  -D, --daemon              run the server asa 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 forunlimited)
                            (default 1 Mbit/sec for UDP, unlimited forTCP)
                            (optional slash and packet count forburst mode)
  -t, --time      #         time in seconds to transmit for (default 10secs)
  -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 forUDP)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run inreverse mode (server sends, client receives)
  -w, --window    #[KMG]    TCP window size (socket buffer size)
  -C, --linux-congestion <algo>  setTCP congestion control algorithm (Linux only)
  -M, --set-mss   #         set TCP maximum segment size (MTU - 40bytes)
  -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         setthe 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 fromserver

[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
3. Apple手机测试
开发板host,ip:172.27.0.25,App手机做client:
测试UDP:
开发板:# iperf -V -s -u
手机:iperf -p 5001 -l 1448 -w 131072 -i 1.0 -u -c 172.27.0.25 -t 10.0 -b 100m
测试TCP:
开发板:# iperf -V -s
手机:iperf -p 5001 -l 131072 -w 131072 -i 1.0 -c 172.27.0.25 -t 10.0
开发板client,App手机做service,ip:172.27.0.165测试TCP:
开发板:# iperf -c 172.27.0.165 -w 128k -t 10.0 -i 1.0 -p 6001手机:# iperf -p 6001 -l 131072 -w 131072 -i 1.0 -s
测试UDP:
开发板:# iperf -c 172.27.0.165 -w 128k -t 10.0 -i 1.0 -p 6001 -l 1448 -u -b 50m
手机:# iperf -p 6001 -l 1448 -w 131072 -i 1.0 -u -s

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

5.软件包中的test_command.sh

#!/bin/sh
#
# This is a set of commands to run and verify they work before doing a newrelease.
# Eventually they should also use the -J flag to generate JSON output, and a program should 
# be written to check the output.
# Be sure to test both client and server on Linux, BSD, and OSX
#

if [ $# -ne 1]
then
  echo "Usage: `basename $0` hostname"exit $E_BADARGS
fi

set -x

host=$1
# basic testing
./src/iperf3 -c $host -V -t 5 -T "test1"./src/iperf3 -c $host -u -V -t 5# omit mode
./src/iperf3 -c $host -i .3 -O 2 -t 5# JSON mode
./src/iperf3 -c $host -i 1 -J -t 5# force V4
./src/iperf3 -c $host -4 -t 5./src/iperf3 -c $host -4 -u -t 5# force V6
./src/iperf3 -c $host -6 -t 5./src/iperf3 -c $host -6 -u -t 5# parallel streams
./src/iperf3 -c $host -P 3 -t 5./src/iperf3 -c $host -u -P 3 -t 5# reverse mode
./src/iperf3 -c $host -P 2 -t 5 -R
./src/iperf3 -c $host -u -P 2 -t 5 -R
# zero copy
./src/iperf3 -c $host -Z -t 5./src/iperf3 -c $host -Z -t 5 -R
# window size
./src/iperf3 -c $host -t 5 -w 8M 
# -n flag
./src/iperf3 -c $host -n 5M  
./src/iperf3 -c $host -n 5M -u -b1G
# conflicting -n -t flags
./src/iperf3 -c $host -n 5M -t 5# -k mode
./src/iperf3 -c $host -k 1K  
./src/iperf3 -c $host -k 1K -u -b1G
# CPU affinity
./src/iperf3 -c $host -A 2/2./src/iperf3 -c $host -A 2/2 -u -b1G
# Burst mode
./src/iperf3 -c $host -u -b1G/100# change MSS
./src/iperf3 -c $host -M 1000 -V
# test congestion control option (linux only)
./src/iperf3 -c $host -C reno -V

6. 若网络媒体出现卡顿可以是用iperf测试卡顿时网络的带宽,以定位是否是底层问题。

免责声明:文章转载自《iperf/iperf3网络测试工具的安装与使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Oracle 通过触发器 来创建 同步临时表 及处理 通过 自治事务 来解决 查询 基表的问题iOS学习笔记(5)形参个数可变的方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

查看IP和MAC地址的命令

[基于MS]查看MAC地址命令: 1、使用ipconfig /all,可以看到具体配置。(查看IP地址,网关,DNS MAC地址等) 2、如果和局域网中的其它计算机通信过的话,可以用arp -a命令查看其MAC地址。 3、另外还可以用nbtstat -a [IP],不过只能查看某台具体机器的MAC地址(查看其他机器的MAC地址)。 [基于MS]查看IP地...

几种cmd下的网络命令

网络命令可以分为三类:网络监测(如ping),网络连接(如telnet),网络配置(如netsh)。关于网络监测的命令:一。ping这个命令是常用的并且是效果最好的网络监测命令。例: C:\>ping 61.129.45.177 Pinging 61.129.45.177 with 32 bytes of data: (程序默认每个数据包的大小为32...

Android : iperf-2.0.4 网络测试工具

一、源码下载及交叉编译: 下载:https://pan.baidu.com/s/1i6NYDF3   //包含linux和windows上的可执行文件 1. 解压后获得perf-2.0.4源码。2. cd iperf-2.0.43. ./configure --host=arm-linux CXX=arm-linux-androideabi-g++ CC=...

docker命令之link

1.新建两台容器,第二台(busybox_2)link到第一台(busybox_1) [root@localhost ~]# docker run -d -it --name busybox_1 busybox /bin/sh -c "while true;do sleep 3600;done" 8240c9aa04e3b5653c6747ae13a4e4...

利用iperf进行WiFi吞吐量的测试方法

一、WiFi模块在出厂前要进行吞吐量的测试,吞吐量指标不过关就得查原因返修。 二、windows xp上的测试方法 1,准备两台电脑、一台路由器,一台电脑用有线连接路由的LAN口,另一台电脑用无线连接路由 2,将iperf.exe软件放入两台电脑的c:windowssystem32目录,以方便在cmd命令窗口下执行iperf命令 3,用接有线的电脑做服务端...

20169205 2016-2017-2 《网络攻防技术》第7周学习总结

20169205 2016-2017-2 《网络攻防技术》第7周学习总结 教材学习内容总结 课本第七章主要围绕windows操作系统安全攻防技术进行讲述,教材中主要涉及的攻击内容如下: Windows操作系统的基本结构 运行于处理器特权模式的操作系统内核 运行在处理器非特权模式的用户空间代码 采用宏内核模式来进行构架 Windows操作系统内核...