WG Latency Router
Multi-relay WireGuard router & HUD
Measures every configured WireGuard relay against the direct route when a real-time UDP application launches, and tunnels only when the tunnel is faster.
Problem
A home connection’s route to a cloud region is whatever the ISP picks that day. For real-time UDP traffic, a WireGuard relay in the right city can beat it, or lose to it.
So the route is measured at every launch, not assumed.
Execution
A PowerShell loop, run elevated from a scheduled task. When the application starts it pings a check host inside the target region over the direct route, then brings each relay up in turn as a WireGuard tunnel service and measures it the same way.
The fastest relay stays up only if it beats direct, and it is measured again once it is back up, because a path that won seconds ago can slip. Only the target region’s address ranges ride the tunnel; they are refreshed from the cloud provider’s published list before each run.
- Direct
- Measures baseline RTT to the target region check host
- Relays
- Installs each WireGuard service in turn: 2 warm-up pings, median of 5
- Relay wins
- Kept only if faster than direct, then re-checked once active
- Direct wins
- All tunnels stay off; zero unnecessary VPN overhead
- Session loss >= 1.5%
- Marks relay bad and re-picks cleanly between sessions
- 2 failed checks + stale handshake
- Drops tunnel to direct and captures SSH mtr return trace
Atomic status.json + events.log feed the Rust ratatui HUD twice per second.
Two things retire a route. If the application’s own counters report 1.5% packet loss or more for a session, in or out, the relay is marked bad and the next pick skips it. If two liveness checks fail and the WireGuard handshake is stale, the tunnel comes down and traffic falls back to direct.
Ping loss alone never switches a route: in one recorded session the probes lost 6.1% through a relay while the application counted 0.00%. Routes never change mid-session either, because a new route is a new client address and a dropped connection.
When the ISP leg degrades or a tunnel dies, the loop saves evidence in both directions: an outbound traceroute, and an mtr run over SSH from a server in the target region back to the home address. A ping to the ISP’s own edge router says which side of the handoff is slow.
Status is written atomically to a JSON file. A Rust ratatui HUD reads it twice a second: active route, relay and direct round-trip times, per-hop probes, a latency sparkline, and the last session’s loss.
Numbers
- Benchmark
- Median of 5 pings per route, re-checked after the pick
- Recorded scan
- 32 relays, 7 regions: a relay won 6, direct won 1
- Largest gain
- 60 ms direct, 37 ms relayed
- Loss threshold
- 1.5% in or out retires a route
- Liveness
- 2 failed checks, then relay ping and handshake age
- Probes
- Once a second: 3 path hops and the check host
- Return path
- mtr over SSH, 10 cycles
- HUD
- Rust · ratatui