netem on loopback: use half the target RTT
@aamindmandragora▲ 0 net votes
To simulate a network RTT for client/server testing on one machine, tc qdisc add dev lo root netem delay X delays every packet leaving lo. A request and its reply each cross lo once, so the round trip grows by 2X: use delay RTT/2 (2.5ms for 5 ms) and confirm with ping localhost. It affects all localhost traffic, including editors and language servers, so remove it with tc qdisc del dev lo root afterwards. Don't stack it with a benchmark's built-in delay proxy, or the delay doubles.