Skip to content
HN On Hacker News ↗

Pushing WireGuard on macOS to 5+ Gbit/s

▲ 66 points • 7 comments • by wh33zle • 5d ago • HN discussion ↗

Pangram verdict · v3.3

We believe this text is mainly human-written, with some AI content.

9 %

AI likelihood · overall

Human
91% human-written 9% AI-generated
SEGMENTS · HUMAN 12 of 18
SEGMENTS · AI 5 of 18
WORD COUNT 1,250
PEAK AI % 100% · §12
Analyzed
Nov 19
backend: pangram/v3.3
Segments scanned
18 windows
avg 69 words each
Distribution
91 / 9%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 1,250 words · 18 segments analyzed

Human AI-generated
§1 Human · 0%

We are on a never-ending quest to offer the fastest WireGuard VPN possible, on every platform. Historically, performance improvements to VPNs have often been limited to Linux as it offers the most versatile and most optimized APIs for fast I/O. We'll get into the details as to how that matters later in this post. Much to the dismay of many Linux enthusiasts, even 2026 isn't really the year of the Linux desktop. Especially in the enterprise world where VPNs are used extensively to protect company networks, most users connect from Windows or Apple devices. As such, when building a fast VPN you really ought to focus on Apple and Windows devices too, and in our humble opinion, your VPN shouldn't limit you in how fast you can transfer data. If you have a 5 Gbit/s Internet connection, you should be able to use that completely. Unlike our Linux and Windows builds, Firezone on macOS and iOS wasn't performing as well as we would have liked, achieving 1 Gbit/s download speed at best and upload speeds often being crippled to a few hundred Mbit/s. The problem got worse with higher latency, which was a hint that packets might be getting lost somewhere. In this post, we are going to talk through how we optimized the Firezone macOS Client from around 1 Gbit/s to over 5 Gbit/s. It is a mix of networking theory and hunting through the XNU source code to uncover how exactly TUN and UDP work on Darwin, the core of Apple's operating system that macOS and iOS build upon. What even is the maximum throughput? A network like the Internet is built from many intermediary devices and paths. Unsurprisingly, the maximum throughput you can get between two endpoints is limited by the slowest device or link along the path. What is perhaps surprising is how we even know what the maximum throughput is. Throughput isn't something that gets advertised and then both ends of the connection adhere to it. Instead, throughput is something you measure and adapt to dynamically. The Internet Protocol (IP) was designed to tolerate packet loss. An IP packet is sent as fire-and-forget and it is the job of protocols built on top of it to deal with lost or untransmitted packets. Protocols like TCP and QUIC therefore come with a congestion controller. It is the congestion controller's job to track what got sent, what the remote received (i.e. acknowledged), how long it took to send the data and from there calculate how fast it should send data. This continuous feedback loop is the reason why a speed test doesn't just immediately report your maximum speed and it first has to "warm up". Essentially, the congestion controller starts with a default window size, sends the data, waits for it to be acknowledged by the remote, measures the round-trip time (RTT) and then starts to increase the window size. The bandwidth-delay product defines how these variables interact. At an RTT of 20 ms, a window size of 1 MB gives us an upper bound of 400 Mbit/s of throughput. Increasing the window size to 2 MB allows for a maximum throughput of 800 Mbit/s. By varying the amount of data that is in flight (and thus unacknowledged), the congestion controller steers the speed of the transfer. On modern Windows (10+), Linux and macOS, the default congestion controller for TCP is CUBIC. CUBIC's algorithm is loss-based, which means it will reduce the window size (and thus the send rate) as soon as it concludes from the remote's acknowledgments that packets got lost. In TCP for example, this happens as part of the TCP header.

§2 Human · 0%

TCP numbers every byte it sends and the receiver's acknowledgment says "I have everything before byte N".

§3 Mixed · 32%

Based on this feedback, the sending side knows which packets are missing.

§4 AI · 100%

If the gap doesn't close within a short reordering window, it retransmits them and the congestion controller treats the gap as loss.

§5 Human · 0%

TCP acknowledgments around a lost segmentA sender and a receiver exchange numbered segments. Segment 1 arrives and the receiver answers ACK 2: it has everything before segment 2. Segment 2 is lost on the way. Segment 3 arrives, but the receiver's ACK stays at 2 because segment 2 is still missing.

§6 Human · 0%

The sender later retransmits segment 2.

§7 Human · 0%

Once it arrives, the receiver answers ACK 4: it now has everything before segment 4.SenderReceiversegment 1ACK 2segment 2lostsegment 3ACK 2segment 2, againACK 4For illustrative purposes, segment numbers are simplified here. ACK 4 doesn't get sent until segment 2 has been received. This exchange happens between the sender and the receiver of the connection.

§8 Human · 0%

Devices along the path do not explicitly negotiate a send rate with the sender.

§9 Human · 0%

They can signal congestion by dropping packets or, with Explicit Congestion Notification (ECN), by marking them. In both cases, it is the sender that adjusts the rate based on feedback from the receiving end. For physical network devices and links, this makes a lot of sense. An intermediary device has physical constraints in how many packets it can forward based on e.g. its clock speed. Packets arriving faster than they can be processed get dropped, which is how the sender learns that it has been sending packets too quickly. Given some ramp-up time, this is how the congestion controller finds a send rate the path can sustain by varying the size of the congestion window. The congestion window can shrink while the link stays busyAn illustrative graph of CUBIC's congestion window over time.

§10 Human · 1%

The window grows during slow start, then each loss reduces it to 70% before it grows again.

§11 AI · 100%

A lower reference marks the window needed to keep this link busy.

§12 AI · 100%

In this example, every reduced window remains above that reference, so queued packets can keep the link busy even while the sender backs off.

§13 Human · 0%

The graph shows the congestion window, not the throughput rate.timecongestion windowwindow at congestionwindow needed to keep link busyslow startpacket losswindow reduced by 30%Here, the window remains large enough to keep the link busy after each loss.

§14 AI · 100%

Queued packets can sustain throughput while the sender backs off.

§15 Human · 0%

When CUBIC detects packet loss, it reduces the congestion window by 30%. This sounds aggressive at first but does not directly translate into a 30% dip in the transfer rate. After all, data that is still in flight is still being drained and delivered. The congestion window only controls at what rate we are sending new data. Most importantly, all of this works based on feedback from the receiver, which is why it takes longer to settle on the effective throughput as latency to the receiver increases. Losing packets is expensive What does that mean for an overlay network like a VPN? The congestion controller doesn't know that the interface it is sending packets into is a virtual one. It treats it like any other network device. It is therefore important that we play by the congestion controller's rules: If it controls throughput by measuring packet loss, we better not lose or reorder any packets in our software.

§16 Human · 0%

Why does the order matter?

§17 AI · 100%

To the sender, a packet that arrives late initially looks just like a lost one: there is a gap in the acknowledgments. Networks can legitimately reorder packets, for example when they spread them across parallel paths.

§18 Human · 0%

That is why TCP waits for a short reordering window before declaring a packet lost. But if a packet arrives later than that, the sender has already retransmitted it and likely reduced its send rate for nothing.