WireGuard on the Raspberry Pi
Posted: Sun Sep 08, 2019 6:27 pm
Recently a way to encrypt network connections called WireGuard was announced thatWithout WireGuard the iperf3 and ping results for the Pi and Xeon are about the same. Bandwidth as measured by iperf3 for the Pi slowed down more over WireGuard than the Xeon, likely due to differences in CPU processing speed. The ping times for the Pi over WireGuard were typically the same as the Xeon to Xeon case at about 0.4ms; however, the average ping time was greater than 0.8ms in each test involving the Pi because there was at least one ping which took more than 2ms. Does anyone know why?
Since WireGuard is not included in the latest version of Raspbian Buster, I installed from source usingAs root I then followed the quick start instructions to set up a wg0 interface that is part of a virtual private network along with two Xeon E5-1650 servers.
The Pi 4B to Xeon iperf3 runs wereand the Xeon to Xeon iperf3 runsThe Pi 4B to Xeon ping runs wereand the Xeon to Xeon ping runs
- operates like IPSec at the kernel level for efficiency;
- uses 4000 lines of code instead of 600,000 lines.
Code: Select all
Direct WireGuard Relative
iperf3 ping iperf3 ping iperf3 ping
Pi4B to Xeon 936 0.182 704 0.874 75% 20%
Xeon to Xeon 935 0.207 896 0.481 96% 43%
Since WireGuard is not included in the latest version of Raspbian Buster, I installed from source using
Code: Select all
$ wget https://git.zx2c4.com/WireGuard/snapshot/WireGuard-0.0.20190905.tar.xz
$ tar Jxf WireGuard-0.0.20190905.tar.xz
$ cd WireGuard-0.0.20190905
$ cd src
$ make -j8
$ sudo bash
# make install
The Pi 4B to Xeon iperf3 runs were
Code: Select all
$ iperf3 -c 192.168.177.2 ; # Pi 4B to Xeon over WireGuard
Connecting to host 192.168.177.2, port 5201
[ 5] local 192.168.177.4 port 57466 connected to 192.168.177.2 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 83.4 MBytes 700 Mbits/sec 0 417 KBytes
[ 5] 1.00-2.00 sec 84.1 MBytes 705 Mbits/sec 0 417 KBytes
[ 5] 2.00-3.00 sec 84.3 MBytes 707 Mbits/sec 0 417 KBytes
[ 5] 3.00-4.00 sec 85.3 MBytes 715 Mbits/sec 0 458 KBytes
[ 5] 4.00-5.00 sec 84.5 MBytes 709 Mbits/sec 0 458 KBytes
[ 5] 5.00-6.00 sec 83.5 MBytes 701 Mbits/sec 0 458 KBytes
[ 5] 6.00-7.00 sec 83.8 MBytes 703 Mbits/sec 0 458 KBytes
[ 5] 7.00-8.00 sec 85.5 MBytes 717 Mbits/sec 0 458 KBytes
[ 5] 8.00-9.00 sec 83.9 MBytes 704 Mbits/sec 0 458 KBytes
[ 5] 9.00-10.00 sec 83.8 MBytes 703 Mbits/sec 0 458 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 842 MBytes 706 Mbits/sec 0 sender
[ 5] 0.00-10.04 sec 841 MBytes 703 Mbits/sec receiver
iperf Done.
$ iperf3 -c d0.wulf ; # Pi 4B to Xeon direct no WireGuard
Connecting to host d0.wulf, port 5201
[ 5] local 192.168.174.145 port 55916 connected to 192.168.174.150 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 111 MBytes 935 Mbits/sec 1 366 KBytes
[ 5] 1.00-2.00 sec 112 MBytes 937 Mbits/sec 0 366 KBytes
[ 5] 2.00-3.00 sec 112 MBytes 940 Mbits/sec 0 366 KBytes
[ 5] 3.00-4.00 sec 112 MBytes 936 Mbits/sec 0 366 KBytes
[ 5] 4.00-5.00 sec 112 MBytes 939 Mbits/sec 0 366 KBytes
[ 5] 5.00-6.00 sec 112 MBytes 938 Mbits/sec 0 366 KBytes
[ 5] 6.00-7.00 sec 112 MBytes 937 Mbits/sec 0 366 KBytes
[ 5] 7.00-8.00 sec 112 MBytes 937 Mbits/sec 0 366 KBytes
[ 5] 8.00-9.00 sec 112 MBytes 937 Mbits/sec 0 366 KBytes
[ 5] 9.00-10.00 sec 112 MBytes 938 Mbits/sec 0 366 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.09 GBytes 938 Mbits/sec 1 sender
[ 5] 0.00-10.04 sec 1.09 GBytes 933 Mbits/sec receiver
iperf Done.
Code: Select all
$ iperf3 -c 192.168.177.2 ; # Xeon to Xeon over WireGuard
Connecting to host 192.168.177.2, port 5201
[ 5] local 192.168.177.3 port 34170 connected to 192.168.177.2 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 108 MBytes 902 Mbits/sec 0 314 KBytes
[ 5] 1.00-2.00 sec 107 MBytes 897 Mbits/sec 0 361 KBytes
[ 5] 2.00-3.00 sec 107 MBytes 897 Mbits/sec 0 383 KBytes
[ 5] 3.00-4.00 sec 107 MBytes 897 Mbits/sec 0 401 KBytes
[ 5] 4.00-5.00 sec 107 MBytes 898 Mbits/sec 0 419 KBytes
[ 5] 5.00-6.00 sec 107 MBytes 896 Mbits/sec 0 419 KBytes
[ 5] 6.00-7.00 sec 107 MBytes 894 Mbits/sec 0 419 KBytes
[ 5] 7.00-8.00 sec 107 MBytes 896 Mbits/sec 0 419 KBytes
[ 5] 8.00-9.00 sec 107 MBytes 897 Mbits/sec 0 419 KBytes
[ 5] 9.00-10.00 sec 107 MBytes 897 Mbits/sec 0 419 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.04 GBytes 897 Mbits/sec 0 sender
[ 5] 0.00-10.00 sec 1.04 GBytes 896 Mbits/sec receiver
iperf Done.
$ iperf3 -c d0.wulf ; # Xeon to Xeon direct no WireGuard
Connecting to host d0.wulf, port 5201
[ 5] local 192.168.174.151 port 35774 connected to 192.168.174.150 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 113 MBytes 947 Mbits/sec 0 369 KBytes
[ 5] 1.00-2.00 sec 112 MBytes 937 Mbits/sec 0 369 KBytes
[ 5] 2.00-3.00 sec 111 MBytes 935 Mbits/sec 0 369 KBytes
[ 5] 3.00-4.00 sec 111 MBytes 932 Mbits/sec 0 369 KBytes
[ 5] 4.00-5.00 sec 111 MBytes 934 Mbits/sec 0 369 KBytes
[ 5] 5.00-6.00 sec 112 MBytes 937 Mbits/sec 0 369 KBytes
[ 5] 6.00-7.00 sec 111 MBytes 935 Mbits/sec 0 369 KBytes
[ 5] 7.00-8.00 sec 111 MBytes 931 Mbits/sec 0 369 KBytes
[ 5] 8.00-9.00 sec 111 MBytes 934 Mbits/sec 0 397 KBytes
[ 5] 9.00-10.00 sec 112 MBytes 937 Mbits/sec 0 397 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.09 GBytes 936 Mbits/sec 0 sender
[ 5] 0.00-10.00 sec 1.09 GBytes 934 Mbits/sec receiver
iperf Done.
Code: Select all
$ ping -c 5 192.168.177.2 # ; Pi 4B to Xeon over WireGuard
PING 192.168.177.2 (192.168.177.2) 56(84) bytes of data.
64 bytes from 192.168.177.2: icmp_seq=1 ttl=64 time=0.512 ms
64 bytes from 192.168.177.2: icmp_seq=2 ttl=64 time=0.434 ms
64 bytes from 192.168.177.2: icmp_seq=3 ttl=64 time=2.51 ms
64 bytes from 192.168.177.2: icmp_seq=4 ttl=64 time=0.453 ms
64 bytes from 192.168.177.2: icmp_seq=5 ttl=64 time=0.468 ms
--- 192.168.177.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 138ms
rtt min/avg/max/mdev = 0.434/0.874/2.505/0.816 ms
$ ping -c 5 d0.wulf # ; Pi 4B to Xeon direct no WireGuard
PING d0.wulf (192.168.174.150) 56(84) bytes of data.
64 bytes from d0.wulf (192.168.174.150): icmp_seq=1 ttl=64 time=0.190 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=2 ttl=64 time=0.140 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=3 ttl=64 time=0.176 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=4 ttl=64 time=0.194 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=5 ttl=64 time=0.211 ms
--- d0.wulf ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 125ms
rtt min/avg/max/mdev = 0.140/0.182/0.211/0.025 ms
Code: Select all
$ ping -c 5 192.168.177.2 ; # Xeon to Xeon over WireGuard
PING 192.168.177.2 (192.168.177.2) 56(84) bytes of data.
64 bytes from 192.168.177.2: icmp_seq=1 ttl=64 time=0.485 ms
64 bytes from 192.168.177.2: icmp_seq=2 ttl=64 time=0.476 ms
64 bytes from 192.168.177.2: icmp_seq=3 ttl=64 time=0.471 ms
64 bytes from 192.168.177.2: icmp_seq=4 ttl=64 time=0.515 ms
64 bytes from 192.168.177.2: icmp_seq=5 ttl=64 time=0.460 ms
--- 192.168.177.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 53ms
rtt min/avg/max/mdev = 0.460/0.481/0.515/0.027 ms
$ ping -c 5 d0.wulf ; # Xeon to Xeon direct no WireGuard
PING d0.wulf (192.168.174.150) 56(84) bytes of data.
64 bytes from d0.wulf (192.168.174.150): icmp_seq=1 ttl=64 time=0.223 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=2 ttl=64 time=0.226 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=3 ttl=64 time=0.218 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=4 ttl=64 time=0.220 ms
64 bytes from d0.wulf (192.168.174.150): icmp_seq=5 ttl=64 time=0.150 ms
--- d0.wulf ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 58ms
rtt min/avg/max/mdev = 0.150/0.207/0.226/0.031 ms