Use Trickle to limit download/upload bandwidth in Linux

Source: Internet
Author: User
Have you ever encountered a program occupying all your network bandwidth? If you have met, you need to limit the bandwidth of the application. Whether you are a system administrator or a common Linux user, you should learn how to control the upload and download speeds of applications to ensure your network bandwidth... "/> <scripttype =" text/javascript "src =" http: // www. 2CT have you ever encountered a program occupying all your network bandwidth? If you have met, you need to limit the bandwidth of the application. Whether you are a system administrator or a common Linux user, you should learn how to control the upload and download speeds of applications to ensure that your network bandwidth is not consumed by a program.
Trickle What is it?
TrickleIs a bandwidth control supply, used to limit such Firefox, FTP, and SSHAnd the bandwidth of other programs that use network bandwidth. You want your YoutubeDoes the music experience affect ftp downloads? If you don't want to, read this article to learn how to install and use trickle on your machine.
How to install Trickle on Linux
The trickle tool has some dependent packages. you must install the tool before installing and using the trickle tool. Libevent Library", But this library has been installed by default on most current Linux machines.
On Debian/Ubuntu/Linux Mint
In Debian/Ubuntu/MintRun on the machine Apt-get install trickle. Make sure that the source list has been updated, and then install the application you want.
1
2
$ Sudo apt-get update
$ Sudo apt-get install trickle
On RHEL/CentOS/Fedora
First, you need to update the system, and then use the following command to install trickle.
1
2
# Yum update
# Yum install trickle
Trickle How to work?
Trickle controls and limits the number of applications by controlling the number of socket data reads and writes. Upload/downloadSpeed. It uses another version BSDSocket API, but the difference is that trickle also manages socket calls.
Note that trickle uses dynamic links and loads, so it is only useful for programs that use the "Glibc Library. Because trickle can set the transmission delay of data on the socket, it can be used to limit the network bandwidth of an application.
Trickle What can't I do?
Trickle cannot be used to restrict usage. UDPThe bandwidth of the Protocol application, which can only be used TCPConnection, but you need to know that it is not for all TCPThe connection is valid. If you keep reading this article carefully, you can guess why. You still remember that trickle only applies Glibc LibraryIs the application valid?
Also, trickle cannot work on executable programs that use static links.
Determine whether Trickle can run on a specific application
Since trickle cannot restrict Upload/downloadSpeed, there should be a way to find the applications that trickle can work on.
LddTools help us find out if a specific program is used Libc. soLibrary. If the program uses this library, you can use trickle to limit its network bandwidth usage.
LddCommand is used to print the shared library required by each program. If you are curious Linux GeekYou can use the man command to find more information about the ldd tool.
1 # Man ldd
FilezillaIs it a program that transfers files using the ftp protocol. can trickle be used to limit its download or upload speed? During your consideration, I use the following command to find out if trickle can be used in filezilla.
1 # Ldd filezilla | grep libc. so
For me, it outputs the following:
1
2
Oltjano @ oltjano-X55CR:/usr/bin $ ldd filezilla | grep libc. so
Libc. so.6 ==>/lib/i386-linux-gnu/libc. so.6 (0xb6bc4000)
Since filezilla uses" Libc. so"Library, then trickle can be used to limit its network bandwidth. This method can be used in any program you are interested in.
Learn how to use Trickle
Use the following command to output Version.
1
2
Root @ oltjano-X55CR :~ # Trickle-V
Trickle: version 1.07
Linux has many command line tools to make the test (experiment) interesting and beautiful. The following Command uses the wget tool to download the latest Pear OS image.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Root @ oltjano-X55CR :~ # Wget http://sourceforge.net/projects/pearoslinux/files/Pear%20OS%208/pearos8-i386.iso/download
 
-- 11:56:32 -- http://sourceforge.net/projects/pearoslinux/files/Pear%20OS%208/pearos8-i386.iso/download
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net) | 216.34.181.60 |: 80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso? R = & ts = 1384928843 & use_mirror = kaz [following]
-- 11:56:33 -- http://downloads.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso? R = & ts = 1384928843 & use_mirror = kaz
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net) | 216.34.181.59 |: 80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://kaz.dl.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso [following]
-- 11:56:33 -- http://kaz.dl.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso
Resolving kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)... 88.204.157.163
Connecting to kaz.dl.sourceforge.net (kaz.dl.sourceforge.net) | 88.204.157.163 |: 80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093664768 (1.0G) [application/octet-stream]
Saving to: 'download'
 
0% [] 30,78, 278 381KB/s eta 1 h 50 m
The output shows that the download speed is about 381 KB/s. I want to limit the download speed 13 K/sIn this way, I can use my bandwidth to do other things. The following command limits the wget speed 13 K/s.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Radisaive @ ravisaive-OptiPlex-380 :~ $ Trickle-d 13 wget http://sourceforge.net/projects/pearoslinux/files/Pear%20OS%208/pearos8-i386.iso/download
 
-- 12:01:19 -- http://sourceforge.net/projects/pearoslinux/files/Pear%20OS%208/pearos8-i386.iso/download
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net) | 216.34.181.60 |: 80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso? R = & ts = 1384929129 & use_mirror = kaz [following]
-- 12:01:19 -- http://downloads.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso? R = & ts = 1384929129 & use_mirror = kaz
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net) | 216.34.181.59 |: 80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://kaz.dl.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso [following]
-- 12:01:20 -- http://kaz.dl.sourceforge.net/project/pearoslinux/Pear%20OS%208/pearos8-i386.iso
Resolving kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)... 88.204.157.163
Connecting to kaz.dl.sourceforge.net (kaz.dl.sourceforge.net) | 88.204.157.163 |: 80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093664768 (1.0G) [application/octet-stream]
Saving to: 'Download. 1'
 
0% [] 2,01, 550 13.1KB/s eta 21 h 5 m
The output shows that the download speed is limited 13 K/s. Download will continue 21 Hour 5 minutes. The above" -D"Option indicates the download, you can also use the" -D"Option and upload option ( -U), As shown in the following example.
1 # Trickle-u 100-d 50 ftp
Command restrictions Ftp ClientThe upload speed is 100 K/s, The download speed is 50 K/s. You can also use the following command to limit the bandwidth of all commands running in a shell.
1 Trickle-d 130-u 13 bash
Each command line tool provides help to users. use the "trickle-h" command to find out more usage of the trickle tool.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Root @ oltjano-X55CR:/usr/bin # trickle-h
 
Usage: trickle [-hvVs] [-d ] [-U ] [-W ] [-T ]
[-L ] [-N ] Command...
-H Help (this)
-V Increase verbosity level
-V Print trickle version
-S Run trickle in standalone mode independent of trickled
-D Set maximum cumulative download rate KB/s
-U Set maximum cumulative upload rate KB/s
-W Set window length KB
-T Set default smoothing time S
-L Set default smoothing length KB
-N Use trickled socket name
-L Set latency Milliseconds
-P Preload the specified. so instead of the default one
Summary
This article describes how to install the trickle tool on a Linux machine and use it to do simple things. Trickle is a required tool for advanced Linux users, whether you work for a large company or use it yourself.
Via: http://www.tecmint.com/manage-and-limit-downloadupload-bandwidth-with-trickle-in-linux/
Translator: geekpi proofreader: jasminepeng
This article was originally translated by LCTT and launched with the Linux honor in China
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.