vim tc_delay.sh
tc qdisc add dev eth0 root netem delay 100ms tc qdisc show dev eth0 sleep 100 tc qdisc del dev eth0 root netem delay 100ms
# tc qdisc add dev eth0 root netem delay 100ms
This command sets the eth0 network card's transmission to be sent with a delay of 100ms .
In a more realistic situation, the delay value will not be so accurate, and there will be a certain fluctuation. We can use the following situation to simulate
Latency value with volatility:
# tc qdisc add dev eth0 root netem delay 100ms 10ms
This command sets the eth0 network card's transmission to be sent with a delay of 100ms ± 10ms ( any value between 90 and 110 ms ).
# tc qdisc add dev eth0 root netem delay 100ms 10ms 30%
This command sets the transmission of the eth0 network card to 100ms , and at the same time, about 30% of the packets are sent with a delay of ± 10ms .
# tc qdisc add dev eth0 root netem loss 1%
This command sets the transmission of the eth0 NIC to randomly drop 1% of the packets.
# tc qdisc add dev eth0 root netem loss 1% 30%
This command sets the transmission of the eth0 network card to randomly drop 1% of the packets, with a success rate of 30% .
Delete the relevant configuration on the network card: Change the add in the previous command to del to delete the configuration:
# tc qdisc del dev eth0 XXXXXXXXXXX (configuration added by yourself) This command will delete the relevant transmission configuration of the eth0 network card
# tc qdisc del dev eth0 root netem delay 100ms
# tc qdisc add dev eth0 root netem duplicate 1%
This command sets the transmission of the eth0 NIC to randomly generate 1% duplicate packets. 6 Simulate packet corruption:
# tc qdisc add dev eth0 root netem corrupt 0.2%
This command sets the eth0 NIC's transmission to randomly generate 0.2 % corrupted packets. ( The kernel version needs to be above 2.6.16 )
# tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%
This command sets the transmission of the eth0 network card to : 25% of the packets ( 50% relevant) will be sent immediately the rest will be delayed by 10 seconds.
In the new version, the following commands will also disrupt the order certain extent : # tc qdisc add dev eth0 root netem delay 100ms 10ms
View configured network conditions: # tc qdisc show dev eth0