zoukankan      html  css  js  c++  java
  • Iperf 网络性能测试工具

    iperf是一种命令行工具,用于通过测量服务器可以处理的最大网络吞吐量来诊断网络速度问题。它在遇到网络速度问题时特别有用,通过该工具可以确定哪个服务器无法达到最大吞吐量。

    环境: server: centos/redhat 7.4

      client:window10

    iperf版本: iperf 3.1.3
    官网地址: https://iperf.fr
    根据自己的系统下载相对应的安装包

    因为我们测试的客户端是win10 ,服务端是Redhat ,所以要下载这两个版本

     

     服务端安装

    rpm -ivh iperf3-3.1.3-1.fc24.x86_64.rpm

    客户端安装

    解压之后直接放到当前用户家目录即可,否则的话,执行需要加绝对路径

    (补充说明:客户端服务端是由命令参数决定的,只是在此测试实验中我个人决定他们为服务端或者是客户端)

    如何使用iperf

    • 必须在测试的两台计算机上同时安装iPerf。如果在个人计算机上使用基于Unix或 Linux的操作系统,则可以在本地计算机上安装iPerf。

    • 但是,如果要测试网络提供商的吞吐量,最好使用另一台服务器作为终点,因为本地ISP可能会施加影响测试结果的网络限制。

    使用方法官网也有

    命令选项

    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 
    格式化带宽数输出。支持的格式有:
    'b' = bits/sec 'B' = Bytes/sec
    'k' = Kbits/sec 'K' = KBytes/sec
    'm' = Mbits/sec 'M' = MBytes/sec
    'g' = Gbits/sec 'G' = GBytes/sec
    'a' = adaptive bits/sec 'A' = adaptive Bytes/sec
    自适应格式是kilo-和mega-二者之一。除了带宽之外的字段都输出为字节,除非指定输出的格式,默认的参数是a。
    -i, --interval # seconds between periodic bandwidth reports -F, --file name xmit/recv the specified file
    设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。
    -B, --bind 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 run in client mode, connecting to -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 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-
    iPerf 3 user documentation
    GENERAL OPTIONS
    Command line option    Description
    -p, --port n    The server port for the server to listen on and the client to connect to. This should be the same in both client and server. Default is 5201.
    --cport n    Option to specify the client-side port. (new in iPerf 3.1)
    -f, --format [kmKM]    A letter specifying the format to print bandwidth numbers in. Supported formats are 
        'k' = Kbits/sec           'K' = KBytes/sec
        'm' = Mbits/sec           'M' = MBytes/sec
    The adaptive formats choose between kilo- and mega- as appropriate.
    -i, --interval n    Sets the interval time in seconds between periodic bandwidth, jitter, and loss reports. If non-zero, a report is made every interval seconds of the bandwidth since the last report. If zero, no periodic reports are printed. Default is zero.
    -F, --file name    client-side: read from the file and write to the network, instead of using random data;
    server-side: read from the network and write to the file, instead of throwing the data away.
    -A, --affinity n/n,m-F    Set the CPU affinity, if possible (Linux and FreeBSD only). On both the client and server you can set the local affinity by using the n form of this argument (where n is a CPU number). In addition, on the client side you can override the server’s affinity for just that one test, using the n,m form of argument. Note that when using this feature, a process will only be bound to a single CPU (as opposed to a set containing potentialy multiple CPUs).
    -B, --bind host    Bind to host, one of this machine's addresses. For the client this sets the outbound interface. For a server this sets the incoming interface. This is only useful on multihomed hosts, which have multiple network interfaces.
    -V, --verbose    give more detailed output
    -J, --json    output in JSON format
    --logfile file    send output to a log file. (new in iPerf 3.1)
    --d, --debug    emit debugging output. Primarily (perhaps exclusively) of use to developers.
    -v, --version    Show version information and quit.
    -h, --help    Show a help synopsis and quit.
    SERVER SPECIFIC OPTIONS 服务器特定选项
    Command line option    Description
    -s, --server    Run iPerf in server mode. (This will only allow one iperf connection at a time)
    -D, --daemon    Run the server in background as a daemon.
    -I, --pidfilefile    write a file with the process ID, most useful when running as a daemon. (new in iPerf 3.1)
    CLIENT SPECIFIC OPTIONS 客户特定选项
    Command line option    Description
    -c, --client host    Run iPerf in client mode, connecting to an iPerf server running on host.
    --sctp    Use SCTP rather than TCP (Linux, FreeBSD and Solaris). (new in iPerf 3.1)
    -u, --udp    Use UDP rather than TCP. See also the -b option.
    -b, --bandwidth n[KM]    Set target bandwidth to n bits/sec (default 1 Mbit/sec for UDP, unlimited for TCP). If there are multiple streams (-P flag), the bandwidth limit is applied separately to each stream. You can also add a ’/’ and a number to the bandwidth specifier. This is called "burst mode". It will send the given number of packets without pausing, even if that temporarily exceeds the specified bandwidth limit.
    -t, --time n    The time in seconds to transmit for. iPerf normally works by repeatedly sending an array of len bytes for time seconds. Default is 10 seconds. See also the -l, -k and -n options.
    -n, --num n[KM]    The number of buffers to transmit. Normally, iPerf sends for 10 seconds. The -n option overrides this and sends an array of len bytes num times, no matter how long that takes. See also the -l, -k and -t options.
    -k, --blockcount n[KM]    The number of blocks (packets) to transmit. (instead of -t or -n) See also the -t, -l and -n options.
    -l, --length n[KM]    The length of buffers to read or write. iPerf works by writing an array of len bytes a number of times. Default is 128 KB for TCP, 8 KB for UDP. See also the -n, -k and -t options.
    -P, --parallel n    The number of simultaneous connections to make to the server. Default is 1.
    -R, --reverse    Run in reverse mode (server sends, client receives).
    -w, --window n[KM]    Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. (this gets sent to the server and used on that side too)
    -M, --set-mss n    Attempt to set the TCP maximum segment size (MSS). The MSS is usually the MTU - 40 bytes for the TCP/IP header. For ethernet, the MSS is 1460 bytes (1500 byte MTU).
    -N, --no-delay    Set the TCP no delay option, disabling Nagle's algorithm. Normally this is only disabled for interactive applications like telnet.
    -4, --version4    only use IPv4.
    -6, --version4    only use IPv6.
    -S, --tos n    The type-of-service for outgoing packets. (Many routers ignore the TOS field.) You may specify the value in hex with a '0x' prefix, in octal with a '0' prefix, or in decimal. For example, '0x10' hex = '020' octal = '16' decimal. The TOS numbers specified in RFC 1349 are: 
        IPTOS_LOWDELAY     minimize delay        0x10
        IPTOS_THROUGHPUT   maximize throughput   0x08
        IPTOS_RELIABILITY  maximize reliability  0x04
        IPTOS_LOWCOST      minimize cost         0x02
    -L, --flowlabel n    Set the IPv6 flow label (currently only supported on Linux).
    -Z, --zerocopy    Use a "zero copy" method of sending data, such as sendfile(2), instead of the usual write(2). This uses much less CPU.
    -O, --omit n    Omit the first n seconds of the test, to skip past the TCP TCP slowstart period.
    -T, --title str    Prefix every output line with this string.
    -C, --linux-congestion algo    Set the congestion control algorithm (Linux only for iPerf 3.0, Linux and FreeBSD for iPerf 3.1).

     

     此时说明已经作为服务端起来了,而且监听在 5201 端口上,接下来我们就可以在客户端做压测了

     我的网卡是百兆网,测试结果挺准确的

    iperf也可以测试通过udp连接的吞吐量,服务端做同样的操作

    iperf3 -s

    客服端指定使用udp协议进行连接测试

     带宽远远低于tcp测试的结果,这是因为iperf把UDP客户端的带宽限制为每秒1Mbit。此时可以用 -b 选项指定带宽,可以略高于自己网卡的带宽,已达到更准确的结果。

    这将告诉客户端我们希望尽可能达到每秒1G 的最大值,-b选项仅在使用UDP连接时有效,因为iperf未在TCP客户端上设置带宽限制。

     iperf 还可以做双向测试,在客户端用 -d 选项,此时他不光发送数据,还接收数据

  • 相关阅读:
    第四章 利用函数实现指定的功能
    5-7 点到原点的距离(多态)
    5-2 宠物的生长(多态)
    5-7 学生cpp成绩统计
    5-6 学生CPP成绩计算
    php将远程图片下载保存到本地
    vs2010 调试快捷键
    vs2010 快捷键大全
    [C#] 使用Application.AddMessageFilter当做Form的热键
    C# 收发和处理自定义的WINDOWS消息
  • 原文地址:https://www.cnblogs.com/augusite/p/14583233.html
Copyright © 2011-2022 走看看