局域网测速:iperf实现局域网点对点测试传输速度

下载地址

https://iperf.fr/download/windows/iperf-3.1.3-win64.zip
https://iperf.fr/download/windows/iperf-3.1.3-win32.zip

下载完成后解压得到:cygwin1.dlliperf3.exe文件

运行CMD,进入解压的目录运行:iperf3.exe 就会看到下面的命令详解。

C:\Users\Anita\Desktop\iperf\64>iperf3.exe
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
  -B, --bind      <host>    bind to a specific interface
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  --logfile f               send output to a log file
  -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
  -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  -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, --len       #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, 8 KB 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
  -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'
  -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 from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets

[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

C:\Users\Anita\Desktop\iperf\64>

首先我们找两个点,一个视为服务器,另一个视为客户端。将软件复制到两个主机。

  • 服务器:192.168.0.250
  • 客户端:192.168.0.98

在服务器上运行

iperf3.exe -s     #启动服务

在这里插入图片描述

在客户端上运行

iperf3.exe -c 192.168.0.250
C:\Users\Anita\Desktop\iperf\64>iperf3.exe -c 192.168.0.250
Connecting to host 192.168.0.250, port 5201
[  4] local 192.168.0.98 port 55593 connected to 192.168.0.250 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  11.4 MBytes  95.4 Mbits/sec
[  4]   1.00-2.00   sec  11.0 MBytes  92.3 Mbits/sec
[  4]   2.00-3.00   sec  11.4 MBytes  95.3 Mbits/sec
[  4]   3.00-4.00   sec  11.2 MBytes  94.3 Mbits/sec
[  4]   4.00-5.00   sec  11.4 MBytes  95.6 Mbits/sec
[  4]   5.00-6.00   sec  11.2 MBytes  94.3 Mbits/sec
[  4]   6.00-7.00   sec  11.4 MBytes  95.3 Mbits/sec
[  4]   7.00-8.00   sec  11.2 MBytes  94.4 Mbits/sec
[  4]   8.00-9.00   sec  11.4 MBytes  95.5 Mbits/sec
[  4]   9.00-10.00  sec  11.2 MBytes  94.2 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec   113 MBytes  94.7 Mbits/sec                  sender
[  4]   0.00-10.00  sec   113 MBytes  94.7 Mbits/sec                  receiver

iperf Done.

最后再看服务端
在这里插入图片描述

第一步:例如我们要测试内网结点A与B两台计算机之间的传输带宽,那么我们需要复制iperf.exe到这两台计算机硬盘中。   第二步:随意选择结点A作为服务端,而B作为客户端,在A上进入命令提示窗口运行iperf -s命令,这样iperf将以服务端方式启动,并且通过TCP的5001端口监听数据。(如图4)   第三步:接下来我们返回到B结点进入命令提示窗口,然后运行iperf -c 192.168.0.199 -t 60,这个命令是将B结点以客户端的方式运行,并且连接IP地址为192.168.0.199的服务端,监视测量数据时间是60秒。(如图5)   第四步:运行完毕客户端将自动开启1903端口连接服务端的5001端口,通过发送与接收数据包来实现测量带宽的目的。   第五步:与此同时我们在服务端上也可以看到有客户端连接5001端口的提示,这表明两个结点已经建立了相应的连接,数据通讯正常。(如图6)   第六步:由于我们之前是设置了测量时间间隔为60秒,所以在60秒过后客户端结点上就会显示出测量的具体数据,从A到B发送接收数据的速度为177Mbits/sec,由于以太网数据传输是双向双工的,所以百M网线理想状态传输速度应该是200Mbits/sec。(如图7)   第七步:当然我们还可以通过在客户端上执行iperf -c 192.168.0.199 -t 60 -i 2,这样将每隔两秒自动将测量结果显示出来,在最后再计算其平均值。(如图8)   通过简单的设置和简单的指令我们轻松实现了针对内网两个结点之间带宽传输速度的测量,当然iperf程序还支持很多参数,具体设置我们可以参考其帮助信息,比较常用的有-l 缓冲区大小,-m 显示tcp最大mtu值,-p 指定服务器端使用的端口或客户端所连接的端口,-u 使用udp协议,-w 指定TCP窗口大小,默认是8KB,-M 设定TCP数据包的最大mtu值等。另外在客户端上可以通过-n 指定传输的字节数,-r 单独进行双向传输测试,在服务端则可以通过-D参数以服务方式运行ipserf,以-R来停止iperf服务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

亦良Cool

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值