Traffic Control (tc)

Network Delay

  1. Simulate network delay.
$ tc qdisc add dev enp0s3 root netem delay 300ms
# tc qdisc change dev enp0s3 root netem delay 300ms

$ tc qdisc show dev enp0s3
qdisc netem 8001: root refcnt 2 limit 1000 delay 300ms
  1. Ping test.
$ ping -c1 google.com
64 bytes from nchkga-ap-in-f14.1e100.net (142.250.198.46): icmp_seq=1 ttl=116 time=403 ms
  1. Stop network delay simulation.
$ tc qdisc del dev enp0s3 root


$ tc qdisc show dev enp0s3
qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64
  1. Ping test.
$ ping -c1 google.com
64 bytes from nchkga-ap-in-f14.1e100.net (142.250.198.46): icmp_seq=1 ttl=116 time=57.7 ms

Packet Loss

  1. Simulate packet loss.
$ tc qdisc add dev enp0s3 root netem loss 20%

$ tc qdisc show dev enp0s3
qdisc netem 8002: root refcnt 2 limit 1000 loss 20%
  1. Ping test.
$ ping -c 100 google.com
10 packets transmitted, 8 received, 20% packet loss, time 9189ms

Packet Corruption

$ tc qdisc change dev enp0s3 root netem corrupt 5%

Packet Duplication

$ tc qdisc change dev eth0 root netem duplicate 1%