Network Simulation
Linux Network emulator linuxfoundation
- Delay all packets out eth0
# tc qdisc add dev eth0 root netem delay 100ms
- Delay + 10ms variation, each 25% correlated to previous value.
# tc qdisc change dev eth0 root netem delay 100ms 10ms 25%
- Other options
- loss 0.3% 25% (% loss and correlation)
- duplicate 1%
corrupt 0.1% << corrupts single bit
Rate control
- There is no rate control built-in to the netem discipline, use Token Bucket Filter (TBF) to limit output.
# tc qdisc add dev eth0 root handle 1:0 netem delay 100ms # tc qdisc add dev eth0 parent 1:1 handle 10: tbf rate 256kbit buffer 1600 limit 3000 # tc -s qdisc ls dev eth0 qdisc netem 1: limit 1000 delay 100.0ms Sent 0 bytes 0 pkts (dropped 0, overlimits 0 ) qdisc tbf 10: rate 256Kbit burst 1599b lat 26.6ms Sent 0 bytes 0 pkts (dropped 0, overlimits 0 )
- To check status
tc -s qdisc
- To remove the delay from eth0
tc qdisc del dev eth0 root
- Here is a simple example that only controls traffic to one IP address.
tc qdisc add dev eth0 root handle 1: prio tc qdisc add dev eth0 parent 1:3 handle 30: netem \ delay 200ms 10ms distribution normal tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit 3000 tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \ match ip dst 172.17.34.0/24 flowid 10:3