Simulating Slow Internet Connection [closed]
Asked Answered
R

17

215

I know this is kind of an odd question. Since I usually develop applications based on the "assumption" that all users have a slow internet connection. But, does anybody think that there is a way to programmatically simulate a slow internet connection, so I can "see" how an application performs under various "connection speeds"?

I'm not worried about which language is used. And I'm not looking for code samples or anything, just interested in the logic behind it.

Rivkarivkah answered 21/8, 2010 at 3:58 Comment(0)
E
115

If you're running windows, fiddler is a great tool. It has a setting to simulate modem speed, and for someone who wants more control has a plugin to add latency to each request.

I prefer using a tool like this to putting latency code in my application as it is a much more realistic simulation, as well as not making me design or code the actual bits. The best code is code I don't have to write.

ADDED: This article at Pavel Donchev's blog on Software Technologies shows how to create custom simulated speeds: Limiting your Internet connection speed with Fiddler.

Evolutionary answered 21/8, 2010 at 4:5 Comment(8)
Hi I wrote a little guide on simulating a slow internet connection that might come in useful: developertipoftheday.com/2010/12/… - full disclosure - this is my own blog, but just in case it helps as I'm all for spreading the good word of fiddler :-)Pinon
The trouble with this fiddler approach is that the latency simulation is not accurate, it operates at the wrong protocol level so you do not get to properly simulate slow start.Iridaceous
@SamSaffron, Sorry to dig up an old post like this, but, do you know any other tools which help in simulation of slow starts?Bellinger
@AnishRam best bet is to use dummynet/ipfw that ships with bsd and family, freebsd, osx etc barkingiguana.com/2009/12/04/…Iridaceous
@AnishRam Also see netem linuxfoundation.org/collaborate/workgroups/networking/netem can simulate a bunch of conditions using iproute2.Evolutionary
In Fiddler, Rules > Performance> Simulate modem speeds. This "simulates typical 56k modem conditions". If you're an expert, you can also go to Rules > Customize Rules.Ligula
Can we get an updated answer for this? This plugin is discontinued and doesn't seem to work.Irrelievable
seems that it's pay now?Mojave
G
170

Starting with Chrome 38 you can do this without any plugins. Just click inspect element (or F12 hotkey), then click on "toggle device mod"enter image description here and you will see something like this:

enter image description here

Among many other features it allows you to simulate specific internet connection (3G, GPRS)

It seems to only work if you have the devtools side bar open.

P.S.2 now you do not need to toggle anything. Throttling panel is available right from the network panel. enter image description here

Note that while clicking on the No throttling you can create your custom throttling options.

enter image description here

Gatepost answered 11/10, 2014 at 9:44 Comment(4)
Now Chrome Dev Tools throttling limits both download and upload speed. But it only limit it for current page in Chrome, so you can't use it to test your page in other browsers. In order to do that you need to use other tools like Fiddler.Exceed
It is worth mentioning that currently WebSockets are not throttled this way: bugs.chromium.org/p/chromium/issues/detail?id=423246Stroup
Upload throttling hasn't worked in quite a few versions of Chrome including the latest (70.0). There's a bug report on the tracker.Keos
In my experience, the biggest cause of web slowness is cable ISPs' flaky DNS being unable to resolve ad servers or CDNs. Sometimes the entire page remains blank until the attempt to resolve them succeeds or times out. Can Chrome simulate this?Spinster
E
115

If you're running windows, fiddler is a great tool. It has a setting to simulate modem speed, and for someone who wants more control has a plugin to add latency to each request.

I prefer using a tool like this to putting latency code in my application as it is a much more realistic simulation, as well as not making me design or code the actual bits. The best code is code I don't have to write.

ADDED: This article at Pavel Donchev's blog on Software Technologies shows how to create custom simulated speeds: Limiting your Internet connection speed with Fiddler.

Evolutionary answered 21/8, 2010 at 4:5 Comment(8)
Hi I wrote a little guide on simulating a slow internet connection that might come in useful: developertipoftheday.com/2010/12/… - full disclosure - this is my own blog, but just in case it helps as I'm all for spreading the good word of fiddler :-)Pinon
The trouble with this fiddler approach is that the latency simulation is not accurate, it operates at the wrong protocol level so you do not get to properly simulate slow start.Iridaceous
@SamSaffron, Sorry to dig up an old post like this, but, do you know any other tools which help in simulation of slow starts?Bellinger
@AnishRam best bet is to use dummynet/ipfw that ships with bsd and family, freebsd, osx etc barkingiguana.com/2009/12/04/…Iridaceous
@AnishRam Also see netem linuxfoundation.org/collaborate/workgroups/networking/netem can simulate a bunch of conditions using iproute2.Evolutionary
In Fiddler, Rules > Performance> Simulate modem speeds. This "simulates typical 56k modem conditions". If you're an expert, you can also go to Rules > Customize Rules.Ligula
Can we get an updated answer for this? This plugin is discontinued and doesn't seem to work.Irrelievable
seems that it's pay now?Mojave
G
54

Google recommends:

Gershom answered 3/4, 2014 at 17:55 Comment(3)
Network Link Conditioner is maintained by Apple (so it's stable and reliable), BUT it only applies to Xcode's simulator.Grouping
@BenWheeler Tried it recently it is surely been applied system wide, even localhostUlceration
I can confirm that Network Link Conditioner is indeed applied to the entire network stack.Donato
D
19

On Linux machines u can use wondershaper

apt-get install wondershaper

$ sudo wondershaper {interface} {down} {up}

the {down} and {up} are bandwidth in kpbs

So for example if you want to limit the bandwidth of interface eth1 to 256kbps uplink and 128kbps downlink,

$ sudo wondershaper eth1 256 128

To clear the limit,

$ sudo wondershaper clear eth1 
Darn answered 24/5, 2016 at 8:39 Comment(0)
G
13

I was using http://www.netlimiter.com/ and it works very well. Not only limit speed for single processes but also shows actual transfer rates.

Guardhouse answered 26/6, 2011 at 14:44 Comment(1)
Most of the other tools provide bandwidth control via artificial latency which doesn't seem to be case with netlimiter which is a good thing. However, in the end it's a commercial tool(with a trial version) and only available under Windows.Melaniamelanic
T
6

There are TCP proxies out there, like iprelay and Sloppy, that do bandwidth shaping to simulate slow connections. You can also do bandwidth shaping and simulate packet loss using IP filtering tools like ipfw and iptables.

Toni answered 21/8, 2010 at 4:7 Comment(2)
Thank you, I'll have a look into iprelay and Sloppy joe.Rivkarivkah
Thanks, ipfw works great. Here's a quick guide I saw that was helpful: barkingiguana.com/2009/12/04/…Hypothermal
T
4

You can try Dummynet, it can simulates queue and bandwidth limitations, delays, packet losses, and multipath effects

Tombouctou answered 21/8, 2010 at 4:5 Comment(0)
M
4

Use a web debugging proxy with throttling features, like Charles or Fiddler.

You'll find them useful web development in general. The major difference is that Charles is shareware, whereas Fiddler is free.

Mendicant answered 26/6, 2011 at 14:44 Comment(2)
You run it as a proxy. The browser automatically connects to it, and it forwards requests to your web app.Mendicant
For Fiddler, it has both modes to work inside/outside of browser.Spectatress
D
4

Also, for simulating a slow connection on some *nixes, you can try using ipfw. More information is provided by Ben Newman's answer on this Quora question

Disarticulate answered 18/5, 2012 at 18:46 Comment(0)
E
4

You can use NetEm (Network Emulation) as a proxy server to emulate many network characteristics (speed, delay, packet loss, etc.). It controls the networking using iproute2 package and it's enabled in the kernel of most Linux distributions.

It is controlled by the tc command-line application (from the iproute2 package), but there are also some web interface GUIs for NetEm, for example PHPnetemGUI2.

The advantage is that, as I wrote, it can emulate not only different network speeds but also, for example, the packet loss, duplication and/or corruption, random or defined delay, etc., so apart from the slow connections, you can also emulate various poorly performing networks and transmission errors.

For your application it's absolutely transparent, you can configure the operating system to use the NetEm as a proxy server, so all connections from that machine will be routed through it. Or you can configure only a specific application to use that proxy.

I have been using it to test the performance of an Android app on various emulated poor-performance networks.

Equanimity answered 5/1, 2017 at 19:53 Comment(0)
C
2

Use a tool like TCPMon. It can fake a slow connection.

Basically, you request it the exact same thing and it just forwards the exact same request to the real server, and then delays the response with only the set amount of bytes.

Cloudy answered 26/6, 2011 at 14:45 Comment(0)
D
2

For Linux, the following list of papers might be useful:

Personally, whilst Dummynet is good, I find NetEm to be the most versatile for my use-cases; I'm usually interested in the effect of delays, rather than bandwidth (i.e. WiFi connection issues), and it's super-easy to emulate random packet loss/corruption, etc. It's also very accessible, and free (unlike the hardware-based Linktropy).

On a side-note, for Windows, Clumsy is awesome. I would also like to add that (regarding websites) browser throttling is not an accurate method for emulating real-life network issues (I think "TKK" commented on a few of the reasons why above).

Hope this helps someone!

Disburden answered 22/10, 2019 at 22:54 Comment(0)
F
2

One common case of shaping a single TCP connection can actually be assembled from dual pairs of socat and cpipe in UNIX fashion like this:

socat TCP-LISTEN:5555,reuseaddr,reuseport,fork SYSTEM:'cpipe -ngr -b 1 -s 10 | socat - "TCP:localhost:5000" | cpipe -ngr -b 1 -s 300'

This simulates a connection with bandwidth of approximately 300kB/s from your service at :5000 and to at approximately 10kB/s and listens on :5555 for incoming connections. Caveat: Note that this per-connection, so each individual TCP connection gets this amount.

Explanation: The outer (left) socat listens with the given options on :5555 as a forking server. The first cpipe command in the SYSTEM:... option then throttles data that went into socket :5555 (and comes out of the first, outer socat) to at most 10kByte/s. That data is then forwarding using another socat which connects to localhost:5000 (where the service you want to slow down should be listening). Data from localhost:5000 is then put into the right cpipe command, which (with the given values) throttles it to about 300kB/s.

The option -ngr to cpipe is important. It causes cpipe to read non-greedily from its input file-descriptor. Otherwise, you might get stuck with data in the buffers not being forwarded and waiting for a reply.

Using the more common buffer tool instead of cpipe is likely possible as well.

(Credits: This is based on the "double-tee" recipe by Christophe Loor from the socat documentation)

Florrieflorry answered 16/6, 2020 at 15:51 Comment(0)
G
1

Mac OSX since 10.10 has an app called Murus Firewall, which acts as a GUI to pf, the replacement for ipfw.

It works very well for system-wide or domain-specific throttling. I was just able to use it to slide my download speed between 300Kbps and 30Mbps to test how a streaming video player adjusts.

Grouping answered 28/9, 2016 at 22:7 Comment(0)
G
1

Updating this (9 years after it was asked) as the answer I was looking for wasn't mentioned:

Firefox also has presets for throttling connection speeds. Find them in the Network Monitor tab of the developer tools. Default is 'No throttling'.

Slowest is GPRS (Download speed: 50 Kbps, Upload speed: 20 Kbps, Minimum latency (ms): 500), ranging through 'good' and 'regular' 2G, 3G and 4G to DSL and WiFi (Download speed: 30Mbps, Upload speed: 15Mbps, Minimum latency (ms): 2).

More in the Dev Tools docs.

Gunpaper answered 20/8, 2019 at 15:15 Comment(0)
A
0

There is also another tool called WIPFW - http://wipfw.sourceforge.net/

It's a bit old school, but you can use it to simulate a slower connection. It's Windows based, and the tool allows the administrator to monitor how much traffic the router is getting from a certain machine, or how much WWW traffic it is forwarding, for example.

Ambary answered 20/9, 2013 at 11:4 Comment(0)
F
-1

There is a simple and practical way to do it, without any application or code. Just connect to the internet using a mobile hotspot. Keep moving the hotspot (phone) away from the connected device to simulate slower networks. 😉

Featured answered 14/3, 2021 at 19:55 Comment(2)
this method is difficult to measure and not applicable to remote serversMargaret
You should understand the use of the word "simulating" in the question before answering. OP does not want to slow down/or destabilize his connection but to simulate a slow connection.Sharmainesharman

© 2022 - 2024 — McMap. All rights reserved.