in TF2 is the bane of my existence. Four people sharing an internet connection can be pretty annoying. My router has no traffic shaping or QoS options, so one person visiting a website can cause latency spikes, and it just goes downhill if they upload a photograph or visit youtube.

I would like a router with QoS (ideally the Tomato firmware) but I can’t justify the expense right now (maybe when I start work), especially as I currently have a modem-router so I might also need to buy a modem as well as the router. Failing that, using a machine as a gateway would give me this kind of control, but I don’t have one. Instead I hacked together a software solution which is as effective as it is ugly.

The general approach is my computer runs a script which checks for any game instances and if it finds any, it sends a message out on the network saying “everyone limit your rates please”. Therefore each computer needs to implement a listening server which somehow toggles the rate limiting when it’s told to. The server is very easy, you can hack this together in Python in about ten minutes. The rate limiting is more difficult.

There are two computers running Windows XP I need to worry about and one running Linux. The Linux one is easy, although I haven’t implemented it yet. I can use iptables to reroute packets through a local rate limiting proxy (Squid) and I can toggle the rule on and off as need be. Write daemon in Python, stick script in /etc/init.d/, enable it with rcconf or whatever. Simples. Linux is truly the operating system of the gods. [edit: actually I used a program called Wondershaper to limit the interface’s rate, not Squid/iptables.]

The Windows situation is much harder. Using a local Squid proxy for the browser works, and Squid can be reconfigured without restarting, but Flash ignores the proxy settings so any Youtube/BBC videos are going to get straight past it and my TF2 is going to say WELCOME TO TWO SECONDS AGO. Maybe there are ways to manipulate the Windows firewall to reroute the packets like in Linux but Windows just seems to fight against you every step of the way. Windows is not the operating system of the gods. Preschool age children maybe, gods no.

In the end I found a program called NetLimiter 2 which provides what it claims is an API, and if you squint hard enough it’s possible to sympathise with this assertion, even if one must stop short of actually agreeing with it. In true Windows fashion, this is the only limiting program I could find at all which supports any kind of programmatic control. It simply baffles me with Windows how so many developers spend so long creating complex programs that do all manner of crazily complicated things deep inside Windows, but they never bother to implement the means to automate them. To me, that makes the program next to useless. Anyway, the code on that linked API page is some kind of JavaScript dialect (JScript) built in to Windows which you can interpret/execute with ‘wscript.exe’. If you leave the first argument as the empty string it applies it to the whole computer, not just a specific program.

It’s not an ideal solution because NetLimiter is fairly ugly; the API looks flaky and amateurish, and it only works on version 2 while the most recent release is 3. And version 2 won’t work on Windows 7.

I also had to use a third party program (hstart.exe) to get the Python server to start quietly at login, otherwise Windows kept insisting on attaching a cmd.exe window to it, even if I used ‘start /B’. Writing it as a proper Windows service would have been better, but more complicated.

On the other hand, it’s better to have an ugly solution that works than a clean solution that doesn’t. Right?



I like blogging

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: