Monday, August 28, 2023

simulate loss and latency on networks,

there is was package called dummy net that would simulate loss and latency on networks, what is there like this for linux today? 

Dummynet was originally developed for FreeBSD to simulate various network properties like bandwidth limitations, latency, and packet loss. For Linux, there are a few tools that can be used to achieve similar network simulations. The most notable one is tc (Traffic Control), which is part of the iproute2 package.

Here's a brief overview of how you can use tc to simulate network conditions:

  1. Latency: To introduce a delay of 100ms on all outgoing packets on the interface eth0:

    bash
    tc qdisc add dev eth0 root netem delay 100ms
  2. Packet Loss: To simulate a 10% packet loss on the interface eth0:

    bash
    tc qdisc add dev eth0 root netem loss 10%
  3. Combine Latency and Packet Loss: To introduce both a delay of 100ms and a 10% packet loss:

    bash
    tc qdisc add dev eth0 root netem delay 100ms loss 10%
  4. Bandwidth Limitation: To limit bandwidth to, say, 1mbit:

    bash
    tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
  5. Removing the rules: To remove the rules and return to normal:

    bash
    tc qdisc del dev eth0 root

Additionally, there are other tools and utilities, such as:

  • Comcast: It's a tool that allows you to simulate bad network connections, so you can test your applications under various conditions.

  • NetEm: It is actually an underlying tool (used in conjunction with tc) that allows you to introduce various network impairments like delay, loss, duplication, and reordering.

Always remember, if you're going to apply any of these changes to a live system, especially one serving real users or critical functions, take care to ensure you understand the implications and have a rollback plan. Also, testing in a controlled environment first is always a good idea.




https://wiki.linuxfoundation.org/networking/iproute2

https://github.com/shemminger/iproute2




Comcast

Testing distributed systems under hard failures like network partitions and instance termination is critical, but it's also important we test them under less catastrophic conditions because this is what they most often experience. Comcast is a tool designed to simulate common network problems like latency, bandwidth restrictions, and dropped/reordered/corrupted packets.

No comments: