Testing Tunnel Performance with iperf2 UDP
In this guide, you'll learn how to use iperf2 in UDP-only mode to test
throughput and network behavior over a TUN-over-UDP tunnel. Unlike iperf3, which
always uses TCP as a control channel, iperf2 can operate in pure UDP mode,
making it ideal for testing scenarios where TCP connections are unreliable or
unavailable, such as high-latency links or networks with strict firewall rules.
Tunnel Setup
We assume you have a working TUN-based VPN tunnel between two Linux devices:
- Client (local): TUN IP
10.0.0.1 - Server (remote): TUN IP
10.0.0.2
iperf2 must be installed on both devices. You can install it via:
sudo apt install iperf
Why iperf2 UDP-Only Mode?
iperf2's key advantage over iperf3 is its ability to operate in pure UDP mode without requiring any TCP control channel. This makes it particularly valuable for:
- High-latency links where TCP handshakes might time out
- Firewall-restricted environments where only UDP traffic is allowed
- Networks with packet loss where TCP struggle to make a connection
iperf3, in contrast, always establishes a TCP control connection even for UDP tests, which can fail in challenging network conditions.
1. Start the iperf2 Server in UDP Mode
On the server side (10.0.0.2), run:
iperf -s -u
-s: Start in server mode-u: Use UDP protocol
This starts iperf2 in UDP listening mode, waiting for incoming UDP test
sessions without requiring any TCP control channel.
2. Run a UDP Test
UDP tests are great for measuring jitter, packet loss, and latency. However, since UDP is connectionless, you must specify the desired bandwidth.
On the client side (10.0.0.1), run:
iperf -c 10.0.0.2 -u -b 1M
-u: Use UDP-b 1M: Target bandwidth of 1 Mbps
Sample Output (UDP):
------------------------------------------------------------
Client connecting to 10.0.0.2, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 1] local 10.0.0.1 port 56655 connected with 10.0.0.2 port 5001
[ ID] Interval Transfer Bandwidth
[ 1] 0.0000-30.0120 sec 3.75 MBytes 1.05 Mbits/sec
[ 1] Sent 2679 datagrams
[ 1] Server Report:
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 1] 0.0000-30.0390 sec 3.75 MBytes 1.05 Mbits/sec 11.927 ms 0/2678 (0%)