Using TC to simulate network delay and packet loss under Linux

Source: Internet
Author: User

Bandwidth or flow rate unit:

Kbps Kbyte/sec Kilobytes per second
Mbps Mbyte/sec Megabytes per second
Kbit Kbits/sec
Mbit Mbits/sec

1 , Analog Delay Transfer

# TC Qdisc Add dev eth0 root netem delay 100ms

This command sets the transmission of the eth0 NIC to a delay of 100 milliseconds to send.

In a more realistic case, the delay value will not be so accurate, there will be a certain fluctuation, we can use the following conditions to simulate the delay value with volatility:

# TC Qdisc Add dev eth0 root netem delay 100ms 10ms

This command sets the transmission of the ETH0 network card to a delay of 100ms±10ms (any value between a maximum of $ ms).

The randomness of this fluctuation can also be further enhanced:

# TC Qdisc Add dev eth0 root netem delay 100ms 10ms 30%

This command sets the transmission of the eth0 NIC to 100ms, and approximately 30% of the packets delay the ±10MS send.

2 , analog network packet loss

# TC Qdisc Add dev eth0 root netem loss 1%

This command sets the transmission of the eth0 NIC to randomly discard 1% of packets.

You can also set the success rate of packet loss:

# TC Qdisc Add dev eth0 root netem loss 1% 30%

This command sets the transmission of the eth0 NIC to randomly discard 1% of packets, with a success rate of 30%.

3 , simulated packet duplication

# TC Qdisc Add dev eth0 root netem duplicate 1%

This command sets the transmission of the eth0 NIC to randomly generate 1% of duplicate packets.

4 , simulated package corruption

# TC Qdisc Add dev eth0 root netem corrupt 0.2%

This command sets the transmission of the eth0 NIC to a randomly generated 0.2% corrupted packet. (kernel version is required at 2.6.16 or more)

5 , simulation package chaos sequence

# TC Qdisc Change dev eth0 root netem delay 10ms reorder 25% 50%

This command sets the transmission of the eth0 NIC to: 25% of the packets (50% related) are sent immediately, and the other is delayed by 10 seconds.

In the new version, the following command will also disrupt the order of the packages to some extent:

# TC Qdisc Add dev eth0 root netem delay 100ms 10ms

Using TC to simulate network delay and packet loss under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.