Ubuntu – Configure application priority to access the network

networking

I noticed that when I am running applications such BitTorrent all the other applications have trouble accessing the network.

I am sure it would be possible to limit BitTorrent's network usage but what I really want is to be able to set priorities to applications (or protocols) accessing the network. For example, let's say I put max priority for the browser (or http) and then, no matter how much bandwidth was using at the time, the http packets would always go through.

Is this possible? Is there an application for Ubuntu to do this or a way to configure this on Ubuntu directly?

Best Answer

Wondershaper

If it's not too simple for your use case I suggest you give wondershaper a try.

An easy to use traffic shaping script that provides these improvements: * Low latency for interactive traffic (and pings) at all times * Allow websurfing at reasonable speeds while uploading / downloading * Make sure uploads don't hurt downloads * Make sure downloads don't hurt uploads . It does this by: * Limiting upload speed slightly, to eliminate queues
* Limiting download speed, while allowing bursts, to eliminate queues
* Interactive traffic skips the queue * ACKs and tiny packets skip the queue

It's available as a debian/ubuntu package, just run sudo apt-get install wondershaper to install it. Between wondershaper and using tc directly, trust me, you want wondershaper. At one time I used tc extensively and while quite powerful, it's not a joy to use.

Starting and configuration of Wondershaper

Close all programs and other browser pages. Then check your speed at http://speedtest.net

Syntax: wondershaper [network interface] [down speed kbit/s] [up speed kbit/s]

Example for 8/1M (mbit/s) ADSL connection:

wondershaper eth0 6700 800

If you want to clear wondershaper queues (disabling traffic shaping):

Syntax: wondershaper clear [network interface]

wondershaper clear eth0

Starting wondershaper automatically when OS starts

This can be done by editing the file /etc/network/interfaces

Before:

auto lo
iface lo inet loopback

After:

iface eth0 inet dhcp
   up /sbin/wondershaper eth0 6700 800
   down /sbin/wondershaper clear eth0
auto eth0

Notice this is just an example. Actual settings might differ a bit in your system. For example, in your system the network interface might be eth0 instead of eth2.

To find your network device execute: ifconfig or see connection information of network manager.

Source: http://www.mdash.net/traffic-shaping-using-wondershaper

Related Question