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

    什么是Iperf?
    Iperf 是一个网络性能测试工具。Iperf可以测试TCP和UDP带宽质量。Iperf可以测量最大TCP带宽,具有多种参数和UDP特性。Iperf可以报告带宽,延迟抖动和数据包丢失。

    Iperf 是一个 TCP/IP 和 UDP/IP 的性能测量工具,能够提供网络吞吐率信息,以及震动、丢包率、最大段和最大传输单元大小等统计信息;从而能够帮助我们测试网络性能,定位网络瓶颈。

     
     使用方法如下:
     

    1.服务端

    iperf -s -w 1m

    2.客户端

    iperf -c 192.168.43.1 -t 60 -i 2 -P 5 -w 1m

    参数的含义:

    -s  (server) 开启服务器

    -c  (client)  指定服务端主机IP

    -t  测试时长。默认10秒

    -i  数据统计间隔,以秒为单位。          client 显示的是发送速率 , server端显示的是接收速率,最好加 i 参数进行速率跟踪

    -p (小写)指定服务器端使用的端口或客户端所连接的端口

    -P (大写)发包并发线程数

    -w 设置TCP窗口大小,默认是8KB。如果窗口太小,有可能丢包

    -u 使用udp协议。测试htb的时候最好用udp,udp通信开销小,测试的带宽更准确

    -b 指定发送带宽,默认是1Mbit/s。与-u 选项相关,千兆链路使用90%容量进行测试就可以了: -u  -b 900M在测试qos的时候,这是最有用的参数

    -l  缓冲区大小,默认是8KB,#iperf -c 222.35.11.23 -l 16

    一般来说,我们在做性能测试的时候需要指定包长,不同的包长会得到不同的吞吐量,通过 -l 指定,而使用 -b 指定带宽 

     --------------------------------------------------------------------------------------------------------------------------------

    使用 iperf 测试两台机器间的最大带宽

     

    如果在测试中想知道两台机器见最大的连接速度。用scp拷一个文件应该是最容易的方法。但是不准确。 iperf 这个小工具就是专门用来干这个的。结果相对来说准确一些。使用起来也很方便。

    首先在两台机器上都安装iperf

    $ sudo apt-get install iperf

    然后在需要测试的一台机器上 启动 iperf 监听

    $ iperf -s
    ------------------------------------------------------------
    Server listening on TCP port 5001
    TCP window size: 85.3 KByte (default)
    ------------------------------------------------------------
    

    然后在另外一台机器上连接过去

    $ iperf -c 192.168.1.10
    ------------------------------------------------------------
    Client connecting to 192.168.1.10, TCP port 5001
    TCP window size: 18.6 KByte (default)
    ------------------------------------------------------------
    [  3] local 192.168.1.9 port 60611 connected with 192.168.1.10 port 5001
    [ ID] Interval       Transfer     Bandwidth
    [  3]  0.0-10.0 sec   112 MBytes  93.5 Mbits/sec
    

    可以看到 连接速率是 93.5Mbps 局域网一般达不到全速。

    另外还有个小工具 用来查看实时的传输速率 httperf

    $ sudo apt-get install httperf
    $ httperf
    httperf --client=0/1 --server=localhost --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=1
    httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
    Maximum connect burst length: 0
    
    Total: connections 1 requests 1 replies 1 test-duration 0.001 s
    
    Connection rate: 1081.0 conn/s (0.9 ms/conn, <=1 concurrent connections)
    Connection time [ms]: min 0.9 avg 0.9 max 0.9 median 0.5 stddev 0.0
    Connection time [ms]: connect 0.2
    Connection length [replies/conn]: 1.000
    
    Request rate: 1081.0 req/s (0.9 ms/req)
    Request size [B]: 62.0
    
    Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
    Reply time [ms]: response 0.7 transfer 0.0
    Reply size [B]: header 284.0 content 177.0 footer 0.0 (total 461.0)
    Reply status: 1xx=0 2xx=1 3xx=0 4xx=0 5xx=0
    
    CPU time [s]: user 0.00 system 0.00 (user 0.0% system 432.4% total 432.4%)
    Net I/O: 552.1 KB/s (4.5*10^6 bps)
    
    Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
    Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
    

    可以看到目前的网络IO 是 552.1KB/s 大约等于 4.5Mbps

  • 相关阅读:
    【转】微信小程序开发之图片等比例缩放 获取屏幕尺寸图片尺寸 自适应
    解决vscode egg调试出现: this socket has been ended by other party【转】
    高仿Readhub小程序 微信小程序项目【原】
    git 解决二进制文件冲突
    webpack 打包编译-webkit-box-orient: vertical 后消失
    H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面
    vue 路由懒加载 使用,优化对比
    jq自定义多选下拉列表框
    System V IPC相关函数
    互斥锁和条件变量(pthread)相关函数
  • 原文地址:https://www.cnblogs.com/wjoyxt/p/4167732.html
Copyright © 2011-2022 走看看