【协议森林】iperf3使用方法及原理

news/2024/5/18 12:35:43 标签: udp, windows, iperf3

1.简述

Iperf 是一个 TCP/IP 和 UDP/IP 的性能测量工具,通过调谐各种参数可以测试TCP的最大带宽,并报告带宽、延迟,最大段和最大传输单元大小等统计信息。Iperf可以运行于Linux/BSD、Unix及Windows等操作系统。

2.使用

root@ubuntu:/home/totosun/Desktop/iperf-3.2-STABLE/iperf-3.2-STABLE/src# ./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 a specific interface
  -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
  --rsa-private-key-path    path to the RSA private key used to decrypt
                            authentication credentials
  --authorized-users-path   path to the configuration file containing user
                            credentials
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, --len       #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, dynamic or 1 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
  --dscp N or --dscp val    set the IP dscp value, either 0-63 or symbolic
  -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
  --get-server-output       get results from server
  --udp-counters-64bit      use 64-bit counters in UDP test packets
  --username                username for authentication
  --rsa-public-key-path     path to the RSA public key used to encrypt
                            authentication credentials

window:

iperf3.exe -s

在这里插入图片描述
客户端:

iperf3 -c 192.168.208.200 -t 60 -P 6
#指定窗口大小
iperf3 -c 192.168.208.200 -t 60 -P 6  -w 8K 

在这里插入图片描述

3.原理分析

iperf3相关命令实现原理函数

    setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt))
    setsockopt(s, IPPROTO_TCP, TCP_MAXSEG, &opt, sizeof(opt))
    setsockopt(s, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt))
    setsockopt(s, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt))
    setsockopt(s, SOL_SOCKET, SO_MAX_PACING_RATE, &fqrate, sizeof(fqrate))
    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))
    setsockopt(s, IPPROTO_IP, IP_TOS, &opt, sizeof(opt)
    setsockopt(s, IPPROTO_TCP, TCP_CONGESTION, test->congestion, strlen(test->congestion))

在这里插入图片描述
客户端与服务器互换,要分清server和客户端读写方向,两者差异比较大。

Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.208.200, port 22238
[  5] local 192.168.208.209 port 5201 connected to 192.168.208.200 port 22239
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   106 MBytes   892 Mbits/sec
[  5]   1.00-2.00   sec   105 MBytes   880 Mbits/sec
[  5]   2.00-3.00   sec   114 MBytes   954 Mbits/sec
[  5]   3.00-4.00   sec   114 MBytes   956 Mbits/sec
[  5]   4.00-5.00   sec   106 MBytes   895 Mbits/sec
[  5]   5.00-6.00   sec   113 MBytes   950 Mbits/sec
[  5]   6.00-7.00   sec   105 MBytes   882 Mbits/sec
[  5]   7.00-8.00   sec  98.1 MBytes   822 Mbits/sec
[  5]   8.00-9.00   sec   111 MBytes   930 Mbits/sec
[  5]   9.00-10.00  sec   109 MBytes   918 Mbits/sec
[  5]  10.00-10.04  sec  3.93 MBytes   958 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-10.04  sec  0.00 Bytes  0.00 bits/sec                  sender
[  5]   0.00-10.04  sec  1.06 GBytes   908 Mbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

在这里插入图片描述

4.抓包对比

在这里插入图片描述
在这里插入图片描述

加入讨论

在这里插入图片描述


http://www.niftyadmin.cn/n/1113823.html

相关文章

使用vASA842配置ASDM645

准备&#xff1a;使用VMware打开vASA842.ova文件&#xff0c;将第一个网络适配器桥接到一个vmnet接口&#xff0c;我这里是vmnet3&#xff0c;网段是10.0.0.0/24,网关是10.0.0.1/24 1、打开vASA842虚拟机&#xff0c;使用CRT连接上ASA CLI界面。 CLI查看show ver: ciscoasa# sh…

菜鸡互啄队 - 测试与发布

一、修复的bug 修复使用commit命令出现的数字长度溢出问题 修复在Windows端的编码问题 二、场景测试 本程序面向软件开发者等使用&#xff0c;只需要有python3的环境就可以运行使用&#xff0c;免去安装的烦恼&#xff0c;更加方便快捷。 三、测试矩阵 测试平台Python版本测试…

【协议森林】Window网络性能调优方法

1.方法 在命里提示符中输入&#xff1a;   netsh interface tcp show global 后&#xff0c;会发现“接收窗口自动调节级别”是normal&#xff0c;问题就出现在这儿&#xff0c;只要将其关闭即可。   netsh int tcp set global autotuningleveldisabled 后会收到“确定”…

SUSE下安装Enlightenment 17(转)

SUSE下安装Enlightenment 17(转)[more]适用于:SUSE Linux ProSUSE Linux有二个主要桌面环境Gnome或KDE。你是感觉哪个比较好? 这个没有准确的问题&#xff0c;它依靠你的需要&#xff0c;选择&#xff0c;和可能合适你的个性而定。 但是大家想不想在SUSE用E17呢&#xff1f;一…

2016/09/21 java关键字static

1.static方法 static方法一般称作静态方法&#xff0c;由于静态方法不依赖于任何对象就可以进行访问&#xff0c;因此对于静态方法来说&#xff0c;是没有this的&#xff0c;因为它不依附于任何对象&#xff0c;既然都没有对象&#xff0c;就谈不上this了。并且由于这个特性&am…

[Leetcode Week3]Evaluate Division

Evaluate Division题解 原创文章&#xff0c;拒绝转载 题目来源&#xff1a;https://leetcode.com/problems/evaluate-division/description/ Description Equations are given in the format A / B k, where A and B are variables represented as strings, and k is a real …

ASA防火墙忘记密码之后的恢复步骤

ASA的密码恢复方法与路由器相似&#xff0c;修改配置寄存器的值&#xff0c;启动时绕过startup-config配置文件&#xff0c;重新配置密码。 密码恢复的步骤如下&#xff1a; &#xff08;1&#xff09;重新插拔电源线&#xff0c;重启ASA &#xff08;2&#xff09;按E…

linux 3.10 串口注册

这个调用过程特别奇特&#xff0c;值得记下来。 最外层调用start_kernel的console_init()进行串口注册。 console_init()调用drivers/tty/tty_io.c&#xff1a; void __init console_init(void) {initcall_t *call;/* Setup the default TTY line discipline. */tty_ldisc_begi…