0009_Iperf3

iperf3 is a tool for network performance measurement. It is widely used to test the bandwidth between two endpoints in a network and can measure TCP, UDP, and SCTP throughput. iperf3 is useful for diagnosing network issues, verifying the quality of a network, and ensuring that a network can handle the required traffic.

Install iperf3:
On Linux, you can install it using the package manager:

sudo apt-get install iperf3

Basic TCP Test (Server and Client):

  • Server: Start iperf3 on one machine in server mode.
iperf3 -s

  • Client: Run the test from another machine.
iperf3 -c <server_ip>

  • This command tests the TCP bandwidth from the client to the server.

UDP Test:

  • Server:
iperf3 -s

Client:

iperf3 -c <server_ip> -u

The -u flag switches to UDP mode.

Specifying Bandwidth:

  • To specify the bandwidth for a UDP test, use the -b option:
iperf3 -c <server_ip> -u -b 10M

  • This example sends data at 10 Mbps.

Test Duration:

  • Use the -t option to set the test duration (in seconds):
iperf3 -c <server_ip> -t 30

  • This command runs the test for 30 seconds.

Parallel Streams:

    • To test multiple parallel streams, use the -P option:
iperf3 -c <server_ip> -P 5

This sends data over 5 parallel streams.

Test with Time-To-Live (TTL):

iperf3 -c <server_ip> --ttl 64

Test with Quality of Service (ToS) or Differentiated Services Code Point (DSCP):

iperf3 -c <server_ip> -S 0x20


ToS/DSCP: These values are used to prioritize network traffic. For example, 0x20 sets a priority for bulk data transfer.

Viewing Results:

  • The results will show the bandwidth achieved, loss rates (for UDP), and other metrics to assess the network’s performance.
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
  -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
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, 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
  -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'
  -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

ToS/DSCP ValueHexadecimal (DSCP)BinaryPriority/Type of TrafficDescription
00x00000000DefaultStandart traffic. No priority.
80x20001000CS1 Standard traffic. No priority.
160x40010000CS2OAM (Operations, Administration, and Management).
240x60011000CS3Signaling, call setup.
320x80100000CS4Streaming media, real-time interactive.
400xA0101000CS5Critical applications, video conferencing.
480xC0110000CS6Network control, routing protocols.
560xE0111000CS7Network control, high-priority traffic.
100x28001010AF11 Low drop precedence, medium priority traffic.
180x48010010AF21 Low drop precedence, high priority traffic.
260x68011010AF31 Low drop precedence, real-time interactive.
340x88100010AF41Low drop precedence, high-priority video and voice.
460xB8101110EFHigh-priority, low-latency traffic, often used for voice over IP (VoIP).
480xC0110000CS6Network control, routing protocols.
560xE0111000CS7Network control, high-priority traffic.

Key Terms:

  • CS (Class Selector): Used for backward compatibility with IP precedence.
  • AF (Assured Forwarding): Assures delivery under prescribed conditions.
  • EF (Expedited Forwarding): Ensures low loss, latency, and jitter traffic.

These DSCP values help prioritize network traffic, ensuring that more critical data (e.g., VoIP or video conferencing) gets the necessary bandwidth and lower latency.

Example Analysis for VoIP Using Iperf3

Objective: To determine if the existing network can support VoIP traffic with minimal latency, packet loss, and jitter.

Process:

  1. Run Iperf3 Server:

    • Start the server on one machine.
iperf3 -s

2. Run Iperf3 Client with VoIP Parameters:

  • On another machine, run the client specifying the server’s IP and parameters to simulate VoIP traffic:
iperf3 -c <server_ip> -u -b 100K -t 30 -S 0xB8

3. Parameters:

      • -u: Uses UDP (since VoIP uses UDP).
      • -b 100K: Limits bandwidth to 100 Kbps, typical for VoIP traffic.
      • -t 30: Test duration is 30 seconds.
      • -S 0xB8: Uses DSCP value 0xB8 (EF – Expedited Forwarding), meaning high priority and low latency.

4. Analyze Results:

    • Latency: Latency is critical. For VoIP, latency should be under 150 ms.
    • Packet Loss: Packet loss should be minimal (0-1%) for good VoIP quality.
    • Jitter: Jitter should be minimal, preferably under 30 ms for VoIP.

Possible Outcomes:

  1. Optimal Conditions:

    • Results: Latency < 100 ms, Packet Loss < 1%, Jitter < 20 ms.
    • Conclusion: The network is well-suited for VoIP with high-quality communication.
  2. Acceptable Conditions:

    • Results: Latency 100-150 ms, Packet Loss 1-2%, Jitter 20-30 ms.
    • Conclusion: The network is acceptable for VoIP, but occasional quality issues may occur.
  3. Unacceptable Conditions:

    • Results: Latency > 150 ms, Packet Loss > 2%, Jitter > 30 ms.
    • Conclusion: The network is not suitable for VoIP. Network improvements or load reduction are necessary.

Output example on a client-side:

iperf3 -c 192.168.XXX.XXX -u -b 100K -t 30 -S 0xB8
Setting UDP block size to 1460
Warning:  UDP block size 1460 exceeds TCP MSS 0, may result in fragmentation / drops
Connecting to host 192.168.10.150, port 5201
[  4] local 172.16.XXX.XXX port 64738 connected to 192.168.XXX.XXX port 5201
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.01   sec  11.4 KBytes  92.6 Kbits/sec  8
[  4]   1.01-2.01   sec  12.8 KBytes   105 Kbits/sec  9
[  4]   2.01-3.00   sec  11.4 KBytes  94.4 Kbits/sec  8
[  4]   3.00-4.01   sec  12.8 KBytes   105 Kbits/sec  9
[  4]   4.01-5.01   sec  12.8 KBytes   105 Kbits/sec  9
[  4]   5.01-6.00   sec  11.4 KBytes  94.4 Kbits/sec  8
[  4]   6.00-7.01   sec  12.8 KBytes   105 Kbits/sec  9
[  4]   7.01-8.01   sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]   8.01-9.00   sec  12.8 KBytes   106 Kbits/sec  9
[  4]   9.00-10.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  10.01-11.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  11.01-12.00  sec  12.8 KBytes   106 Kbits/sec  9
[  4]  12.00-13.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  13.01-14.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  14.01-15.00  sec  11.4 KBytes  94.4 Kbits/sec  8
[  4]  15.00-16.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  16.01-17.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  17.01-18.00  sec  12.8 KBytes   106 Kbits/sec  9
[  4]  18.00-19.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  19.01-20.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  20.01-21.00  sec  12.8 KBytes   106 Kbits/sec  9
[  4]  21.00-22.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  22.01-23.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  23.01-24.00  sec  11.4 KBytes  94.4 Kbits/sec  8
[  4]  24.00-25.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  25.01-26.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  26.01-27.00  sec  12.8 KBytes   106 Kbits/sec  9
[  4]  27.00-28.01  sec  11.4 KBytes  93.0 Kbits/sec  8
[  4]  28.01-29.01  sec  12.8 KBytes   105 Kbits/sec  9
[  4]  29.01-30.00  sec  12.8 KBytes   106 Kbits/sec  9
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-30.00  sec   366 KBytes   100 Kbits/sec  1.869 ms  0/257 (0%)
[  4] Sent 257 datagrams

iperf Done.

Output example on a server side:

Server listening on 5201
-----------------------------------------------------------
Accepted connection from 172.16.XXX.XXX, port 4140
[  5] local 192.168.XXX.XXX port 5201 connected to 172.16.XXX.XXX port 64738
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-1.00   sec  9.98 KBytes  81.8 Kbits/sec  0.318 ms  0/7 (0%)
[  5]   1.00-2.00   sec  11.4 KBytes  93.4 Kbits/sec  0.311 ms  0/8 (0%)
[  5]   2.00-3.00   sec  12.8 KBytes   105 Kbits/sec  0.254 ms  0/9 (0%)
[  5]   3.00-4.00   sec  11.4 KBytes  93.4 Kbits/sec  0.326 ms  0/8 (0%)
[  5]   4.00-5.00   sec  12.8 KBytes   105 Kbits/sec  0.408 ms  0/9 (0%)
[  5]   5.00-6.00   sec  11.4 KBytes  93.4 Kbits/sec  0.303 ms  0/8 (0%)
[  5]   6.00-7.00   sec  12.8 KBytes   105 Kbits/sec  0.461 ms  0/9 (0%)
[  5]   7.00-8.00   sec  12.8 KBytes   105 Kbits/sec  0.302 ms  0/9 (0%)
[  5]   8.00-9.00   sec  11.4 KBytes  93.4 Kbits/sec  0.506 ms  0/8 (0%)
[  5]   9.00-10.00  sec  12.8 KBytes   105 Kbits/sec  0.353 ms  0/9 (0%)
[  5]  10.00-11.00  sec  11.4 KBytes  93.4 Kbits/sec  0.307 ms  0/8 (0%)
[  5]  11.00-12.00  sec  12.8 KBytes   105 Kbits/sec  0.290 ms  0/9 (0%)
[  5]  12.00-13.00  sec  11.4 KBytes  93.4 Kbits/sec  0.414 ms  0/8 (0%)
[  5]  13.00-14.00  sec  12.8 KBytes   105 Kbits/sec  0.331 ms  0/9 (0%)
[  5]  14.00-15.00  sec  11.4 KBytes  93.4 Kbits/sec  0.306 ms  0/8 (0%)
[  5]  15.00-16.00  sec  12.8 KBytes   105 Kbits/sec  0.229 ms  0/9 (0%)
[  5]  16.00-17.00  sec  12.8 KBytes   105 Kbits/sec  0.203 ms  0/9 (0%)
[  5]  17.00-18.00  sec  11.4 KBytes  93.4 Kbits/sec  0.301 ms  0/8 (0%)
[  5]  18.00-19.00  sec  12.8 KBytes   105 Kbits/sec  0.353 ms  0/9 (0%)
[  5]  19.00-20.00  sec  11.4 KBytes  93.4 Kbits/sec  0.275 ms  0/8 (0%)
[  5]  20.00-21.00  sec  12.8 KBytes   105 Kbits/sec  0.373 ms  0/9 (0%)
[  5]  21.00-22.00  sec  11.4 KBytes  93.4 Kbits/sec  0.657 ms  0/8 (0%)
[  5]  22.00-23.00  sec  12.8 KBytes   105 Kbits/sec  0.458 ms  0/9 (0%)
[  5]  23.00-24.00  sec  11.4 KBytes  93.4 Kbits/sec  0.338 ms  0/8 (0%)
[  5]  24.00-25.00  sec  12.8 KBytes   105 Kbits/sec  0.325 ms  0/9 (0%)
[  5]  25.00-26.00  sec  12.8 KBytes   105 Kbits/sec  0.257 ms  0/9 (0%)
[  5]  26.00-27.00  sec  11.4 KBytes  93.4 Kbits/sec  0.231 ms  0/8 (0%)
[  5]  27.00-28.00  sec  12.8 KBytes   105 Kbits/sec  0.208 ms  0/9 (0%)
[  5]  28.00-29.00  sec  11.4 KBytes  93.4 Kbits/sec  0.219 ms  0/8 (0%)
[  5]  29.00-30.00  sec  12.8 KBytes   105 Kbits/sec  1.873 ms  0/9 (0%)
[  5]  30.00-30.27  sec  2.85 KBytes  85.7 Kbits/sec  1.869 ms  0/2 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-30.27  sec   366 KBytes  99.2 Kbits/sec  1.869 ms  0/257 (0%)  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------


If you need to evaluate the channel for possible operation through this communication channel of 100 IP phones, then the speed should be increased to 10 Mbps, and the minimum test time is 60 seconds