Iperf3.1.3移植与使用

一、修改文件

1.根目录Makefile:屏蔽掉examples编译,不屏蔽则编译出错,我们不没用到该工具所以将其屏蔽,如下;

SUBDIRS = src #examples

2.src/Makefile:去掉“-pg”编译选项,屏蔽gprof(剖析工具)使用,因工程中使用GNU工具,会导致在android中编译出错,我们这里不需要优化该工具;

Gprof介绍:

http://www.cnblogs.com/xuxm2007/archive/2012/02/28/2372057.html

二、编译安装

1.生成makefile文件

安卓环境下移植:

./configure --host=arm-linux-androideabi  CC='arm-linux-androideabi-gcc --sysroot=/opt/android-ndk-r10b/platforms/android-9/arch-arm'  CFLAGS=-static CXX='arm-linux-androideabi-g++ --sysroot=/opt/android-ndk-r10b/platforms/android-9/arch-arm' CXXFLAGS=-static --prefix=/usr/local/iperf3.1.3


海思交叉编译器环境下移植:

./configure --host=arm-hisiv100nptl-linux  CFLAGS=-static  CXXFLAGS=-static --prefix=/usr/local/iperf3.1.3

X86环境下移植:

./configure CFLAGS=-static  CXXFLAGS=-static --prefix=/usr/local/iperf3.1.3

注意:-static的作用是将iperf3工具和其动态库编译在一起,如果不加则分开,使用iperf3时必须连同其动态库一起使用;

2.编译安装

执行make distclean;  make;  make install;

三、命令使用

Iperf是一个网络性能测试工具。可以测试TCPUDP带宽质量,可以测量最大TCP带宽,具有多种参数和UDP特性,可以报告带宽,延迟抖动和数据包丢失。Iperflinuxwindows平台均有二进制版本供自由使用。

  

Iperf使用方法与参数说明

参数说明

-s server模式启动,egiperf -s

-c hostclient模式启动,hostserver端地址,egiperf -c 222.35.11.23

通用参数

-f [kmKM] 分别表示以Kbits, Mbits, KBytes, MBytes显示报告,默认以Mbits为单位,egiperf -c 222.35.11.23 -f K

-i sec 以秒为单位显示报告间隔,egiperf -c 222.35.11.23 -i 2

-l 缓冲区大小,默认是8KB,egiperf -c 222.35.11.23 -l 16

-m 显示tcp最大mtu

-o 将报告和错误信息输出到文件egiperf -c 222.35.11.23 -o ciperflog.txt

-p 指定服务器端使用的端口或客户端所连接的端口egiperf -s -p 9999;iperf -c 222.35.11.23 -p 9999

-u 使用udp协议

-w 指定TCP窗口大小,默认是8KB

-B 绑定一个主机地址或接口(当主机有多个地址或接口时使用该参数)

-C 兼容旧版本(当server端和client端版本不一样时使用)

-M 设定TCP数据包的最大mtu

-N 设定TCP不延时

-V 传输ipv6数据包

server专用参数

-D 以服务方式运行iperfegiperf -s -D

-R 停止iperf服务,针对-Degiperf -s -R

client端专用参数

-d 同时进行双向传输测试

-n 指定传输的字节数,egiperf -c 222.35.11.23 -n 100000

-r 单独进行双向传输测试

-t 测试时间,默认10,egiperf -c 222.35.11.23 -t 5

-F 指定需要传输的文件

-T 指定ttl

应用实例

使用 iperf -s 命令将 Iperf 启动为 server 模式,在客户机上使用 iperf -c启动client模式。

iperf s

------------------------------------------------------------

Server listening on TCP port 5001

TCP window size: 8.00 KByte (default)

------------------------------------------------------------

iperf -c 59.128.103.56

上面使用服务端和客户端的默认设置进行测试

iperf -s -w 300K

------------------------------------------------------------

Server listening on TCP port 5001

TCP window size:  300 KByte

------------------------------------------------------------

iperf -c 59.128.103.56 -f K -i 2 -w 300K

       设定报告间隔为2秒,服务器端和客户端的TCP窗口都开到300KB

iperf -c 59.128.103.56 -f K -i 2 -w 300K n 1000000

测试传输约1MB数据

iperf -c 59.128.103.56 -f K -i 2 -w 300K t 36

测试持续36

iperf -c 59.128.103.56 -f K -i 2 -w 300K -n 10400000 d

测试双向的传输

iperf -c 59.128.103.56 -f K -i 2 -w 300K u

UDP测试

其中 -i 参数的含义是周期性报告的时间间隔(interval),单位为秒;在上面的例子中,表示每隔2秒报告一次带宽等信息。

注:该命令说明为转载文章:http://blog.sina.com.cn/s/blog_49ab2ae20100cnig.html

猜你喜欢

转载自blog.csdn.net/edw200/article/details/70502522