Linux: network bandwidth limitations

In this article, I will describe two different ways to restrict network traffic on Linux.

Limit the application traffic on a Linux ( Rate Limit the Application ON AN Linux )

A method of limiting the rate of network traffic is called trickle through a command line tool.

By running, pre-loaded with a rate limiting socket library method , trickle command allows you to change the flow of any one particular program.

trickle command has a nice feature is that it only runs in user space , which means you do not need root privileges to limit the bandwidth usage of a program.

To be able to use the bandwidth trickle program control program, the program must use the sockets interface non-static link library.

When you want the program does not have a built-in bandwidth control function of rate limiting, trickle can be helped.

Installation trickle

Installation trickle in Ubuntu, Debian and its derivatives releases:

$ sudo apt-get install tr​​ickle

In Fdora or CentOS / RHEL (with EPEL depot):

$ sudo yum install tr​​ickle

The basic use of trickle

Just simply trickle command (and rate parameters) in the command you want to run before.

$ trickle -d <download-rate> -u <upload-rate> <command>

This will <command> download and upload of the specified rate limit value (KBytes / s units).

For example, the maximum upload bandwidth provided scp session is 100 KB / s:

$ trickle -u 100 scp backup.tgz alice@remote_host.com:

Should you wish, you can customize a starter by way of creation, use the following command to set the maximum download rate (for example, 300 KB / s) for your Firefox browser.

trickle -d 300 firefox %u

Finally, trickle can also be run in daemon mode, in this mode, it will limit the total bandwidth of all start by trickle and running of the program and. It started as a trickle daemon (for example, trickled):

$ sudo trickled -d 1000

Once trickled daemon running in the background, you will be able to start other programs by trickle command. If you start a program via trickle, then the maximum download speed of this process will be 1000 KB / s, if you then start another program via trickle, then (download) rate limit for each program will be limited to 500 KB / s, and the like.

 

Restrict network interface on Linux

Another control your bandwidth resources is a way to limit the bandwidth on each interface . This is particularly useful when you share your upstream bandwidth network connections with others. Like with the other, Linux has a tool to do it for you. wondershaper is doing that.


wondershaper actually a shell script that uses tc to define the flow adjustment command, use QoS to handle specific network interface. Outgoing traffic on the different priority queues, to achieve the purpose of limiting the rate of outgoing traffic; the incoming traffic by packet loss rate to achieve the purpose of limitation.


In fact, the stated objectives wondershaper's not just an interface to increase its bandwidth limit; when the batch download or upload in progress, wondershaper also tried to keep the interactive session as SSH low latency. Similarly, it will also control the bulk upload (for example, Dropbox synchronization) does not make download "suffocation" and vice versa.

Installation wondershaper

Wondershaper mounted on Ubuntu, Debian its derivatives:

$ sudo apt-get install wondershaper

(With the EPEL depot) mounted in Fdora wondershaper or CentOS / RHEL:

$ sudo yum install wondershaper

The basic usage wondershaper

$ sudo wondershaper <interface> <download-rate> <upload-rate>

$ WonderShaper network interface [Name] [downlink speed (Kb) upstream speed] [(Kb)]

For example, the maximum eth0 download / upload bandwidth are set to 1000Kbit / s and 500Kbit / s:

$ sudo wondershaper eth0 1000 500

You can also rate limit be removed by running the following command:

$ sudo wondershaper clear eth0

If you are interested in works wondershaper, you can read it in a shell script (/ sbin / wondershaper)

 

Translation link: http://xmodulo.com/limit-network-bandwidth-linux.html

Guess you like

Origin blog.csdn.net/fly910905/article/details/91356407