嵌入式技术分享

Embedded Technology Sharing

使用iperf测试设备的网络吞吐量

一、iperf简介

iperf是一个基于Client/Server的网络性能测试工具,可以测试TCP、UDP和SCTP带宽质量,能够提供网络吞吐量信息,以及震动、丢包率,最大段和最大传输单元大小等统计信息,帮助我们测试网络性能,定位网络瓶颈。
iperf的好处是纯粹发包和接收,不会被硬盘、Flash等读写速度影响测试结果。
博主本人测试路由器的无线性能,iperf测试结果在一定程度上反应了路由器的网络性能。

二、演示

PC 与 路由器
路由器做服务端:

iperf3 -s -p 6800

PC做客户端:

iperf3 -c 192.168.10.1 -p 6800 -i 1 -t 30

三、iperf下载地址

1.官网
https://iperf.fr/iperf-download.php

2.windows 64位
https://iperf.fr/download/windows/iperf-3.1.3-win64.zip

3.windows 32位
https://iperf.fr/download/windows/iperf-3.1.3-win32.zip

4.ubuntu

sudo apt-get install iperf3

5.iperf源码
https://github.com/esnet/iperf

四、iperf的安装

1.windows
解压后将 iperf3.exe 和 cygwin1.dll 文件复制到 C:\Windows\System32路径,
以管理员身份运行cmd
输入iperf3 -v
有版本信息则表明安装成功

C:\Windows\system32>iperf3.exe -v
iperf 3.1.3
CYGWIN_NT-10.0 ThinkPad-W530 2.5.1(0.297/5/3) 2016-04-21 22:14 x86_64
Optional features available: None

2.路由器

make menuconfig

Network —>
<*> iperf3…………………… Internet Protocol bandwidth measuring tool
生成的ipk路径:lede/bin/packages/mipsel_24kc/base

3.嵌入式设备
交叉编译

4.ubuntu

sudo apt-get install iperf3

五、iperf参数

root@OpenWrt:~# iperf3 -h
Usage: iperf3 [-s|-c host] [options]
       iperf3 [-h|--help] [-v|--version]

Server or Client:
  -p, --port      #         server port to listen on/connect to
  -f, --format   [kmgtKMGT] format to report: Kbits, Mbits, Gbits, Tbits
  -i, --interval  #         seconds between periodic throughput reports
  -F, --file name           xmit/recv the specified file
  -A, --affinity n/n,m      set CPU affinity
  -B, --bind      <host>    bind to the interface associated with the address <host>
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  --logfile f               send output to a log file
  --forceflush              force flushing output at every interval
  -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
  -I, --pidfile file        write PID file
  -1, --one-off             handle one client connection then exit
Client specific:
  -c, --client    <host>    run in client mode, connecting to <host>
  -u, --udp                 use UDP rather than TCP
  --connect-timeout #       timeout for control connection setup (ms)
  -b, --bitrate #[KMG][/#]  target bitrate in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  --pacing-timer #[KMG]     set the timing for pacing, in microseconds (default 1000)
  --fq-rate #[KMG]          enable fair-queuing based socket pacing in
                            bits/sec (Linux only)
  -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, --length    #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, dynamic or 1460 for UDP)
  --cport         <port>    bind to a specific client port (TCP and UDP, default: ephemeral port)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run in reverse mode (server sends, client receives)
  -w, --window    #[KMG]    set window size / socket buffer size
  -C, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)
  -M, --set-mss   #         set TCP/SCTP maximum segment size (MTU - 40 bytes)
  -N, --no-delay            set TCP/SCTP 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, 0-255.
                            The usual prefixes for octal and hex can be used,
                            i.e. 52, 064 and 0x34 all specify the same value.
  --dscp N or --dscp val    set the IP dscp value, either 0-63 or symbolic.
                            Numeric values can be specified in decimal,
                            octal and hex (see --tos above).
  -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
  --extra-data str          data string to include in client and server JSON
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets
  --repeating-payload       use repeating pattern in payload, instead of
                            randomized payload (like in iperf2)

[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-

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

常用参数
-s :服务端
-c :客户端 + 服务端的iP
-p :端口号
-i :时间间隔
-t :测试次数

如果文章对您有帮助,欢迎移至上方按钮打赏博主;

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注