faking latency on your local network

I recently had call to try and artificially introduce network latency on my machine. During development of a web application of any sort, it’s artificially fast and reliable if it only has to go over localhost or even to another machine on the local network. While I could have easily pushed the service to a remote server, that would obviously have its own problems in terms of quickly progressing development.

The answer is depressingly straight forward. Of course Linux has a set of tools to deal with just this situation. I just had to search for quite a long time until I struck the right search terms, so to help anyone else searching out there I’d like to describe this process as faking latency, or introducing lag.

The application you want is called “tc” and here is the guide I used. but keep in mind that if you’re using Fedora 17+, you need to install “kernel-modules-extra” in order to get started. Here’s the code I ended up using:

Show current configuration

tc qdisc show

Add a delay of 20ms +- 100msecs to lo

tc qdisc add dev lo root netem delay 20ms 100ms

Remove any modifications to lo

tc qdisc del root dev lo

Let me know if you find any novel uses for fake latency!

Posted in Linux
One comment on “faking latency on your local network
  1. Brian says:

    I came here for the font tips, and got this little gem. It will be almost essential to helping me build the upload portion of an application. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">