Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

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

share|improve this answer
    
Wow, that's an excellent resource. I thinking setting NOPRIOPORTSRC to his bittorrent port would do exactly what he needs. –  Karl Bielefeldt Oct 8 '10 at 18:51

This is a well-known problem, and as far as I know there is no easy answer.

The general problem is called QoS, short for Quality of Service. At the level of the networking infrastructure, what you can do is traffic shaping.

There is a fundamental limitation of traffic shaping for your use case (which is a very common one): you need to act at the point of entry to the bottleneck, not at the point of exit. But typically the bottleneck is the connection between your home/workplace to your ISP's infrastructure, and you can't control what happens at your ISP's, so you can only shape upload, not download. This means you can effectively prioritize web browsing over bittorrent, but not (say) streaming content over background downloads.

If you have a home router and it supports QoS/shaping/whatever-it-calls-it, its interface is likely to be easier to use than what Ubuntu can offer. So look there first. But this is an advanced feature not found in all routers.

Most bittorrent clients should be able to limit bandwidth usage. If you have less upload than download bandwidth (which is typical for home users over DSL), setting the limit to 70%–80% of your bandwidth should leave room for comfortable web browsing.

share|improve this answer

For a more complicated requirements, where wondershaper is not enough you can use Master Shaper. I've not used it myself, but the screenshot below should give you an idea:

Master Shaper

share|improve this answer

This is called bandwidth management, which on Ubuntu is done through the tc command. More info here, but it is not for the faint of heart.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.