zoukankan      html  css  js  c++  java
  • Linux

    参考自:https://www.cnblogs.com/jiqing9006/p/10966578.html

    iperf简介:

    Iperf 是一个网络性能测试工具。Iperf可以测试最大TCP和UDP带宽性能,具有多种参数和UDP特性,可以根据需要调整,可以报告带宽、延迟抖动和数据包丢失。

    iperf版本:

    iperf 分为两种版本,unix/linux版和windows版,unix/linux版更新比较快,版本最新。windows版更新慢。windows版的iperf叫jperf,或者xjperf。jperf是在iperf基础上开发了更好的UI和新的功能。

    iperf参数说明(命令窗口执行):

    [root]# iperf -h
    Usage: iperf [-s|-c host] [options]
    iperf [-h|--help] [-v|--version]
    注:详细说明见百度百科:https://baike.baidu.com/item/iperf/11067694?fr=aladdin

    iperf实例:

    1、TCP测试

    服务器执行:./iperf -s -i 1 -w 1M 这裏是指定Linux,如果是 iperf -s则是windows平台下命令。默认包大小为8kbyte/s
    客户端执行:./iperf -c host -i 1 -w 1M
    其中-w表示TCP window size,host需替换成服务器地址。

    2、UDP测试

    服务器执行:./iperf -u -s
    客户端执行:./iperf -u -c 10.255.255.251 -b 900M -i 1 -w 1M -t 60
    其中-b表示使用多少带宽,1G的线路你可以使用900M进行测试。

    iperf功能介绍:

    1、TCP

    • 测量网络带宽
    • 报告MSS/MTU值的大小和观测值
    • 支持TCP窗口值通过套接字缓冲
    • 当P线程或Win32线程可用时,支持多线程。客户端与服务端支持同时多重连接

    2、UDP

    • 客户端可以创建指定带宽的UDP流
    • 测量丢包
    • 测量延迟
    • 支持多播
    • 当P线程可用时,支持多线程。客户端与服务端支持同时多重连接(不支持Windows)

    3、在适当的地方,选项中可以使用K(kilo-)和M(mega-)。例如131072字节可以用128K代替。

    4、可以指定运行的总时间,甚至可以设置传输的数据总量。

    5、在报告中,为数据选用最合适的单位。

    6、服务器支持多重连接,而不是等待一个单线程测试。

    7、在指定时间间隔重复显示网络带宽,波动和丢包情况。

    8、服务器端可作为后台程序运行。

    9、服务器端可作为Windows 服务运行。

    10、使用典型数据流来测试链接层压缩对于可用带宽的影响。

    iperf在Ubuntu上安装:

    1、iperf的github地址

    https://github.com/esnet/iperf/releases

    2、解压到指定目录

    sudo tar -zvxf iperf-3.6.tar.gz -C /usr/local

    3、进入目录配置,编译,安装

    ./configure
    make
    sudo make install

    4、报错

    iperf3: error while loading shared libraries: libiperf.so.0: cannot open shared object file: No such file or directory

    5、手动执行

    sudo /sbin/ldconfig

    6、可以访问了

    # iperf3 -v
    iperf 3.6 (cJSON 1.5.2)
    Linux JQ-Mac 4.15.0-45-generic #48~16.04.1-Ubuntu SMP Tue Jan 29 18:03:48 UTC 2019 x86_64
    Optional features available: CPU affinity setting, IPv6 flow label, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing, authentication

    7、开启服务

    # iperf3 -s
    -----------------------------------------------------------
    Server listening on 5201
    -----------------------------------------------------------

    8、确保服务端开启5201端口(可以开启服务就忽略这一步)

    vim /etc/sysconfig/iptables
    /etc/init.d/iptables restart

    9、测试访问

    # iperf3 -c 192.168.1.200
    Connecting to host 192.168.1.200, port 5201
    [  5] local 192.168.1.228 port 58092 connected to 192.168.1.200 port 5201
    [ ID] Interval           Transfer     Bitrate         Retr  Cwnd
    [  5]   0.00-1.00   sec  11.3 MBytes  94.5 Mbits/sec    0   24.0 KBytes       
    [  5]   1.00-2.00   sec  11.2 MBytes  94.1 Mbits/sec    0   26.9 KBytes       
    [  5]   2.00-3.00   sec  11.2 MBytes  94.1 Mbits/sec    0   28.3 KBytes       
    [  5]   3.00-4.00   sec  11.2 MBytes  94.2 Mbits/sec    0   43.8 KBytes       
    [  5]   4.00-5.00   sec  11.2 MBytes  94.2 Mbits/sec    0   43.8 KBytes       
    [  5]   5.00-6.00   sec  11.2 MBytes  93.7 Mbits/sec    0   43.8 KBytes       
    [  5]   6.00-7.00   sec  11.1 MBytes  93.3 Mbits/sec    0   43.8 KBytes       
    [  5]   7.00-8.00   sec  11.3 MBytes  94.4 Mbits/sec    0   66.5 KBytes       
    [  5]   8.00-9.00   sec  11.3 MBytes  94.8 Mbits/sec    0    100 KBytes       
    [  5]   9.00-10.00  sec  11.1 MBytes  93.2 Mbits/sec    0    100 KBytes       
    - - - - - - - - - - - - - - - - - - - - - - - - -
    [ ID] Interval           Transfer     Bitrate         Retr
    [  5]   0.00-10.00  sec   112 MBytes  94.0 Mbits/sec    0             sender
    [  5]   0.00-10.04  sec   112 MBytes  93.6 Mbits/sec                  receiver
    
    iperf Done.

    10、执行命令将打印信息追加到文件(服务器和客户端都在同一台机器上)

    //确保服务器开启的情况下,在客户端执行
    // -c:表示自己是客户端
    // 127.0.0.1:表示服务器地址
    // -b 40M:以40Mbits/sec的速度
    // -t 10:测试10秒钟
    // 1.txt:表示追加的文件名相对路径
    iperf3 -c 127.0.0.1 -b 40M -t 10 >> 1.txt
    博客园文作者:Citrusliu 博文地址:https://www.cnblogs.com/citrus
  • 相关阅读:
    对于基础资料的关联操作
    单据关联关系记录
    单据转换插件中新增行
    APK签名校验绕过
    android 安全需要关注
    安卓从业者应该关注:Android 6.0的运行时权限
    让阿里云的Centos,PHP组件 ImageMagick支持png和jpeg格式
    cocos2d-x 常规库的图文件配置
    cocos2d-x 添加 libLocalStorage 库...
    cocos2d-x3.9 默认是 gnustl_static 配置,但是 这个库缺少c++的基础功能... c++_static 功能全面些
  • 原文地址:https://www.cnblogs.com/citrus/p/13372970.html
Copyright © 2011-2022 走看看