110

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?

yoozer8
  • 1,144
  • 2
  • 15
  • 30
Philipp
  • 119,250
  • 27
  • 256
  • 336

7 Answers7

64

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.

chaos
  • 3,125
  • 1
  • 21
  • 30
Marc Bury
  • 663
  • 4
  • 7
35

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).

grg
  • 458
  • 1
  • 5
  • 11
  • 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? – Erik B Jun 01 '17 at 09:54
  • For newer xcode versions: https://developer.apple.com/download/more/?q=Additional%20Tools – Esqarrouth Jan 11 '21 at 17:49
15

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.

Martin Tale
  • 386
  • 1
  • 9
  • 1
    -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. – House Aug 30 '13 at 14:17
  • 9
    @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. – Ilmari Karonen Aug 30 '13 at 16:00
  • 1
    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. – House Aug 30 '13 at 22:52
12

Clumsy, for Windows Vista & 7.

clumsy

user2818782
  • 221
  • 2
  • 2
8

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.

5

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"

jhocking
  • 15,786
  • 2
  • 43
  • 59
  • 1
    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? – vbo Oct 20 '14 at 15:50
  • and it even got +5, wft? – Marian Paździoch Dec 29 '15 at 20:51
  • 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. – jhocking Dec 30 '15 at 18:46
  • 1
    @jhocking He means it only works for HTTP traffic. Many realtime games use TCP or UDP. – AaronLS Apr 25 '16 at 17:39
0

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.

BanksySan
  • 200
  • 9
  • Interesting. Can you provide more details? Maybe some example script? – Philipp Oct 08 '19 at 13:08
  • @Philipp This answer (https://stackoverflow.com/a/47401557/442351) gives an example. – BanksySan Oct 08 '19 at 13:50
  • 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. – Philipp Oct 08 '19 at 14:59
  • @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. – BanksySan Oct 08 '19 at 18:28