DEV Community

kunzhu0710
kunzhu0710

Posted on

Play with the iPerf test of Tencent Cloud CVM

Cloud Virtual Machine (CVM) provides you with secure and flexible computing capabilities. You can enable CVM in the cloud in just minutes to meet your diverse computing needs. Through (CVM)[https://www.tencentcloud.com/products/cvm?from_social=dev_8], you can easily scale up or down your computing resources as your business needs change. Billed based on your actual resource consumption, CVM reduces your computing costs and simplifies IT-related OPS.

When it comes to iPerf, everyone must know that it is a command used to test network performance. iPerf is an open source network performance testing tool developed by the University of Illinois. It can be used to test the performance of TCP or UDP connections between network nodes (including loopback), including bandwidth, jitter and packet loss rate, where jitter and packet loss rate are suitable for UDP testing, and bandwidth testing is suitable for TCP and UDP.
Generally speaking, the bandwidth test adopts UDP mode test, because the limit bandwidth, path delay, and packet loss rate can be measured in UDP mode, and these test items will be printed out in the bandwidth test report. When testing, first use the theoretical bandwidth of the link as the data transmission rate to test, for example, the theoretical bandwidth of the link from the client to the server is 1000Mbps, first use -b 1000M to test, and then according to the test results (including Actual bandwidth, delay jitter and packet loss rate), and then use the actual bandwidth as the data transmission rate to test, you will find that the delay jitter and packet loss rate are much better than the first time, repeat the test several times, you can get a stable actual bandwidth.
iPerf works based on the server-client mode. Therefore, to use iPerf to test bandwidth, you need to establish a server (for discarding traffic) and a client (for generating traffic). The iPerf server or client uses the same command, but the options to start the command are different.

Key Features of iPerf

TCP

Measure network bandwidth
Report size and observations of MSS/MTU values
Support for TCP window values ​​via socket buffering
Multithreading is supported when P threads or Win32 threads are available. Client and server support simultaneous multiple connections

UDP

Clients can create UDP streams of specified bandwidth
Measure packet loss
Measurement delay
Multicast support
Multithreading is supported when P threads are available. Client and server support simultaneous multiple connections (does not support Windows)

iPerf installation

To install IPerf, you can download it for different operating systems at https://iperf.fr/iperf-download.php. It is recommended to download the iPerf2 version. Since iPerf3 cannot support multi-process download, it is more troublesome to perform multi-process testing. The specific command can be modeled as follows:
Enable multithreading on the server:
iperf3 -s -p 5101&; iperf3 -s -p 5102&; iperf3 -s -p 5103 &
The client enables multithreading:
iperf3 -c hostname -T s1 -p 5101 &;
iperf3 -c hostname -T s2 -p 5102 &;
iperf3 -c hostname -T s3 -p 5103 &;
It can be seen that iPerf3 multi-threading is actually opening multiple ports for testing, which is troublesome, so it is recommended to download iperf2.

  1. For the windows version of iPerf, directly copy the decompressed iperf.exe and cygwin1.dll to the %systemroot% directory
  2. For the linux version of iPerf, please use the following command to install rpm -ivh iperf-.rpm # iPerf Startup Test

The iPerf test requires that the server side and the client side execute commands respectively to start

Server

iperf -s -p [端口]

client

iperf -c [server IP]
Note: iPerf tests the bandwidth of the TCP protocol by default. If you need to test the bandwidth of UDP, you need to add the -u option
The following is a simple test example:

1. Bandwidth test for TCP:

iperf -s -p 3389
iperf -c 10.104.17.84 -p 3389 -t 30 -i 1

Introduction of common indicators:

-c: client mode, followed by server ip
-p: followed by the port the server is listening on
-i: Set the time interval for bandwidth reporting, in seconds
-t: Set the duration of the test, the unit is seconds, the default is 10s if not set
-w: Set the size of the tcp window, generally do not need to be set, the default can be

To test multi-threaded TCP, add the -P parameter to the client to test the multi-threaded TCP performance
imageServer and client for TCP bandwidth test

2. Bandwidth test for UDP:

iperf -s -p 3389 -u
iperf -c 10.104.17.84 -p 3389 -i 1 -u -b 2000M

Introduction of common indicators:

-c: client mode, followed by server ip
-p: followed by the port the server is listening on
-i: Set the time interval for bandwidth reporting, in seconds
-t: Set the duration of the test, the unit is seconds, the default is 10s if not set
-b: Set the sending bandwidth of udp, in bit/s
imageUDP bandwidth test on server and client

iPerf common options

command line options describe
-f, --format [bkmaBKMA] Formatted bandwidth number output. The supported formats are: 'b' = bits/sec 'B' = Bytes/sec 'k' = Kbits/sec 'K' = KBytes/sec 'm' = Mbits/sec 'M' = MBytes/sec 'g' = Gbits/sec 'G' = GBytes/sec 'a' = adaptive bits/sec 'A' = adaptive Bytes/sec The adaptive format is one of kilo- and mega-. Fields other than bandwidth are output as bytes, unless the output format is specified, the default parameter is a. Note: When calculating bytes, Kilo = 1024, Mega = 1024^2, Giga = 1024^3. Usually, in the network, Kilo = 1000, Mega = 1000^2, and Giga = 1000^3, so Iperf also calculates bits (bits) accordingly. If this bothers you, use the -f b parameter and do the math yourself.
-i, --interval # Set the time interval between each report, in seconds. If set to a non-zero value, the test report will be output at this interval. The default value is zero.
-l, --len #[KM] Sets the length of the read and write buffers. The default value of TCP mode is 8KB, and the default value of UDP mode is 1470 bytes.
-m, --print_mss Output the TCP MSS value (supported via TCP_MAXSEG). The MSS value is generally 40 bytes smaller than the MTU value. Usually
-p, --port # Set the port to be the same as the listening port on the server side. The default is port 5001, the same as ttcp.
-u, --udp Use the UDP method instead of the TCP method. See the -b option.
-w, --window #[KM] Set the socket buffer to the specified size. For TCP mode, this setting is the TCP window size. For UDP mode, this setting is the buffer size for accepting UDP packets, limiting the maximum value that can accept packets.
-B, --bind host One of several addresses bound to the host. For the client, this parameter sets the popup interface. For the server side, this parameter sets the push interface. This parameter is only used on hosts with multiple network interfaces. In Iperf's UDP mode, this parameter is used to bind and join a multicast group. Use a multicast address in the range 224.0.0.0 to 239.255.255.255. See the -T parameter.
-C, --compatibility Compatibility mode can be used when working with lower versions of Iperf. It is not necessary to use compatibility mode on both ends, but it is strongly recommended to use compatibility mode on both ends. In some cases, the use of certain data streams can cause server-side crashes in version 1.7 or cause unexpected connection attempts.
-M, --mss #[KM} Attempt to set the TCP maximum segment value with the TCP_MAXSEG option. The size of the MSS value is usually the TCP/IP header minus 40 bytes. In Ethernet, the MSS value is 1460 bytes (MTU 1500 bytes). Many operating systems do not support this option.
-N, --nodelay Set the TCP no delay option to disable Nagle's algorithm. Normally this option is disabled for interactive programs, such as telnet.
-V (from v1.6 or higher) Bind an IPv6 address.
Server: $ iperf -s –V
Client: $ iperf -c -V
Note: In 1.6.3 or later, specifying an IPv6 address does not require binding with the -B parameter, as in versions prior to 1.6. On most operating systems, an IPv4 client-mapped IPv4 address will be responded.
Server-side dedicated options
-s, --server Iperf server mode
-D (v1.2 or later) Iperf runs as a background daemon under Unix platforms. Under the Win32 platform, Iperf will run as a service.
-R (v1.2 or later, Windows only) Uninstall the Iperf service (if it is running).
-o (v1.2 or later, Windows only) Redirect output to specified file
-c, --client host If Iperf is running in server mode and a host is specified with the -c parameter, then Iperf will only accept connections from the specified host. This parameter does not work in UDP mode.
-P, --parallel # The number of connections to keep before the server shuts down. The default is 0, which means connections are always accepted.
Client specific options
-b, --bandwidth #[KM] Bandwidth used in UDP mode, in bits/sec. This option is related to the -u option. The default value is 1 Mbit/sec.
-c, --client host Run Iperf in client mode and connect to the specified Iperf server.
-d, --dualtest Run dual test mode. This will reverse the connection from the server side to the client side, using the port specified in the -L parameter (or by default the port from which the client side connects to the server side). These are done immediately at the same time as the operation. If you want an interactive test, try the -r parameter.
-n, --num #[KM] The number of buffers to transmit. Normally, Iperf sends data every 10 seconds. The -n parameter crosses this limit, sending data of the specified length the specified number of times, regardless of how long the operation takes. See the -l and -t options.
-r, --tradeoff Reciprocating test mode. When the client-to-server test ends, the server connects back to the client through the port specified by the -l option (or the port that the client connects to the server by default). When the client connection is terminated, the reverse connection begins. If you need to test both ways at the same time, try the -d parameter.
-t, --time # Sets the total time for the transfer. Iperf repeatedly sends packets of the specified length within the specified time. The default is 10 seconds. See the -l and -n options.
-L, --listenport # Specifies the port used by the server to connect back to the client. By default, the port that the client connects to the server is used.
-P, --parallel # Threads. Specifies the number of threads to use between client and server. The default is 1 thread. This parameter needs to be used by both the client and the server.
-S, --tos # Type of service for outgoing packets. Many routers ignore the TOS field. You can specify this value using hexadecimal numbers starting with "0x", or octal or decimal numbers starting with "0".
For example, '0x10' in hexadecimal = '020' in octal = '16' in decimal. The TOS value of 1349 is:
IPTOS_LOWDELAY minimize delay 0x10
IPTOS_THROUGHPUT maximize throughput 0x08
IPTOS_RELIABILITY maximize reliability 0x04
IPTOS_LOWCOST minimize cost 0x02
-T, --ttl # The TTL value of the outgoing multicast packet. This is essentially the number of hops the data takes through the router. The default is 1, link-local.
-F (from v1.2 or higher) Bandwidth is measured using a specific data stream, such as a specified file.
$ iperf -c -F
-I (from v1.2 or higher) As with -F, input data from standard input and output files.
Miscellaneous
-h, --help Display the command line reference and exit.
-v, --version Display version information and build information and exit.

Top comments (0)