Summary of delay commands for simulating packet loss in centos
Summary of delay commands for simulating packet loss in linux:
First, run the ifconfig command.
1. Set latency
Latency: sudo tc qdisc add dev eth0 root netem delay 30 ms
Latency in the range (10-50 ms): sudo tc qdisc add dev eth0 root netem delay 30 ms 20 ms
Set the delay to 30 ms, and about 20% packets will delay sending sudo tc qdisc add dev eth0 root netem delay 30 ms 20 ms 20%
Display delay settings: sudo tc qdisc show
Modification delay: sudo tc qdisc change dev eth0 root netem delay 40 ms
Deletion delay: sudo tc qdisc del dev eth0 root netem delay 40 ms
2. Set packet loss
Packet loss: sudo tc qdisc add dev eth0 root netem loss 10%.
10% of data packets are randomly dropped. The success rate is 20%: sudo tc qdisc add dev eth0 root netem loss 10% 20%.
Delete packet loss: sudo tc qdisc del dev eth0 root netem loss 10%
3. Duplicate simulated packages
1% duplicate packets are randomly generated: sudo tc qdisc add dev eth0 root netem duplicate 1%
4. data packet corruption
0.2% corrupted data packets are randomly generated: sudo tc qdisc add dev eth0 root netem packet upt 0.2%
5. unordered data packets
25% of data packets (related to 50%) will be sent immediately, and the other delay is 10 seconds: sudo tc qdisc change dev eth0 root netem delay 10 ms reorder 25% 50%
6. Check the configured network conditions for production
Sudo tc qdisc show dev eth0
7. Delete tc rules
Sudo tc qdisc del dev eth0 root