Pádraig Brady taught me a great trick in a comment to a previous blog post and it was so neat I feel a need to highlight it further as it also makes it easier for me to find it again later!
To simulate a far away server, add RTT time to the localhost device. For example if we add 100 milliseconds (which then makes 200ms ping time to localhost):
$ tc qdisc add dev lo root handle 1:0 netem delay 100msec
Restore it back to normal again with:
$ tc qdisc del dev lo root
tc qdisc add dev lo root handle 1:0 netem delay 100msec
Restore it back to normal again with:
tc qdisc del dev lo root
In addition, add a random packet loss. 500ms latency with 2.5% packet loss:
tc qdisc add dev lo root handle 1:0 netem delay 250msec loss 2.5%
That´s an interesting approach , but why not host the site on a local server , as in local in the country / town / at least continent ?
I get the benefits of simulating lag, but we should aim to reduce it not accept it :D.
Best of luck !
How do you add latency to localhost on Windows?
Nice post. I created a simple bash script to make this a little more flexible and make it so that I didn’t have to remember the syntax since I’ll probably only need to use this every once in a while.
https://gist.github.com/740829
Thanks again.
Cool trick. Thanks for highlighting it 🙂
@urssur: I assume you didn’t actually read the blog post I made the other day about SFTP transfers over high latency connections? It’s a bless being able to simulate such connections on your own systems instead of having to dig up a system that actually features such a latency! I don’t like high latencies, but when I write network protocols for use in the real world…
@ted: everything in Windows is a pain so I expect this is too…
@Eric: oh, nice indeed. I may very well use exactly that here too. Thanks!
@Ted: Windows adds plenty of latency all on it’s own, dude.
In reply to Ted’s Wndows question.. “Use IIS”.
Instead of making fun of Ted why not simply saying that you do not know… 😉
*nix, open source, windows, Apple, iphone, … ayatollahs are boring…
RE: Windows. Very true. On Vista there are significant differences between ‘localhost’ and ‘127.0.0.1’ This was improved in 7 but the internal resolution of localhost is still not as fast as it was in XP.
Let me also mention that I in fact blogged about Window’s amazingly slow localhost a good while ago…
On Windows (for HTTP/S connections) I use Charles debugger proxy which has a latency setting.
@Josh: that’s indeed one way to accomplish something that in many cases is similar, yes. At least if you’re dealing with something HTTP like.
But a HTTP/HTTPS proxy is actually not what I want for my case. I debugged a SSH/SFTP implementation and the last thing I want then is to have it first go through a proxy.
@Eric: zero value (0) fits better to be used (instead of “off”) as an option to disable.
@Ted: for HTTP requests you also can use Fiddler on Windows.
But if you need to perform more specific tasks (like in Daniel’s case) you can try LANforge ICE Network Emulator (www.candelatech.com). But it’s not free. Probably it provides functionality you need in trial version.
(Or install Linux? 🙂
Very interesting. One thing would be good to know: does it reset on a reboot?