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!