110
\$\begingroup\$

I am developing an online multiplayer game. It works well when I test it on the local area network, but before I release it I would like to test how the user-experience works out for someone who has not such a good connection to the server. How can I simulate a bad internet connection with high latency, low bandwidth, jitter and occasional packet loss when in a local environment?

\$\endgroup\$
7
  • 74
    \$\begingroup\$ Send it to me for testing! Connections in my country are horrible by default. \$\endgroup\$
    – Stephan B
    Commented Aug 30, 2013 at 10:52
  • 9
    \$\begingroup\$ A commendable goal. I do wish published studios would do the same. Epic Games, I'm looking at you. \$\endgroup\$
    – Gusdor
    Commented Aug 30, 2013 at 12:17
  • 9
    \$\begingroup\$ Find a friend nearby who uses Comcast... \$\endgroup\$
    – WernerCD
    Commented Aug 30, 2013 at 12:55
  • 13
    \$\begingroup\$ Simulating a bad internet connection contains the current answers and more. \$\endgroup\$
    – House
    Commented Aug 30, 2013 at 14:29
  • 2
    \$\begingroup\$ I immediately thought of this other recent SE question: superuser.com/questions/637594/… \$\endgroup\$
    – Patrick M
    Commented Aug 30, 2013 at 14:58

7 Answers 7

64
\$\begingroup\$

I think Dummynet is what you are looking for. Dummynet is a network emulation tool which can simulate bandwidth limitations, delays, packet losses, and many more. You can easily choose which traffic you want to intercept and configure the limitations, e.g. to limit all incoming TCP traffic to 2Mbit/s you do

ipfw add pipe 2 in proto tcp
ipfw pipe 2 config bw 2Mbit/s

You see the traffic selection is done by the known ipfw firewall and the pipes provide the limitation features.

It is available for FreeBSD, Linux and Windows.

\$\endgroup\$
4
  • \$\begingroup\$ does it work with Windows loopback adapter? \$\endgroup\$ Commented Jul 3, 2015 at 10:34
  • \$\begingroup\$ to answer my own question, no, it doesn't work for me on Windows 8.1, even after I disabled signed driver reinforcement \$\endgroup\$ Commented Jul 3, 2015 at 13:10
  • \$\begingroup\$ @AndyT Did you find something that works with loopback? Finding something that does packloss AND works with loopback seem difficult. \$\endgroup\$
    – AaronLS
    Commented Apr 24, 2016 at 3:15
  • \$\begingroup\$ @AaronLS: please see another answer here: gamedev.stackexchange.com/a/100779/4731 \$\endgroup\$ Commented Apr 24, 2016 at 12:04
35
\$\begingroup\$

Network Link Conditioner

If you're on a Mac, you can use Network Link Conditioner.

Network Link Conditioner Preference Pane

You can simulate various cases of bad internet connections, including Edge and 3G.

In addition, you can create your own profiles with your own settings:

Network Link Conditioner Custom Profiles

It is a free download in Xcode (go to Xcode → Open Developer Tool → More Developer Tools… and download the Hardware IO Tools for Xcode).

\$\endgroup\$
2
  • \$\begingroup\$ I like this tools, but I need something that I can use for automated testing. Does anyone know if there is a command line interface for this? \$\endgroup\$
    – Erik B
    Commented Jun 1, 2017 at 9:54
  • \$\begingroup\$ For newer xcode versions: developer.apple.com/download/more/?q=Additional%20Tools \$\endgroup\$
    – Esqarrouth
    Commented Jan 11, 2021 at 17:49
15
\$\begingroup\$

If you are on linux you can use netem to simulate all of the possible problems with network like high latency, low bandwidth, packet losses and many others.

There is an option for windows called NetLimiter but I haven't used it so can't vouch for it.

Just found a Mac App called SlowlyApp.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ -1 As with the other answers. This is just links. Please update the answer to include descriptions of what the applications do and how they do it. \$\endgroup\$
    – House
    Commented Aug 30, 2013 at 14:17
  • 9
    \$\begingroup\$ @Byte56: What these apps do is simulate a slow and/or unreliable network connection, just like the question asks for. I'm pretty sure how they do it is outside the scope of this site. I'd say this is a perfectly good answer to the question as asked; if there's a problem, it's in the question, not in the answers. \$\endgroup\$ Commented Aug 30, 2013 at 16:00
  • 1
    \$\begingroup\$ Technically, the question asks "How can I simulate a bad internet connection". It doesn't ask for applications to do it. But yes, I think this question is outside the scope of this site. \$\endgroup\$
    – House
    Commented Aug 30, 2013 at 22:52
12
\$\begingroup\$

Clumsy, for Windows Vista & 7.

clumsy

\$\endgroup\$
3
  • \$\begingroup\$ works fine for windows 8.1 on loopback \$\endgroup\$ Commented Jul 3, 2015 at 13:09
  • \$\begingroup\$ Don't forget to run as administrator. Or it silently doesn't do anything. Otherwise great tool. \$\endgroup\$ Commented Sep 5, 2017 at 18:50
  • \$\begingroup\$ Clumsy also works great on W10. This is such a good tool. \$\endgroup\$ Commented Oct 20, 2020 at 8:21
8
\$\begingroup\$

How can I simulate a bad internet connection with high latency, low bandwidth, jitter and occasional packet loss when in a local environment?

If you're on Windows, you can try SoftPerfect Connection Emulator. It's basically a driver that injects itself between your application and the network layer (similar to Wireshark/WinPCAP) for the selected NIC and can simulate limited bandwidth, latency, packet loss, and other things. The UI is simple and straightforward.

It's a commercial product, but the trial lets you do 30-second bursts of "interference" that should be good enough for you to judge whether this tool does what you want.

Another cross-platform option is DummyNet, which behaves in a similar manner (via ipfw) but is a bit less easy-to-use.

I would like to test how the user-experience works out for someone who has not such a good connection to the server.

I think this part of the question could be restated as "how do I deal with network latency in my application?" One commonly-used and effective technique is Dead Reckoning. The linked article explains it better than I can, but the basic idea is that your clients kind of "simulate" where each entity should be and what it should be doing by an algorithm. Whenever an entity deviates from this algorithm (i.e. player input, server-side event, etc), it sends out an update to each client.

\$\endgroup\$
5
\$\begingroup\$

I haven't used it in a while, but I've used Charles for testing this. It is an application with various network diagnostics tools, including simulating the problems you mentioned: "a bad internet connection with high latency, low bandwidth, jitter and occasional packet loss"

\$\endgroup\$
4
  • 1
    \$\begingroup\$ From the first glance it looks like Charles is a kind of HTTP proxy, so it can't shape plain TCP or UDP traffic. Am I missing something? \$\endgroup\$
    – vbo
    Commented Oct 20, 2014 at 15:50
  • \$\begingroup\$ and it even got +5, wft? \$\endgroup\$ Commented Dec 29, 2015 at 20:51
  • \$\begingroup\$ er I'm not sure what "shape plain TCP or UDP traffic" means, but I've used this tool for precisely what the OP asked about, simulating a bad internet connection. \$\endgroup\$
    – jhocking
    Commented Dec 30, 2015 at 18:46
  • 1
    \$\begingroup\$ @jhocking He means it only works for HTTP traffic. Many realtime games use TCP or UDP. \$\endgroup\$
    – AaronLS
    Commented Apr 25, 2016 at 17:39
0
\$\begingroup\$

If you're savvy with Fiddler, and you're only interested in HTTP/1 then you can script this.

Fiddler doesn't support HTTP/2, intercepting with it will cause all HTTP traffic to downgrade to HTTP/1.

\$\endgroup\$
4
  • \$\begingroup\$ Interesting. Can you provide more details? Maybe some example script? \$\endgroup\$
    – Philipp
    Commented Oct 8, 2019 at 13:08
  • \$\begingroup\$ @Philipp This answer (stackoverflow.com/a/47401557/442351) gives an example. \$\endgroup\$
    – BanksySan
    Commented Oct 8, 2019 at 13:50
  • \$\begingroup\$ It only supports http? Not even websockets? Then I don't think it has much use in game development. If you worry about latency then you wouldn't be using http in the first place. But thanks for mentioning it anyway. \$\endgroup\$
    – Philipp
    Commented Oct 8, 2019 at 14:59
  • \$\begingroup\$ @Philipp it does support WebSockets, just hot HTTP/2. Though, you should look at HTTP/2, it's nothing like HTTP/1, no more head-of-line blocking, no more multiple handshakes, no more duplicate headers and/or cookies. \$\endgroup\$
    – BanksySan
    Commented Oct 8, 2019 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .