WEBVTT

1
00:00:00.300 --> 00:00:05.880
Port 51820 is only a habit for a WireGuard server.

2
00:00:05.900 --> 00:00:08.680
Started twelve times with no port set,

3
00:00:08.700 --> 00:00:12.060
our test client came up on twelve different ports.

4
00:00:12.480 --> 00:00:18.700
WireGuard's own documentation uses 51820 in its examples.

5
00:00:18.720 --> 00:00:21.340
That number sits in a range of ports that is

6
00:00:21.360 --> 00:00:25.810
never assigned, and WireGuard sends only UDP.

7
00:00:26.230 --> 00:00:27.650
Here is one packet,

8
00:00:27.670 --> 00:00:30.450
seen from both sides of a Linux NAT that we

9
00:00:30.470 --> 00:00:32.370
set to randomise ports.

10
00:00:32.390 --> 00:00:35.970
The client sent it from 51820.

11
00:00:35.990 --> 00:00:38.770
The server saw 48491,

12
00:00:38.790 --> 00:00:41.490
and other ports in our two other runs.

13
00:00:41.510 --> 00:00:46.870
WireGuard answers whichever port the last authenticated packet came from.

14
00:00:47.280 --> 00:00:50.220
WireGuard has no TCP mode,

15
00:00:50.240 --> 00:00:56.460
and its documentation blames the performance of TCP inside TCP.

16
00:00:56.480 --> 00:01:00.860
So we wrote a forty-line relay that carries WireGuard's packets

17
00:01:00.880 --> 00:01:03.340
inside one TCP connection,

18
00:01:03.370 --> 00:01:05.660
and made the link lose packets.

19
00:01:06.080 --> 00:01:08.860
With half a percent to two percent of packets lost

20
00:01:08.880 --> 00:01:12.300
each way, one download through our relay ran about as

21
00:01:12.320 --> 00:01:16.220
fast as over plain UDP:

22
00:01:16.240 --> 00:01:19.260
9.1 megabits a second against 9.2,

23
00:01:19.280 --> 00:01:22.700
and 4.1 against 4.0.

24
00:01:22.720 --> 00:01:24.530
It did not collapse.

25
00:01:24.950 --> 00:01:26.770
Our reading of the counters:

26
00:01:26.790 --> 00:01:29.970
the outer connection repaired every loss itself,

27
00:01:29.990 --> 00:01:32.930
so the download inside never saw one,

28
00:01:32.950 --> 00:01:37.330
with zero resends in all sixty runs through our large-buffer

29
00:01:37.350 --> 00:01:40.370
relay. It kept widening its window,

30
00:01:40.390 --> 00:01:43.600
and the extra data waited in the relay's queue.

31
00:01:44.020 --> 00:01:45.920
That queue is the price.

32
00:01:45.940 --> 00:01:47.360
During the download,

33
00:01:47.380 --> 00:01:51.360
the median ping was twenty milliseconds over UDP.

34
00:01:51.380 --> 00:01:56.640
Through our relay it was 507 to 715 milliseconds,

35
00:01:56.660 --> 00:01:59.680
and one ping in a hundred took about one and

36
00:01:59.700 --> 00:02:02.160
a half to two and a quarter seconds or more.

37
00:02:02.580 --> 00:02:07.200
Our first relay made TCP look far worse:

38
00:02:07.220 --> 00:02:11.200
47.1 megabits a second against 794.5,

39
00:02:11.220 --> 00:02:12.960
with no loss at all.

40
00:02:12.980 --> 00:02:17.600
Its own dropped packets tracked the download's resends,

41
00:02:17.620 --> 00:02:20.080
190 against 190 in one run.

42
00:02:20.100 --> 00:02:21.920
We were measuring our relay.

43
00:02:21.940 --> 00:02:25.740
With a bigger buffer it reached 635,

44
00:02:25.760 --> 00:02:28.140
still short of plain UDP.

45
00:02:28.560 --> 00:02:32.620
So open one UDP port where the first packet arrives,

46
00:02:32.640 --> 00:02:34.540
let the client pick its own,

47
00:02:34.560 --> 00:02:37.980
and if a tunnel runs inside TCP,

48
00:02:38.000 --> 00:02:41.290
judge it by its delay as well as its speed.

