From 7b27f66ab241ff08ab653225a97b6481cf952d0e Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Wed, 25 Nov 2026 18:06:16 +0000 Subject: [PATCH] nixos/home: Use BBR on castle and the routers `estuary`'s port in ColoClue DC6 loses bursts of packets whenever the members switch floods other members' traffic to it. CUBIC treats each burst as congestion and takes 20-30 s to recover, longer than the gap between floods. BBR keeps going: uploading from `river` to `estuary`, it averaged 185 Mbit/s against CUBIC's 149 Mbit/s. Add a `my.network.bbr` option and enable it on `castle`, which uploads to colony, and on the home routers. The routers only gain for their own connections, since congestion control doesn't apply to forwarded traffic. BBR paces itself, so the default qdisc is left alone. Co-Authored-By: Claude Opus 5.5 --- nixos/boxes/home/castle/default.nix | 1 + nixos/boxes/home/routing-common/default.nix | 1 + nixos/modules/network.nix | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/nixos/boxes/home/castle/default.nix b/nixos/boxes/home/castle/default.nix index adb153e..d19dc9e 100644 --- a/nixos/boxes/home/castle/default.nix +++ b/nixos/boxes/home/castle/default.nix @@ -221,6 +221,7 @@ in my = { tmproot.size = "24G"; + network.bbr = true; user = { config.extraGroups = [ "input" ]; diff --git a/nixos/boxes/home/routing-common/default.nix b/nixos/boxes/home/routing-common/default.nix index 896bd09..7a12e59 100644 --- a/nixos/boxes/home/routing-common/default.nix +++ b/nixos/boxes/home/routing-common/default.nix @@ -317,6 +317,7 @@ in as211024 = config.age.secrets."l2mesh/as211024.key".path; }; }; + network.bbr = true; firewall = { trustedInterfaces = [ "lan-hi" "lan-lo" ]; udp.allowed = [ 5353 ]; diff --git a/nixos/modules/network.nix b/nixos/modules/network.nix index 80fabb0..3e916a4 100644 --- a/nixos/modules/network.nix +++ b/nixos/modules/network.nix @@ -1,8 +1,16 @@ { lib, pkgs, config, ... }: let inherit (lib) flatten optional mkIf mkDefault mkMerge versionAtLeast; + inherit (lib.my) mkBoolOpt'; + + cfg = config.my.network; in { + options.my.network.bbr = mkBoolOpt' false + ("Whether to use BBR congestion control for TCP connections this box sends. Unlike the default " + + "(CUBIC), BBR doesn't treat packet loss as congestion, so it keeps throughput up on lossy paths. " + + "It has no effect on traffic the box forwards."); + config = mkMerge [ { networking = { @@ -22,6 +30,14 @@ in }; } + (mkIf cfg.bbr { + # BBR paces its own sending, so the default qdisc (fq_codel) stays as it is. + boot = { + kernelModules = [ "tcp_bbr" ]; + kernel.sysctl."net.ipv4.tcp_congestion_control" = "bbr"; + }; + }) + (mkIf config.my.build.isDevVM { networking.interfaces.eth0.useDHCP = mkDefault true; virtualisation = {