You are on page 1of 14
A SUE true 7 inscirina the Next Gen 15 Useful examples of iperf commands in Linux (How to use iperf in Linux) May 31, 2020 by cyberithub Table of Contents Syntax iperf commands in Linux Example 1: How to check perf command version Example 2: How to Check Network Performance in Server Mode Example 3 How to Check Network Performance in Client made Example &: How to Sta iperf Server on UDP Port Example 5: How to Send data for N secs in Client Mode Example 6: How to measure bidirectional bandwidths sequentially Example 7: How to measure bidirectional bandwidths simukaneoushy Example 6: How to Change TCP Window Size in Client mode Example 9: How to change TCP Window Size in Server mode Example 10: How to Connect iperf Server on UDP Port Example 11: How to Check Packet Loss through UDP Connection Example 12: How to Check UDP Network Statistics in Detail Example 13: How to Launch Parallel Network Bandwidth Tests Example 14: How to Test TCP Connection Using Maximum Segment Size Example 15: How to check other options of iperf commands in Linux Advertisements Source from Alibaba.com In this article, will take you through 15 Useful examples of iperf commands in Linux ipertis an open source tool that can be easily installed in Linux, It provides a reliable information about Network Bandwidth and its performance. You can easily check the network latency and other errors using this tool. You can also check many different information using iperf tool from Client as well as from Server Side, We wil look into various possible uses of this too! in below examples, Syntax Iperf -s [opti ‘Apert -u -c server [options] iperf commands in Linux Allso Reas Install inerf and perform network throughput test in Linux (RedHat/CentOS 7/8) in § Easy Steps Example 1: How to check iperf command version I you want to check iperf command version then you need to use -v option with ipert commands as shown below. As you can see from below output current iperf command version is 2.0.23 Advertisements Source from Alibaba.com [root@lecalhost ~]# iperf -v Sperf version 2.0.13 (21 Jan 2019) pthreads NOTE: Please note that here | am using root user to run all the below commands.You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User. -v print version information and quit [rootglocathost ~]# iperf -s -F Server Listening on TC? port S801 TCP window size: 85.3 KByte (default) [ 4] local 192.168.9.100 port S8@1 connected with 192,168.0.108 port 54310 (peer 12857.1824.3338-unk) [ 10] Interval Transfer Bandwidth [ 4] 0.0-64.9 sec 0.08 Kaytes 0.00 Kaytes/sec yun in server mode “-f: format to report adaptive, bits, Bytes, Kbits, Mbits, Gbits, KBytes, MBytes, GBytes Example 3: How to Check Network Performance in Client mode Ifyou want to check network performance in Client mode then you need to use -c option with iperf command as shown below. In ‘this example we are trying to connect Server 192.168.0.108 on TCP port S8@1 with default TCP window size. [root@lecalhost ~]# iperf -c 192.168.8.100 Client connecting to 192.168.0.180, TCP port S0@1 TCP window size: 4.00 Mayte (default) [3] local 192.168.0.106 port 54358 connected with 192.168.0.108 port 5¢01 [ 10] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 30.9 Gaytes 25.5 cbits/sec in client mode, connecting te host You can also go to the Server end and verify the response as shown below. Server Listening on TCP port 5802 TCP window size: 85.3 KByte (default) [ 4] local 192.168.0.169 port 5081 connected with 192.168.0.186 port 54358 [ 1D] Interval Transfer Bandwidth [ 4] 0.0-10.8 sec 32356224 KBytes 3227989 xBytes/sec NOTE: Please note that you need to start the Server first before launching any client connections or else you will get connection refused error. Example 4: How to Start iperf Server on UDP Port If you want to start Iperf Server on UDP Port instead of starting in default TC? Port then you need to use -u option with iperf command as shown below. In this example we are trying to start perf in Server mode on default UDP Port 5801 using ipers -v command. unr buffer size: 208 Kayte (default) Example 5: I you want to send data for N secs in Client mode then you need to provide the number of seconds using -t option with ipert ‘command as shown below. In this example we are trying to send data to the Server(192.168.0.100) for 15 seconds in Client made Using perf -c 192.168.0.188 -t 15 command [root@lecalhost ~]# iperf -c 192.168.8.100 -t 15 Client connecting to 192.168.0.160, TCP port S0@1 TCP window size: 4.00 MByte (default) [ 3] local 192.168.0.100 port 54364 connected with 192.168.0.108 port 5¢01 [ 10] Interval Transfer Bandwidth [ 3] 0.0-15.0 sec 42.6 Gaytes 24.4 Gbits/sec time in seconds to listen for new traffic connections, receive trafic or transmit traffic Example 6: How to measure irectional bandwidths sequentially I you want to measure bidirectional bandwidths sequentially then you need to use -r option with iperf command as shown below. In this example we are connecting Server 192.168.0.10@ on Port 5881 to perform bidirectional tests sequentially. [root@localhost ~}# iperf -c 192.168.0.100 -r Client connecting to 192.168.0.180, TCP port S0e1 TCP window size: 4.00 wayte (default) [ 3] local 192.168.0.105 port 54378 connected with 192.168.0.100 port Seat [ 10] Interval Transfer Bandwidth [ 3] @.0-10.0 sec 30.2 Gaytes 25.0 Gbits/sec Do a bidirectional test individually - client-to-server, followed by a reversed test, server-to-dlient You can also go to the Server end and verily the response as shown below. Server Listening on TCP port 5801 TCP window size: 85.3 xByte (default) [ 4] local 192.168.0.180 port $801 connected with 192.168.0.106 port 54378 [ 10] Interval Transfer Bandwidth [ 4] 0.0-10.0 sec 31730336 KBytes 3167739 KBytes/sec Client connecting to 192.168.0.168, TCP port 5001 TCP window size: 4096 KByte (default) [4] local 192.168.0.106 port $4372 connected with 192.168.@.108 port Se01 [5] 1oca1 192.168.2.100 port Se@1 connected with 192.168.0.1@6 port $4372 [root@localhost ~]# iperf -c 192.168.0.108 -4 bind failed: Adéress already in use Client connecting to 192.168.0.160, TCP port S0@1 TCP window size: 4.00 MByte (default) [ 3] local 192.168.@.100 port 54374 connected with 192.168.0.100 port 5001 [ 10] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 14.8 Gaytes 12.7 cbits/sec -d:Do a bidirectional test simultaneously. You can also verify the response from Server end as shown below. Server listening on TC> port 5002 TCP window size: 85.3 xByte (default) [ 4] local 192.168.0.180 port 5801 connected with 192.168.0.106 port 54374 Client connecting to 192.168.0.160, TCP port 5001 TCP window size: 4096 Kyte (default) [ 5} local 192.168.0.106 port 54376 connected with 192.168.0.108 port 5e01 [ 5] local 192.168.2.100 port 5801 connected with 192.168.0.106 port 54376 [ 10) Interval Transfer Bandwidth [ 4] 0.0-10.0 sec 15499264 KBytes 1546299 xBytes/sec [ 6] 0.0-10.0 sec 15464960 Kaytes 1544880 Kaytes/sec [ 5] 0.0-10.0 sec 15464960 KBytes 1541043 xBytes/sec sum) e. -10.0 sec 30964224 KBytes 3285504 KBytes/sec Example 8: How to Change TCP Window Size in Client mode I you want to change the TCP Window size in Client mode then you need to use -w option with iperf command as shown below. In this example we are trying to connect Server 192.168.0.188 on TCP Port 5881 with TCP window size of 4900, [root@locathost ~]# iperf -c 192.168.0.100 -w 4200 Client connecting to 192.168.0.160, TCP port Soe1 ‘TCP window size: 7.81 KByte (WARNING: requested 3.91 KByte) [ 3] local 192,168.0.160 port 54378 connected with 192.168.0.100 port See1 [ 1D] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 32.4 MBytes 27.1 Mbits/sec -w : TCP window size (socket buffer size) Example 9: How to change TCP Window Size in Server mode I you want to change TCP Window Size in Server mode then you need to use -w option with -s option as shown below. In th ‘example, we are trying to start Server which listens on Port $001 with a TCP window size of 4000. Example 10: How to Connect iperf Server on UDP Port. I you want to connect Server on UDP Port instead of default TCP Port then you need to use -u option with iperf command as shown below. in this example, we are trying to connect Server 192.168.2.188 on UDP Port $801 instead of connecting to default TCP Port. [root@locathost ~]# iperf -c 192.168.0.100 -u Client connecting to 192.168.0.108, UDP port 50@1 Sending 1470 byte datagrans, 1G target: 11215.21 us (Kalman adjust) UDP buffer size: 208 KByte (default) 3] local 192.168.0.186 port 53574 connected with 192.168.0.10@ port S201 1] Interval Transfer Bandwidth 3] 0.0-10.0 sec 1.25 Maytes 1.05 Mbits/sec 3] Sent 892 datagrans 3] Server Report: 3] ©.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.006 ms 6/ 892 (2X) “ul: use UDP rather than TCP Now you can go to Server end and verify the response as shown below. Server Listening on UO? port S801 Receiving 1470 byte datagrams oP buffer size: 208 KByte (default) [ 3] local 192,168.0.160 port 5861 connected with 192.168.2.106 port 53674 [ 1D] Interval Transfer Bandwidth Jitter Lost/Total Datagrars [ 3] @.0-10.0 sec 1281 KBytes 128 KBytes/sec 0,006 ms @/ 892 (@%) Example 11: How to Check Packet Loss through UDP Connection, I you want to determine the packet oss through the network then UDP is the best way to check and measure this loss. In this example, we are trying to connect Server 192.168.0.169 on UDP Port Se@i with a target bandwidth of 18 Mbits/sec. [root@locathost ~]# iper -c 192.168.0.100 -u -b 10% Client connecting to 192.168.0.160, UDP port 5001 Sending 147@ byte datagrans, 1°G target: 1176.02 us (Kelman adjust) UP buffer size: 208 KByte (default) [ 3] local 192,168.2.186 port 58487 connected with 192.168.@.188 port Se01 [ 10) Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 11.9 Mytes 10.0 Mbits/sec [3] Sent 2502 catagrans [ 3] Server Report: [3] 0.0-10.0 sec 11.9 maytes 10.6 Mbits/sec 0.009 ms 0/ 8503 (@%) Server Listening on UOP port 5201 Receiving 1470 byte datagrans OP buffer size: 208 KByte (default) [3] local 192.168.0.100 port 5201 connected with 192.168.0.105 port 58487 [ 10] Interval Transfer Bandwidth Jitter Lost/Total Datagrars [ 3] 0.0-10.0 sec 12205 KBytes 1221 KAytes/sec 0.009 ms @/ 8503 (0%) Example 12: How to Check UDP Network Statistics in Detail Ifyou want to check all the UDP Network Statistics like Transfer Bandwidth, Jitter, Packet Loss etc then you need to use below per commands. In client end, we will send the data to connect to UDP Port on Server 192.168.9.120 using bandwidth of 18 Mbits/sec, [root@localhost ~]# ipert -c 192.168.0.108 -u -b 108 Client connecting to 192.168.9.168, UDP port 5001 Sending 147@ byte datagrans, 1°G target: 1176.02 us (Kelman adjust) UP buffer size: 208 KByte (default) [ 3] local 192.168.0.106 port 35616 connected with 192.168.0.100 port See1 [ 1D] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 11.9 MBytes 10.0 Mbits/sec [ 3] Sent 8504 catagrans [ 3] Server Report [ 3] 8.0-10.0 sec 11.9 MBytes 10.0 Mbits/sec 8.003 ms 0/ 8504 (0%) You can also verify the stats from Server end as shown below, [root@localhost ~]# iperf -s -f K ~ Server Listening on UDP port 5801 Receiving 1478 byte datagrans OP buffer size: 208 Kayte (default) [ 3] local 192.168.0.100 port $801 connected with 192.168.0.106 port 35016 [ 10] Interval Transfer Bandwidth Jitter Lost/Total Datagrars [3] 0.0- 2.0 sec 2aaz Kaytes 1221 KBytes/sec 0.096 ms 0/ 1781 (OX) [3] 2.0- 4.0 sec 2642 Kaytes 1221 KBytes/sec 0.004 ms @/ 1781 (OX) [3] 4.0- 6.0 sec 2642 Kaytes 1221 KBytes/sec 0.006 ms 0/1781 (OX) [ 3] 6.0- 8.0 sec 2640 Kaytes 1220 KBytes/sec 0.009 ms @/ 1780 (OX) [ 3] 8.0-10.0 sec 2442 Kaytes 1221 KBytes/sec 0.009 ms @/ 1781 (OX) [ 3] 0.0-10.0 sec 12208 KBytes 1221 KBytes/sec 0.009 ms @/ 8504 (B%) pause n seconds between periodic bandwidth reports Example 13: How to Launch Par lel Network Bandwidth Tests I you want to run parallel network bandwidth tests then you need to use -P option jpert command and specify the number of connections as shown below. In this example we are trying to launch 4 Parallel Network Bandwidth tests by connecting 192, 168.0,18@ Server on Port 5001. 3] local 192.168.0166 port 54380 connected with 192.168.0.108 port Sea 5] Local 192-168.0.195 port 54384 connected with 192.168.0.108 port Se01 4) local 192.168.2.105 port 54382 connected with 192.168.0.100 port 5001 6] local 192-168.2.195 port 54386 connected with 192.168.0.108 port 5¢01 10) Interval Transfer Bandwidth 6] 0.0-10.0 sec 6.88 Gaytes 5.84 Gbits/sec 3] 0.0-10.0 sec 6.69 Gaytes 5.73 Gbits/sec 5] 0.0-10.0 sec 6.70 Gaytes 5.75 bits/sec [4] 0.0-10.0 sec 6.58 Gaytes 5.63 bits/sec [SUM] 0.0-10.0 sec 26.8 GBytes 22.9 Gbits/sec t t t t i t i t -P :number of parallel client threads to run Similarly you can go to Server end and check the number of client connections as shown below. Server Listening on Tc? port Seer TCP window size: 85.3 KByte (default) [ 6] local 192.168.0.169 port S0ai connected with 192.168.2.106 port 54384 [ 7] local 192.168.8.169 port S61 connected with 192.168.@.186 port 54386 [ 4] local 192.168.0.169 port S0a1 connected with 192.168.0.106 port 54380 [ 5] local 192.168..160 port 5861 connected with 192.168.@.186 port 54382 [ 1D] Interval Transfer Bandwidth t t [ t t 6] 8.8-10.0 sec 7027328 KBytes 699575 KBytes/sec 7] 0.0-10.1 sec 7131648 Kaytes 709131 KBytes/sec 4) 0.9-10.1 sec 7610304 KBytes 695462 KBytes/sec 5] .0-10.1 sec 6982400 KBytes 685541 KBytes/sec [SUM] 8.0-10.1 sec 28071680 KBytes 2784871 KBytes/sec Example 14: How to Test TCP Connection Using Maximum Segment Size Ifyou want to test TCP Connection using maximum segment size then you need to use -» option with iperf command as shown below. Usually MSS will have the size range from @-65535 bytes. Hence by specifying -m option with iperf command will use the maximum segment size of 65535 bytes for TCP testing [root@localhost ~]# iperf -< 192.168.0.10 -m Client connecting to 192.168.0.168, TCP port 5001 TCP window size: 4.00 MByte (default) 3] local 192.168.0.186 port 54390 connected with 192.168.0.160 port Seo 10] Interval Transfer Bandwidth 3] 0.0-10.0 sec 31.0 Gaytes 25.6 Gbits/sec 3] MSS size 65483 bytes (NTU 65523 bytes, unknown interface) -m: print TCP maximum segment size (MTU - TCP/IP header) Now you can go to Server end and check the response as shown below. A 4) local 192.168.0.108 port 5801 conne: { 1D} Interval Transfer Bandwidth [ 4} 0.0-10.0 sec 32477952 KBytes 3244064 KBytes/sec id with 192.168.0.206 port 54390 Example 15: How to check other options of iperf commands in Linux I you want to check all the other options available with iperf command then you need to use iperf --help command as shown below. [root@localhast =] iperf --hele Usage: iperf [-s|-c host) [options] Sper [-h|--help) [-v|--version] Client/Server: =b, =-bandwidth a{ke@kMs | pps] bandwidth to send at in bits/sec or packets per second fenhancedreports use enhanced reporting giving mone tcp/udp and traffic information Foreat [kngkMs] format to report: Kbits, Mbits, KBytes, MBytes Anterval # seconds between peniodic bandwidth reports Len #[knkM] length of buffer in bytes to read or write (Defaults: TCh print_nss print TCP maximum segment size (MTU - TCP/IP header) ‘output output the report or error message to this specified file port # server port to listen on/connect to Ludp use UDP rather than TCP idp-counters-6abit use 64 bit sequence nunbers with UDP “My “window #{KM] TCP window size (socket buffer size) realtime request realtire scheduler bind [:)[X] bind to , ip addr (including multicast address) and optional port and compatibility for use with older versions does not sent extra asgs inss # set TCP naximun segnent size (NTU - 49 bytes) nodelay set TCP no delay, disabling Nagle's Algoriths tos # set the sockets IP_TOS (byte) fielé 28K, v4 UDP=1478, v6 UDP=1450) Popular Recommendations:- How to Cleanup Failed Actions from PCS Status of Cluster How to Enable or Disable SELinux Temporarily or Permanently on RedHat/CentOS 7/8 10 Popular Examples of sudo command in Linux(RedHat/CentOS 7/8) How to Install and Use telnet command Linux (RedHat/Linux 7/8) using 5 Easy Steps 12 Most Popular rm command in Linux with Examples i ificate using Ba MORE, Linux Leave a Comment Name* Email Website Save my name, email, and website in this browser for the next time | comment. ws Azure Bash c ce cat Chef Cloud Database DevOps Docker Docker BK Git Go Google HTML Interview Questions Java JavaScript Kubernetes Linux macOS Monitoring MORE MySQL Networking Nodejs Openstack Oracle Perl PHP Powershell Programming Roy Scripting Security Solaris Terraform Windows Coa Recent Posts How to Navigate to Home Directory in Linux Using 4 Sy Methods How to Find the Serial Number on a MacBook Using 2 Easy Methods Benefits of using Node JS: Unleash the Power ofthis Revolutionary Technology Bash command or script to emulate watch utility functionality in Linux/Unix How to Solve Kubemetes Pod CreateContainerConfigError Solved "Kubernetes Pod CrashLoopBackOff with Exit Code 1” Error How to Install docker on Ubuntu 22.04 LTS Uammy Jellyfish) Solved “Could not get lock /varflib/dpkg/lock-frontend (unattended-upgr)" How to Enable or Disable Automatic Updates on Ubuntu/Debian Linux How to Install watch command on MacOS Using 7 Easy Steps Recent Comments an on Solved "WsIRegisterDistribution failed with error: 0x80370114 Egidijus on Solved "No remote refs found similar to ‘lathub™ error Shin on Solved “xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)" tu on Solved "WsIRegisterDistribution failed with error: 0x80370114 Siddhi on Solved *WsIRegisterDistribution failed with etror: x803701 14 kev on Solved "Could not chdir to home directory /home/oo0 in Linux Luis on Best Steps to Install and Configure OpenLDAP Server on RHEL/CentOS 7 First Name * Last Name Email Address * pvacy policy > Tener)

You might also like