If you work with anything network related, you’ve probably experienced the kind of effort that is involved with testing and verifying your designs and implementations working correctly under the various scenarios that can happen over a network. Issues like random disconnects, reconnects, time-outs, traffic congestion, low latency vs high latency, testing network prediction algorithms, testing custom designed protocols, etc. There are some commercial solutions out there that provide products to assist with this kind of testing, but if you don’t have cash to throw around, there is a very good free alternative called Linux :)
Linux has a command line tool called Traffic Control, or simply “tc”. It is very powerful as it allows you to simulate:
- Variable latency
- Packet loss
- Packet duplication
- Packet corruption
- Packet reordering
- Bandwidth throttling
Any of these properties can be used together or individually against any type of packet coming in or going out of your network. You can construct filters that block all inbound traffic on port 80, or optionally delay all or specific packets outbound from your game server by 50 - 100 ms in your LAN to simulate real gameplay over the Internet. It’s really powerful.
Since it is a command line tool, it takes a bit of time to understand the concept, the grammar, and setting up rules. So I decided to start an open source project that allows you to configure TC via a web site. Configuration is defined in a JSON object, so it’s possible to write your own front-end client or even automated test scripts. Now this isn’t the first of its kind. I did find some other open source solutions out there doing something similar, but I haven’t found one that allows a good level of customizability and with room for growth, so I wrote my own.
If you develop online apps or games and you’re looking for something free to help with your development and testing, check it out. If you use to write stubs to simulate these tests, great, now you can get rid of that crap :) And if you’re an online developer and you don’t test your network code… Extend your arm, then use your other hand to slap your wrist :)
The project is called PHP TC (yep, that’s original folks :). It’s up for grabs on Sourceforge.