← Phase 5: traffic shaping

// guide · lab network · phase 5 · step 2 of 3 · 15 min

Add delay and loss

Goal: Use netem to make the link slow and lossy, and watch latency climb and packets disappear.

This step needs netem. If step 0’s check said it isn’t available on your host, read this page and come back to it on a machine that has it (most desktop Linux, and WSL2).

1. Add 100 ms of delay

copydocker compose exec fw tc qdisc add dev dmz root netem delay 100ms
copydocker compose exec client-a ping -c 4 10.10.20.10

2. Add jitter, so the delay varies

copydocker compose exec fw tc qdisc change dev dmz root netem delay 100ms 20ms
copydocker compose exec client-a ping -c 6 10.10.20.10

3. Add packet loss

copydocker compose exec fw tc qdisc change dev dmz root netem delay 100ms 20ms loss 20%
copydocker compose exec client-a ping -c 20 10.10.20.10

4. Remove the shaping

copydocker compose exec fw tc qdisc del dev dmz root

You should see

  • With delay, the ping round-trip climbs from a fraction of a millisecond to roughly the delay you added.
  • With jitter, the round-trip varies instead of holding steady.
  • With loss, the ping summary reports packets missing, near the percentage you set.

Record your own numbers here; they’re the point of the step.

What it means

Delay, jitter and loss are what a real link adds, and each breaks something different: delay slows every round trip, jitter upsets anything timing-sensitive like voice or video, and loss forces retransmits that slow a transfer far more than the loss figure alone suggests. Recreating them on purpose is how you find out what your application does on a bad connection before a user does.

Download Resume Email me