iperf/iperf3 测试网络性能

2023-10-22 02:10

本文主要是介绍iperf/iperf3 测试网络性能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、简介

iPerf3 是一种用于测量网络上最大带宽的工具。这是一个新的实现,它与原始 iPerf 不共享任何代码,也不向后兼容。 iPerf 最初由 NLANR/DAST 开发,iPerf3 主要由 ESnet / 劳伦斯伯克利国家实验室开发。

iPerf features

  • TCP and SCTP
    • Measure bandwidth
    • Report MSS/MTU size and observed read sizes.
    • Support for TCP window size via socket buffers.
  • UDP
    • Client can create UDP streams of specified bandwidth.
    • Measure packet loss
    • Measure delay jitter
    • Multicast capable
  • Cross-platform: Windows, Linux, Android, MacOS X, FreeBSD, OpenBSD, NetBSD, VxWorks, Solaris,...
  • Client and server can have multiple simultaneous connections (-P option).
  • Server handles multiple connections, rather than quitting after a single test.
  • Can run for specified time (-t option), rather than a set amount of data to transfer (-n or -k option).
  • Print periodic, intermediate bandwidth, jitter, and loss reports at specified intervals (-i option).
  • Run the server as a daemon (-D option)
  • Use representative streams to test out how link layer compression affects your achievable bandwidth (-F option).
  • A server accepts a single client simultaneously (iPerf3) multiple clients simultaneously (iPerf2)
  • New: Ignore TCP slowstart (-O option).
  • New: Set target bandwidth for UDP and (new) TCP (-b option).
  • New: Set IPv6 flow label (-L option)
  • New: Set congestion control algorithm (-C option)
  • New: Use SCTP rather than TCP (--sctp option)
  • New: Output in JSON format (-J option).
  • New: Disk read test (server: iperf3 -s / client: iperf3 -c testhost -i1 -F filename)
  • New: Disk write tests (server: iperf3 -s -F filename / client: iperf3 -c testhost -i1)

二、使用方法

iperf的命令参数共分为三类,分别是客户端与服务器端公用参数、服务器端专用参数和客户端专用参数,下面对常用的选项进行介绍。

GENERAL OPTIONS
Command line optionDescription
-p, --port nThe 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 nOption 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

设置cpu的亲和性,可以指定某一个逻辑cpu运行。

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 hostBind 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, --verbosegive more detailed output
-J, --jsonoutput in JSON format
--logfile filesend output to a log file. (new in iPerf 3.1)
--d, --debugemit debugging output. Primarily (perhaps exclusively) of use to developers.
-v, --versionShow version information and quit.
-h, --helpShow a help synopsis and quit.
SERVER SPECIFIC OPTIONS
Command line optionDescription
-s, --serverRun iPerf in server mode. (This will only allow one iperf connection at a time)
-D, --daemonRun the server in background as a daemon.
-I, --pidfilefilewrite a file with the process ID, most useful when running as a daemon. (new in iPerf 3.1)
CLIENT SPECIFIC OPTIONS
Command line optionDescription
-c, --client hostRun iPerf in client mode, connecting to an iPerf server running on host.
--sctpUse SCTP rather than TCP (Linux, FreeBSD and Solaris). (new in iPerf 3.1)
-u, --udpUse UDP rather than TCP. See also the -b option.
-b, --bandwidth n[KM]

限制测试带宽。UDP 默认为 1Mbit/秒,TCP 默认无限制

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

以时间为测试结束条件进行测试,默认为 10 秒

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]

读写缓冲区的长度,TCP 默认为 128K,UDP 默认为 8K;

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 nThe number of simultaneous connections to make to the server. Default is 1.
-R, --reverseRun in reverse mode (server sends, client receives).
-w, --window n[KM]

设置套接字缓冲区大小,TCP 模式下为窗口大小;

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

设置 TCP/SCTP 最大分段长度(MSS,MTU 减 40 字节)

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

设置 TCP/SCTP no delay,屏蔽 Nagle 算法;

Set the TCP no delay option, disabling Nagle's algorithm. Normally this is only disabled for interactive applications like telnet.

-4, --version4only use IPv4.
-6, --version4only use IPv6.
-S, --tos nThe 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        0x10IPTOS_THROUGHPUT   maximize throughput   0x08IPTOS_RELIABILITY  maximize reliability  0x04IPTOS_LOWCOST      minimize cost         0x02
-L, --flowlabel n

设置 IPv6 流标签

Set the IPv6 flow label (currently only supported on Linux).

-Z, --zerocopy

使用 “zero copy”(零拷贝)方法发送数据;

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

忽略前 n 秒的测试

Omit the first n seconds of the test, to skip past the TCP TCP slowstart period.

-T, --title strPrefix every output line with this string.
-C, --linux-congestion algo

设置 TCP 拥塞控制算法

Set the congestion control algorithm (Linux only for iPerf 3.0, Linux and FreeBSD for iPerf 3.1).

See also GitHub - esnet/iperf: iperf3: A TCP, UDP, and SCTP network bandwidth measurement tool

三、常见使用场景

3.2、测试UDP丢包和延迟

iperf也可以用于UDP数据包吞吐量、丢包率和延迟指标,但是由于UDP协议是一个非面向连接的轻量级传输协议,并且不提供可靠的数据传输服务,因此对UDP应用的关注点不是传输数据有多快,而是它的丢包率和延时指标。通过iperf的“-u”参数即可测试UDP应用的传输性能


    增加参数 –b 指定带宽,-n 指定传输的数据量

ref:

iPerf - The TCP, UDP and SCTP network bandwidth measurement tool

18张图带你了解衡量网络性能的四大指标:带宽、时延、抖动、丢包 - 知乎

网络性能测试工具iperf的使用与参数解析_【ql君】qlexcel的博客-CSDN博客_iperf结果分析

iperf网络性能测试工具_mob604756f61e6c的技术博客_51CTO博客

iperf—流量测试 - 灵笑若然 - 博客园

这篇关于iperf/iperf3 测试网络性能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/258423

相关文章

Debian 13升级后网络转发等功能异常怎么办? 并非错误而是管理机制变更

《Debian13升级后网络转发等功能异常怎么办?并非错误而是管理机制变更》很多朋友反馈,更新到Debian13后网络转发等功能异常,这并非BUG而是Debian13Trixie调整... 日前 Debian 13 Trixie 发布后已经有众多网友升级到新版本,只不过升级后发现某些功能存在异常,例如网络转

从原理到实战解析Java Stream 的并行流性能优化

《从原理到实战解析JavaStream的并行流性能优化》本文给大家介绍JavaStream的并行流性能优化:从原理到实战的全攻略,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的... 目录一、并行流的核心原理与适用场景二、性能优化的核心策略1. 合理设置并行度:打破默认阈值2. 避免装箱

深度剖析SpringBoot日志性能提升的原因与解决

《深度剖析SpringBoot日志性能提升的原因与解决》日志记录本该是辅助工具,却为何成了性能瓶颈,SpringBoot如何用代码彻底破解日志导致的高延迟问题,感兴趣的小伙伴可以跟随小编一起学习一下... 目录前言第一章:日志性能陷阱的底层原理1.1 日志级别的“双刃剑”效应1.2 同步日志的“吞吐量杀手”

Python开发简易网络服务器的示例详解(新手入门)

《Python开发简易网络服务器的示例详解(新手入门)》网络服务器是互联网基础设施的核心组件,它本质上是一个持续运行的程序,负责监听特定端口,本文将使用Python开发一个简单的网络服务器,感兴趣的小... 目录网络服务器基础概念python内置服务器模块1. HTTP服务器模块2. Socket服务器模块

Java慢查询排查与性能调优完整实战指南

《Java慢查询排查与性能调优完整实战指南》Java调优是一个广泛的话题,它涵盖了代码优化、内存管理、并发处理等多个方面,:本文主要介绍Java慢查询排查与性能调优的相关资料,文中通过代码介绍的非... 目录1. 事故全景:从告警到定位1.1 事故时间线1.2 关键指标异常1.3 排查工具链2. 深度剖析:

Go语言网络故障诊断与调试技巧

《Go语言网络故障诊断与调试技巧》在分布式系统和微服务架构的浪潮中,网络编程成为系统性能和可靠性的核心支柱,从高并发的API服务到实时通信应用,网络的稳定性直接影响用户体验,本文面向熟悉Go基本语法和... 目录1. 引言2. Go 语言网络编程的优势与特色2.1 简洁高效的标准库2.2 强大的并发模型2.

深入解析Java NIO在高并发场景下的性能优化实践指南

《深入解析JavaNIO在高并发场景下的性能优化实践指南》随着互联网业务不断演进,对高并发、低延时网络服务的需求日益增长,本文将深入解析JavaNIO在高并发场景下的性能优化方法,希望对大家有所帮助... 目录简介一、技术背景与应用场景二、核心原理深入分析2.1 Selector多路复用2.2 Buffer

基于Python Playwright进行前端性能测试的脚本实现

《基于PythonPlaywright进行前端性能测试的脚本实现》在当今Web应用开发中,性能优化是提升用户体验的关键因素之一,本文将介绍如何使用Playwright构建一个自动化性能测试工具,希望... 目录引言工具概述整体架构核心实现解析1. 浏览器初始化2. 性能数据收集3. 资源分析4. 关键性能指

Zabbix在MySQL性能监控方面的运用及最佳实践记录

《Zabbix在MySQL性能监控方面的运用及最佳实践记录》Zabbix通过自定义脚本和内置模板监控MySQL核心指标(连接、查询、资源、复制),支持自动发现多实例及告警通知,结合可视化仪表盘,可有效... 目录一、核心监控指标及配置1. 关键监控指标示例2. 配置方法二、自动发现与多实例管理1. 实践步骤

MySQL深分页进行性能优化的常见方法

《MySQL深分页进行性能优化的常见方法》在Web应用中,分页查询是数据库操作中的常见需求,然而,在面对大型数据集时,深分页(deeppagination)却成为了性能优化的一个挑战,在本文中,我们将... 目录引言:深分页,真的只是“翻页慢”那么简单吗?一、背景介绍二、深分页的性能问题三、业务场景分析四、