troubleshooting BSD TCP network performance
Recently I've been trying the BSD family of operating systems and I've been pleasantly surprised. I am no UNIX evangelist, but what started as mere curiosity (due to ocassionally using Solaris and HP-UX at work) has turned into full blown love for the feeling of simplicity and smoothness that comes with learning and administering the BSDs.
That's why I've decided to move my servers to one (or more) of them. In my local network they work perfectly, but when I installed them abroad I noticed some severe disparity in their handling of high latency TCP and HTTP traffic:

I am especially concerned about NetBSD, so I decided to take a closer look, and hopefully, ask for help.
Index
- Overview
- LAN: iperf3
- LAN: HTTP
- Internet/WAN: iperf3
- Internet/WAN: HTTP
- Tuning attempts
- Final thoughts and NetBSD
Overview
First, let's start with what I tried to test the network speeds:
- iperf3: server->client, TCP and UDP, over the Internet (US->Chile) and over my local network
- HTTP download: server->client, over the Internet (US->Chile) and over my local network
Tested operating systems:
- Alpine Linux v3.23 (Linux 6.18)
- FreeBSD 15.0-RELEASE
- OpenBSD 7.8
- NetBSD 10.1 and 11.0 RC1
Things to consider:
- All remote servers are installed on the same Proxmox (KVM+virtio) node in the US
- RTT latency to remote servers is ~209ms
- Local servers run in Proxmox as well
LAN: iperf3
Locally, all tested OSes are very capable of saturating the local network link, both through TCP and UDP:

We see no problems here.
LAN: HTTP
We can also observe flawless and quick HTTP downloads over the network:

Internet/WAN: iperf3
Over the Internet we can also observe in the iperf3 UDP tests that all OSes can easily saturate the uplink of the remote node at around 600 Mbit/s. That said, we can start seeing problems when it comes to TCP:

We can see the expected unstability that comes with a high-latency congested network, but they don't all seem to react equally to it. HTTP downloads show a clearer picture.
Internet/WAN: HTTP

Stock, I can observe the following:
- Alpine Linux seems to have the least trouble recovering from speed dips caused by network congestion.
- FreeBSD occassionally reaches higher speeds than Linux but speed dips are much more severe when they happen.
- OpenBSD seems stable enough but it seems to be capping at around 8-10 MiB/s. Dips are pronounced as well.
- NetBSD has the most trouble here, displaying several speed dips and seemingly a hard cap at around 986 KiB/s.
I generally don't need high speeds, but the hard wall that NetBSD seems to be hitting is concerning. You can see the tcpdump output here.
Tuning attempts
Since the speed stability issues seem to stem from congestion, I tried some different congestion control algorithms on Linux and FreeBSD. I enabled BBR on Linux:
/etc/sysctl.conf (Linux)
And did the same on FreeBSD:
/boot/loader.conf (FreeBSD)
/etc/sysctl.conf (FreeBSD)
I also tried to increase the buffer sizes on NetBSD, as I heard they're tiny by default:
/etc/sysctl.conf (NetBSD)
While NetBSD didn't improve, the speed boost achieved by BBR on FreeBSD was pretty incredible:

- Linux stayed mostly the same.
- FreeBSD was so fast it finished the download in 30 seconds. Congestion still causes dips but it also recovers much faster from them.
- OpenBSD didn't have tunables I could find (I may be wrong) since window sizing seems to be done fully automatically, but I'm happy with the stock result.
- NetBSD's tunables around send and recv buffers didn't help much with speed, they only increased packet loss instead.
Final thoughts and NetBSD
Overall I'm pretty happy with the result - congestion-triggered speed dips aren't too bad in practice, and for my usage (mostly HTTP web serving) OpenBSD's speeds are more than enough.
I'd really want to get a better result out of NetBSD, though. I'm really enjoying using it so far and it'd be a waste to replace it with something else if it's something that can be fixed. Browsing the mailing lists I saw someone getting 17 MB/s with the default settings so I'm not sure what's wrong in my case.
To rule out routing I tried installing it on different datacenters (Germany and Japan) and the results were similar.
So there you go - I'm ultimately looking forward to moving to the BSDs. But I'd love to have NetBSD as an option for me as well. I wish I had enough networking knowledge to pinpoint the issue. If you have any idea of what could be wrong, please contact me (preferably e-mail).