[关闭]
@qidiandasheng 2019-11-19T08:38:30.000000Z 字数 4409 阅读 3766

网速测试利器-iperf3

使用工具


简介

iperf3是一个网络速度测试工具,支持IPv4与IPv6,支持TCP、UDP、SCTP传输协议,可在Windows、Mac OS X、Linux、FreeBSD等各种平台使用,是一个简单又实用的小工具。 本文介绍安装、使用iperf3 网速测试工具。

安装

Ubuntu安装

  1. sudo apt-get install iperf3

CentOS安装

  1. yum install iperf3

MAC OS X安装

  1. brew install iperf3

网络带宽测试

在使用iperf3测试时,要同时在server端与client端都各执行一个程序,让它们互相传送报文进行测试。

首先在服务端(48.77.234.178)启动server端的程序:

  1. iperf3 -s

接着在client端执行:

  1. iperf3 -c 48.77.234.178

测试结果

从打印的内容看,缺省参数下,Client将连接Server端的5201端口,持续向Server端发送数据,并统计出每秒传输的字节数、带宽、出现报文重传的次数、拥塞窗口(Congestion Window)大小,整个测试将持续10秒钟;最后将汇总10秒的平均数据,并给出发送和接收端的统计。

Client端

  1. [ ID] Interval Transfer Bitrate Total Datagrams
  2. [ 5] 0.00-1.01 sec 129 KBytes 1.05 Mbits/sec 95
  3. [ 5] 1.01-2.01 sec 125 KBytes 1.02 Mbits/sec 92
  4. [ 5] 2.01-3.00 sec 131 KBytes 1.09 Mbits/sec 97
  5. [ 5] 3.00-4.00 sec 127 KBytes 1.04 Mbits/sec 94
  6. [ 5] 4.00-5.00 sec 129 KBytes 1.05 Mbits/sec 95
  7. [ 5] 5.00-6.00 sec 127 KBytes 1.04 Mbits/sec 94
  8. [ 5] 6.00-7.00 sec 127 KBytes 1.04 Mbits/sec 94
  9. [ 5] 7.00-8.00 sec 129 KBytes 1.06 Mbits/sec 95
  10. [ 5] 8.00-9.00 sec 127 KBytes 1.04 Mbits/sec 94
  11. [ 5] 9.00-10.00 sec 126 KBytes 1.03 Mbits/sec 93
  12. - - - - - - - - - - - - - - - - - - - - - - - - -
  13. [ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
  14. [ 5] 0.00-10.00 sec 1.25 MBytes 1.05 Mbits/sec 0.000 ms 0/943 (0%) sender
  15. [ 5] 0.00-10.30 sec 1.24 MBytes 1.01 Mbits/sec 9.435 ms 8/942 (0.85%) receiver
  16. iperf Done.

server端

  1. [ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
  2. [ 5] 0.00-1.00 sec 71.8 KBytes 588 Kbits/sec 3431041313.248 ms 0/53 (0%)
  3. [ 5] 1.00-2.00 sec 146 KBytes 1.20 Mbits/sec 3223480.936 ms 0/108 (0%)
  4. [ 5] 2.00-3.00 sec 123 KBytes 1.01 Mbits/sec 9083.840 ms 2/93 (2.2%)
  5. [ 5] 3.00-4.00 sec 130 KBytes 1.07 Mbits/sec 26.471 ms 0/96 (0%)
  6. [ 5] 4.00-5.00 sec 117 KBytes 955 Kbits/sec 6.871 ms 4/90 (4.4%)
  7. [ 5] 5.00-6.00 sec 134 KBytes 1.10 Mbits/sec 11.419 ms 0/99 (0%)
  8. [ 5] 6.00-7.00 sec 126 KBytes 1.03 Mbits/sec 9.642 ms 0/93 (0%)
  9. [ 5] 7.00-8.00 sec 108 KBytes 888 Kbits/sec 7.776 ms 0/80 (0%)
  10. [ 5] 8.00-9.00 sec 145 KBytes 1.19 Mbits/sec 9.401 ms 1/108 (0.93%)
  11. [ 5] 9.00-10.00 sec 129 KBytes 1.05 Mbits/sec 9.824 ms 1/96 (1%)
  12. [ 5] 10.00-10.30 sec 35.2 KBytes 979 Kbits/sec 9.435 ms 0/26 (0%)
  13. - - - - - - - - - - - - - - - - - - - - - - - - -
  14. [ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
  15. [ 5] 0.00-10.30 sec 1.24 MBytes 1.01 Mbits/sec 9.435 ms 8/942 (0.85%) receiver

使用命令

  1. Server or Client:
  2. -p, --port # server port to listen on/connect to 端口
  3. -f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes 格式化带宽数输出
  4. -i, --interval # seconds between periodic bandwidth reports 设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。
  5. -F, --file name xmit/recv the specified file
  6. -A, --affinity n/n,m set CPU affinity
  7. -B, --bind <host> bind to a specific interface 主机绑定指定接口
  8. -V, --verbose more detailed output 更详细的输出
  9. -J, --json output in JSON format 输出JSON格式
  10. --logfile f send output to a log file 将输出发送到日志文件
  11. -d, --debug emit debugging output 发出调试输出
  12. -v, --version show version information and quit 显示版本信息并退出
  13. -h, --help show this message and quit 显示帮助信息并退出
  14. Server specific:
  15. -s, --server run in server mode 运行服务器模式
  16. -D, --daemon run the server as a daemon 将服务器作为守护进程运行
  17. -I, --pidfile file write PID file PID文件
  18. -1, --one-off handle one client connection then exit 处理一个客户端连接,然后退出
  19. Client specific:
  20. -c, --client <host> run in client mode, connecting to <host> 在客户端模式下运行,连接到主机
  21. -u, --udp use UDP rather than TCP 使用UDP而不是TCP
  22. -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited) 目标带宽(比特/秒)
  23. (default 1 Mbit/sec for UDP, unlimited for TCP) UDP默认为1 Mbit/秒,TCP没有限制
  24. (optional slash and packet count for burst mode)
  25. -t, --time # time in seconds to transmit for (default 10 secs) 传输时间(默认为10秒)
  26. -n, --bytes #[KMG] number of bytes to transmit (instead of -t) 要传输的字节数(而不是-t)
  27. -k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n) 要传输的块(包)数量(而不是-t或-n)
  28. -l, --len #[KMG] length of buffer to read or write 读取或写入缓冲区的长度
  29. (default 128 KB for TCP, 8 KB for UDP) TCP默认为128 KB, UDP默认为8 KB
  30. --cport <port> bind to a specific client port (TCP and UDP, default: ephemeral port) 绑定到特定的客户端端口(TCPUDP,默认:临时端口)
  31. -P, --parallel # number of parallel client streams to run 要运行的并行客户端流的数量
  32. -R, --reverse run in reverse mode (server sends, client receives) 以反向模式运行(服务器发送,客户端接收)
  33. -w, --window #[KMG] set window size / socket buffer size 设置窗口大小/套接字缓冲区大小
  34. -C, --congestion <algo> set TCP congestion control algorithm (Linux and FreeBSD only) 设置TCP拥塞控制算法(只支持LinuxFreeBSD)
  35. -M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes) 设置TCP/SCTP最大段大小(MTU - 40字节)
  36. -N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm 设置TCP/SCTP没有延迟,禁用Nagle的算法
  37. -4, --version4 only use IPv4
  38. -6, --version6 only use IPv6
  39. -S, --tos N set the IP 'type of service' 设置IP“服务类型”
  40. -L, --flowlabel N set the IPv6 flow label (only supported on Linux) 设置IPv6流标签(只支持Linux)
  41. -Z, --zerocopy use a 'zero copy' method of sending data 使用“零拷贝”方法发送数据
  42. -O, --omit N omit the first n seconds 省略前N秒
  43. -T, --title str prefix every output line with this string 在每个输出行前面加上这个字符串
  44. --get-server-output get results from server 从服务器获取结果
  45. --udp-counters-64bit use 64-bit counters in UDP test packets 在UDP测试包中使用64位计数器
  46. --no-fq-socket-pacing disable fair-queuing based socket pacing
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注