Linux – higher traffic priority for FPS game in Linux

iptableslinuxtctraffic-shaping

Goal: when running a FPS game in Linux, automate the setup of higher priority for its network traffic

I know such tasks are usually accomplished with a combination of iptables (to mark IP packets meeting certain criteria) and tc (to prioritize those IP packets).

Problems:

  • earlier version of iptables had an –pid-owner option with a warning in the manpage that this is broken on SMP kernels. My recent version of iptables (1.4.7) doesn't mention this option in the manpage at all
  • probably I can't use a single destination port to match traffic, because game servers run on different ports

I aim for a wrapper shell script which will:

  • run the game executable
  • find its name/pid
  • based on this will increase the priority of network traffic for this process
  • when I exit the game, will restore everything to defaults

Is this possible? I'm willing to go as far as dealing with custom netfilter modules, if there are any which could help.

Best Answer

I don't think you want to mess with QoS on the client; on your router maybe, but on the client machine, you're just introducing extra packet processing which is actually going to slow things down. On the router you're prioritizing those packets above other packets (like other http connections or other traffic also going through the router), so it's a win, but on the client you're doing extra filtering instead of just handing the packets straight through to the process.

You might want to use nice to adjust your client process priority though, so it will get faster access to the CPU than background things running on the same machine.

You might want to tune up your network receive/send buffer size to help minimize retransmits.

If you're trying to control actual bandwidth being generated by your computer, then you'll need more data on what exactly the FPS traffic is and how close it is to the 'other' traffic that you want to de-prioritize. You may be able to get away with something as simple as 'prioritize UDP over TCP' if your FPS uses UDP and your other traffic is all TCP. Or it may be more complex. Once you know how to characterize each set of traffic though, then you'll want to look at other answers for details.

Related Topic