# Performance, tuning, and the cipher stance

> culvert's defaults err high-security first and resilient-everywhere second.
> What moves the needle for a client on a hostile network, what is a host
> concern rather than a culvert setting, and why the shipped cipher is the
> "boring" one.

## Tuning profiles

Tuning is data, not code. It lives in `profiles/*.yaml`, loaded via
`CULVERT_PROFILE` (a shipped name, or a path to your file). Seven are
shipped. The two tuning baselines are `default` and `mobile`. `home`,
`corporate`, `travel` and `edge-fleet` are deployment profiles, and `example`
is a template:

- `default` - the general-purpose baseline: `mssfix 1420` (off the PPPoE
  fragmentation cliff), OS-auto socket buffers, WireGuard MTU 1420 (1500 less
  the IPv6 outer headers).
- `mobile` - constrained or extra-encapsulated paths (5G, phone tether,
  hotel/captive wifi, CGNAT): larger OpenVPN buffers, `tun-mtu`/`mssfix` 1400,
  tolerant keepalive, and WireGuard MTU 1280.

Neither loads unless `CULVERT_PROFILE` names it. With no profile the code
defaults apply, the same as `default` except `mssfix 1450`.

The one client-resilience knob that matters most is MTU. A 1420 WireGuard
tunnel black-holes on a ~1400 NAT64/CGNAT/PPPoE path: it connects, the
handshake completes, then large transfers stall silently because carriers
filter the ICMP that would signal "too big". 1280 is the IPv6 minimum every
network must pass, so it gets through with headroom. Everything else in the
profiles (buffers, keepalive) is smoothing. MTU is the difference between
"works" and "connects but hangs".

Copy a profile, change values, point `CULVERT_PROFILE` at your file. There are
no hidden presets in code.

## Ciphers: AES-256-GCM first, ChaCha20-Poly1305 second

The data channel ships `data-ciphers AES-256-GCM:CHACHA20-POLY1305`.

AES-256-GCM leads for compliance. CNSA 2.0 and FIPS name AES-256 and neither names ChaCha20, and the deployments culvert is built for often have to pass that audit. So the CNSA-classical path (TLS 1.3, P-384, SHA-384, tls-crypt-v2, AES-256-GCM) is what ships by default.

ChaCha20-Poly1305 is offered second because it is the safer cipher on a CPU without AES-NI: constant-time by construction, so no cache-timing side channel, and the same speed on a Xeon and a Cortex-A53. TLS 1.3, SSH and WireGuard default to it for those reasons.

The order is a per-profile setting (`data_ciphers`, or `CULVERT_DATA_CIPHERS`):

- `default` profile: `AES-256-GCM:CHACHA20-POLY1305`. The CNSA and FIPS lead, ChaCha20 still offered. This is what ships.
- `mobile` profile: `CHACHA20-POLY1305:AES-256-GCM`. ChaCha20 first for the clients without AES-NI that profile targets. Picking it leaves the CNSA suite in exchange for mobile-client performance, and AES-256-GCM stays offered, so nothing weaker is negotiated.
- ChaCha20 everywhere, without OpenVPN: WireGuard. Its suite is fixed at ChaCha20-Poly1305, Curve25519 and BLAKE2s, fast on every CPU, and it re-handshakes across network switches, so it is the better path for roaming clients. WireGuard is outside CNSA by design.
- CNSA or FIPS required: the `default` profile with `CULVERT_DATA_CIPHERS=AES-256-GCM`, which rejects the ChaCha20 fallback outright.

The default profile is never reordered to ChaCha20 first. That would leave CNSA silently, where the mobile profile makes the same trade as a labelled choice.

## Data Channel Offload (DCO) - a host readiness item, not a culvert setting

DCO moves OpenVPN's data-channel crypto into the kernel and multi-threads it,
the single biggest OpenVPN throughput win. It is a HOST property, not
something a profile can turn on:

- The `ovpn` module is in the kernel from Linux 6.16. On an older kernel the
  ovpn-backports DKMS project builds it. Either way needs OpenVPN 2.7+ (culvert
  ships it) and an AEAD cipher with no compression (culvert's defaults
  satisfy this). The older `ovpn-dco` module and its `openvpn-dco-dkms` package
  serve OpenVPN 2.6 and do nothing for 2.7.
- Without the module, OpenVPN runs its data channel in userspace - correct
  and secure, just slower, and single-core-per-tunnel. OpenVPN logs at
  startup that it is disabling data channel offload. Check it if throughput
  matters.

DCO is a server-scale throughput win. It does not change a single client's
resilience on a bad link. Prioritise it for a busy multi-client deployment,
not for a handful of road-warrior tunnels.

## Host sysctl - the other server-side lever

For lossy or high-latency (i.e. mobile) paths, set on the VPN host:

```ini
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
net.ipv4.ip_forward = 1
```

BBR + `fq` and larger UDP socket buffers are the biggest server-side help on
long-fat or lossy networks. NIC offloads (GRO/GSO/TSO) can batch packets for a
large CPU saving, but they are tuned on the *physical* NIC, not the tunnel
interface, and can regress inside virtualised/tunnel-in-tunnel stacks
(Proxmox, VXLAN) - treat them as a diagnostic lever, not a blanket default.

## What does NOT earn a place

- Reordering OpenVPN to ChaCha20-first as a default - leaves CNSA (see above).
- OpenVPN `float` for roaming - it widens attack surface by accepting an
  authenticated session from a different source IP. Use WireGuard for roaming
  instead.
- Compression - disabled on purpose (VORACLE), and it disables DCO as well.
