iperf 测试网络性能指标

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云原生数据库 PolarDB 分布式版,标准版 2核8GB
RDS PostgreSQL Serverless,0.5-4RCU 50GB 3个月
推荐场景:
对影评进行热评分析
简介: Iperf是一个网络性能测试工具,主要应用于LINUX服务器下面。可以测量最大TCP和UDP带宽,具有多种参数和特性,可以记录带宽,延迟抖动和数据包丢失,最大组和MTU等统计信息,通过这些信息可以发现网络问题,检查网络质量,定位网络瓶颈。Iperf在linux和windows平台均有二进制版本供自.

Iperf是一个网络性能测试工具,主要应用于LINUX服务器下面。可以测量最大TCP和UDP带宽,具有多种参数和特性,可以记录带宽,延迟抖动和数据包丢失,最大组和MTU等统计信息,通过这些信息可以发现网络问题,检查网络质量,定位网络瓶颈。Iperf在linux和windows平台均有二进制版本供自由使用。

对于需要大量网络交互的产品,例如Greenplum,网络性能指标是一个很重要的指标。

安装在需要测试网络的两台主机上。

git clone https://github.com/esnet/iperf.git
cd iperf

切换到最新的稳定分支后安装

git checkout 3.1-STABLE
./configure --prefix=/home/digoal/iperfhome
make
make install

将so加入

$ sudo vi /etc/ld.so.conf
/home/digoal/iperfhome/lib
# ldconfig
# ldconfig -p |grep iperf

详细的命令说明

./iperfhome/bin/iperf3 --help
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
  -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
  -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
  -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'
  -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

[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

帮助文档

man man1/iperf3.1 
IPERF(1)                         User Manuals                         IPERF(1)

NAME
       iperf3 - perform network throughput tests

SYNOPSIS
       iperf3 -s [ options ]
       iperf3 -c server [ options ]

DESCRIPTION
       iperf3 is a tool for performing network throughput measurements.  It can test either TCP or UDP throughput.  To perform an iperf3 test the user must establish both a server and a client.

GENERAL OPTIONS
       -p, --port n
              set server port to listen on/connect to to n (default 5201)

       -f, --format
              [kmKM]   format to report: Kbits, Mbits, KBytes, MBytes

       -i, --interval n
              pause n seconds between periodic bandwidth reports; default is 1, use 0 to disable

       -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
              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 a specific interface

       -V, --verbose
              give more detailed output

       -J, --json
              output in JSON format

       --logfile file
              send output to a log file.

       -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

SERVER SPECIFIC OPTIONS
       -s, --server
              run in server mode

       -D, --daemon
              run the server in background as a daemon

       -I, --pidfile file
              write a file with the process ID, most useful when running as a daemon.

       -1, --one-off
              handle one client connection, then exit.

CLIENT SPECIFIC OPTIONS
       -c, --client host
              run in client mode, connecting to the specified server

       --sctp use SCTP rather than TCP (FreeBSD and Linux)

       -u, --udp
              use UDP rather than TCP

       -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.  Setting the target bandwidth to 0 will disable bandwidth limits (particularly useful for UDP tests).

       -t, --time n
              time in seconds to transmit for (default 10 secs)

       -n, --bytes n[KM]
              number of bytes to transmit (instead of -t)

       -k, --blockcount n[KM]
              number of blocks (packets) to transmit (instead of -t or -n)

       -l, --length n[KM]
              length of buffer to read or write (default 128 KB for TCP, 8KB for UDP)

       --cport port
              bind data streams to a specific client port (for TCP and UDP only, default is to use an ephemeral port)

       -P, --parallel n
              number of parallel client streams to run

       -R, --reverse
              run in reverse mode (server sends, client receives)

       -w, --window n[KM]
              window size / socket buffer size (this gets sent to the server and used on that side too)

       -M, --set-mss n
              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’

       -L, --flowlabel n
              set the IPv6 flow label (currently only supported on Linux)

       -X, --xbind name
              Bind  SCTP  associations  to  a specific subset of links using sctp_bindx(3).  The --B flag will be ignored if this flag is specified.  Normally SCTP will include the protocol addresses of all active
              links on the local host when setting up an association. Specifying at least one --X name will disable this behaviour.  This flag must be specified for each link to be included in the association, and
              is  supported  for  both iperf servers and clients (the latter are supported by passing the first --X argument to bind(2)).  Hostnames are accepted as arguments and are resolved using getaddrinfo(3).
              If the --4 or --6 flags are specified, names which do not resolve to addresses within the specified protocol family will be ignored.

       --nstreams n
              Set number of SCTP streams.

       -Z, --zerocopy
              Use a "zero copy" method of sending data, such as sendfile(2), instead of the usual write(2).

       -O, --omit n
              Omit the first n seconds of the test, to skip past the TCP slow-start period.

       -T, --title str
              Prefix every output line with this string.

       -C, --congestion algo
              Set the congestion control algorithm (Linux and FreeBSD only).  An older --linux-congestion synonym for this flag is accepted but is deprecated.

       --get-server-output
              Get the output from the server.  The output format is determined by the server (in particular, if the server was invoked with the --json flag, the output will be in JSON format, otherwise it will  be
              in human-readable format).  If the client is run with --json, the server output is included in a JSON object; otherwise it is appended at the bottom of the human-readable output.

AUTHORS
       A list of the contributors to iperf3 can be found within the documentation located at http://software.es.net/iperf/dev.html#authors.

SEE ALSO
       libiperf(3), http://software.es.net/iperf

ESnet                            October 2015                         IPERF(1)

简单的测试
服务端

./iperfhome/bin/iperf3 -p 8181 -f M -i 3 -B 0.0.0.0 -V --logfile /tmp/iperf.log -s -D

tail -f -n 1 /tmp/iperf.log 

客户端, 通过-M 指定测试的TCP包大小。

./iperfhome/bin/iperf3 -c xxx.xxx.xxx.xxx -p 8181 -b 0 -t 100 -P 64 -i 3 -M 90

有必要的话,可以指定并行度,测试tcp或udp, 缓冲区的大小,TCP窗口的大小,MTU大小,堵塞控制算法等等。

通过sar -n DEV 1 10000可以观察服务端以及客户端的接收和发送pps, 带宽等信息。
sar -n TCP | EDEV ...
iptraf
qperf

目录
相关文章
|
2月前
|
机器学习/深度学习 PyTorch 算法框架/工具
目标检测实战(一):CIFAR10结合神经网络加载、训练、测试完整步骤
这篇文章介绍了如何使用PyTorch框架,结合CIFAR-10数据集,通过定义神经网络、损失函数和优化器,进行模型的训练和测试。
109 2
目标检测实战(一):CIFAR10结合神经网络加载、训练、测试完整步骤
|
2月前
|
安全 网络安全
Kali渗透测试:使用Armitage扫描网络
Kali渗透测试:使用Armitage扫描网络
|
20天前
|
机器学习/深度学习 自然语言处理 前端开发
前端神经网络入门:Brain.js - 详细介绍和对比不同的实现 - CNN、RNN、DNN、FFNN -无需准备环境打开浏览器即可测试运行-支持WebGPU加速
本文介绍了如何使用 JavaScript 神经网络库 **Brain.js** 实现不同类型的神经网络,包括前馈神经网络(FFNN)、深度神经网络(DNN)和循环神经网络(RNN)。通过简单的示例和代码,帮助前端开发者快速入门并理解神经网络的基本概念。文章还对比了各类神经网络的特点和适用场景,并简要介绍了卷积神经网络(CNN)的替代方案。
|
27天前
|
编解码 安全 Linux
网络空间安全之一个WH的超前沿全栈技术深入学习之路(10-2):保姆级别教会你如何搭建白帽黑客渗透测试系统环境Kali——Liinux-Debian:就怕你学成黑客啦!)作者——LJS
保姆级别教会你如何搭建白帽黑客渗透测试系统环境Kali以及常见的报错及对应解决方案、常用Kali功能简便化以及详解如何具体实现
|
3月前
|
存储 弹性计算 测试技术
阿里云服务器实例规格vCPU、内存、网络带宽、网络收发包PPS、连接数等性能指标详解
阿里云服务器ECS实例可以分为多种实例规格族。根据CPU、内存等配置,一种实例规格族又分为多种实例规格。而实例规格又包含vCPU、处理器、内存、vTPM、本地存储、网络带宽、网络收发包PPS、连接数、弹性网卡、云盘带宽、云盘IOPS等指标,本文为大家详细介绍实例规格的这些指标,以供大家了解和选择。
152 14
阿里云服务器实例规格vCPU、内存、网络带宽、网络收发包PPS、连接数等性能指标详解
|
2月前
|
JSON 算法 数据可视化
测试专项笔记(一): 通过算法能力接口返回的检测结果完成相关指标的计算(目标检测)
这篇文章是关于如何通过算法接口返回的目标检测结果来计算性能指标的笔记。它涵盖了任务描述、指标分析(包括TP、FP、FN、TN、精准率和召回率),接口处理,数据集处理,以及如何使用实用工具进行文件操作和数据可视化。文章还提供了一些Python代码示例,用于处理图像文件、转换数据格式以及计算目标检测的性能指标。
67 0
测试专项笔记(一): 通过算法能力接口返回的检测结果完成相关指标的计算(目标检测)
|
2月前
|
机器学习/深度学习 数据采集 算法
目标分类笔记(一): 利用包含多个网络多种训练策略的框架来完成多目标分类任务(从数据准备到训练测试部署的完整流程)
这篇博客文章介绍了如何使用包含多个网络和多种训练策略的框架来完成多目标分类任务,涵盖了从数据准备到训练、测试和部署的完整流程,并提供了相关代码和配置文件。
58 0
目标分类笔记(一): 利用包含多个网络多种训练策略的框架来完成多目标分类任务(从数据准备到训练测试部署的完整流程)
|
27天前
|
人工智能 安全 Linux
网络空间安全之一个WH的超前沿全栈技术深入学习之路(4-2):渗透测试行业术语扫盲完结:就怕你学成黑客啦!)作者——LJS
网络空间安全之一个WH的超前沿全栈技术深入学习之路(4-2):渗透测试行业术语扫盲完结:就怕你学成黑客啦!)作者——LJS
|
27天前
|
安全 大数据 Linux
网络空间安全之一个WH的超前沿全栈技术深入学习之路(3-2):渗透测试行业术语扫盲)作者——LJS
网络空间安全之一个WH的超前沿全栈技术深入学习之路(3-2):渗透测试行业术语扫盲)作者——LJS
|
27天前
|
SQL 安全 网络协议
网络空间安全之一个WH的超前沿全栈技术深入学习之路(1-2):渗透测试行业术语扫盲)作者——LJS
网络空间安全之一个WH的超前沿全栈技术深入学习之路(1-2):渗透测试行业术语扫盲)作者——LJS
下一篇
无影云桌面