搜索
您的当前位置:首页正文

Iperf使用方法与参数说明

来源:意榕旅游网
Iperf使⽤⽅法与参数说明

Iperf是⼀个⽹络性能测试⼯具。可以测试TCP和UDP带宽质量,可以测量最⼤TCP带宽,具有多种参数和UDP特性,可以报告带宽,延迟抖动和数据包丢失。Iperf在linux和windows平台均有⼆进制版本供⾃由使⽤。

Iperf was developed by NLANRDAST as a modern alternative for measuring maximum TCP and UDP bandwidth

performance. Iperf allows the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter,datagram loss.

Iperf使⽤⽅法与参数说明 参数说明

-s 以server模式启动,eg:iperf -s

-c host以client模式启动,host是server端地址,eg:iperf -c 222.35.11.23 通⽤参数

-f [kmKM] 分别表⽰以Kbits, Mbits, KBytes, MBytes显⽰报告,默认以Mbits为单位,eg:iperf -c 222.35.11.23 -f K-i sec 以秒为单位显⽰报告间隔,eg:iperf -c 222.35.11.23 -i 2-l 缓冲区⼤⼩,默认是8KB,eg:iperf -c 222.35.11.23 -l 16-m 显⽰tcp最⼤mtu值

-o 将报告和错误信息输出到⽂件eg:iperf -c 222.35.11.23 -o ciperflog.txt

-p 指定服务器端使⽤的端⼝或客户端所连接的端⼝eg:iperf -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 以服务⽅式运⾏iperf,eg:iperf -s -D-R 停⽌iperf服务,针对-D,eg:iperf -s -R

client端专⽤参数-d 同时进⾏双向传输测试

-n 指定传输的字节数,eg:iperf -c 222.35.11.23 -n 100000

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

-t 测试时间,默认10秒,eg:iperf -c 222.35.11.23 -t 5-F 指定需要传输的⽂件-T 指定ttl值 应⽤实例

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

------------------------------------------------------------Server listening on TCP port 5001TCP window size: 8.00 KByte (default)------------------------------------------------------------

iperf -c 59.128.103.56

上⾯使⽤服务端和客户端的默认设置进⾏测试

iperf -s -w 300K

------------------------------------------------------------Server listening on TCP port 5001TCP 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秒报告⼀次带宽等信息。

启动⼀个iperf服务器进程

  ⾸先要介绍的命令⽤来启动iperf服务器监听进程以便监听客户端连接的。命令如下:  iperf.exe -s -P 2 -i 5 -p 5999 -f k

  这个命令会启动iperf,后续参数⽤来设定监听5999 端⼝(默认端⼝是5001), 限定iperf只允许两个连接,每5秒汇报⼀次连接情况。连接限制参数(-P参数)⾮常重要,当两个连接建⽴后,服务器进程就会退出。如果这个参数设定为0,那么iperf 进程将持续监听端⼝,并且不限制连接数量。在 Windows主机上键⼊该命令,会显⽰出如图A所⽰界⾯  图 A  

  启动⼀个iperf 客户端连接

  iperf 的另⼀半就是客户端,⽤来连接到服务器监听端⼝。⽐如我们要连接到⼀台叫做 s-network1.amcs.tld 的服务器,端⼝为5999,连接60 秒并且每5秒显⽰⼀次状态,命令⾏如下:  iperf.exe -c s-network1.amcs.tld -P 1 -i 5 -p 5999 -f B -t 60 -T 1

  命令启动后,s-network1 主机被⽤来进⾏⽹络性能检测。与Jperf GUI 界⾯提供的漂亮图形不同, iperf只会根据测量参数简单的报告⽹络带宽状况,在本例中是以 ⽐特为单位(-f 参数)进⾏带宽表⽰的。图B显⽰了远程客户端与s-network1主机间的带宽性能。  图 B  

  为了应对⽇常便捷应⽤的需求,我们可以建⽴⼀个 .bat批处理⽂件,届时填⼊服务器名称即可实现快速检测。以下为实际使⽤的拷屏:

C:\\jperf\\jperf\\bin>iperf

Usage: iperf [-s|-c host] [options]

Try `iperf --help' for more information.C:\\jperf\\jperf\\bin>iperf --helpUsage: iperf [-s|-c host] [options] iperf [-h|--help] [-v|--version]

Client/Server:

-f, --format [kmKM] format to report: Kbits, Mbits, KBytes, MBytes -i, --interval # seconds between periodic bandwidth reports -l, --len #[KM] length of buffer to read or write (default 8 KB)

-m, --print_mss print TCP maximum segment size (MTU - TCP/IP header) -o, --output output the report or error message to this specified file -p, --port # server port to listen on/connect to -u, --udp use UDP rather than TCP

-w, --window #[KM] TCP window size (socket buffer size)

-B, --bind bind to , an interface or multicast address -C, --compatibility for use with older versions does not sent extra msgs -M, --mss # set TCP maximum segment size (MTU - 40 bytes) -N, --nodelay set TCP no delay, disabling Nagle's Algorithm -V, --IPv6Version Set the domain to IPv6

Server specific:

-s, --server run in server mode

-D, --daemon run the server as a daemon -R, --remove remove service in win32

Client specific:

-b, --bandwidth #[KM] for UDP, bandwidth to send at in bits/sec (default 1 Mbit/sec, implies -u)

-c, --client run in client mode, connecting to -d, --dualtest Do a bidirectional test simultaneously

-n, --num #[KM] number of bytes to transmit (instead of -t) -r, --tradeoff Do a bidirectional test individually

-t, --time # time in seconds to transmit for (default 10 secs) -F, --fileinput input the data to be transmitted from a file -I, --stdin input the data to be transmitted from stdin -L, --listenport # port to recieve bidirectional tests back on -P, --parallel # number of parallel client threads to run -T, --ttl # time-to-live, for multicast (default 1)Miscellaneous:

-h, --help print this message and quit

-v, --version print version information and quit

[KM] Indicates options that support a K or M suffix for kilo- or mega-The TCP window size option can be set by the environment variable

TCP_WINDOW_SIZE. Most other options can be set by an environment variableIPERF_, such as IPERF_BANDWIDTH.

因篇幅问题不能全部显示,请点此查看更多更全内容

Top