Skip to content

CICD-332 · Packet loss simulation ​

Encyclopedia · Advanced networking and API testing · All snippets

Previous · CICD-331 · Next · CICD-333

1. Where it fits ​

  • Placement local ephemeral container only.
  • Prerequisites authorized test service, known endpoint or local fixture and the named test CLI.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
tc qdisc replace dev eth0 root netem loss 2%
tc -s qdisc show dev eth0

3. How it works ​

The netem qdisc introduces loss into the selected disposable lab interface. The statistics query records the resulting impairment before cleanup restores the interface.

4. Verify the result ​

Run inside an isolated lab network namespace with CAP_NET_ADMIN and remove the qdisc after testing. Never apply this to a shared host interface.

Watch for. Confine the test and all synthetic traffic to an authorized, disposable lab. Check cleanup even after a failing assertion.

Validation syntax-validated (Bash parse). Status definitions.