Install using trickle in Linux systems to control user bandwidth

Source: Internet
Author: User
Tags socket linux mint
1. Trickle Introduction

Trickle is a lightweight user space bandwidth control tool used to limit network bandwidth such as browser Firefox, FTP, SSH,CURL,WGET,SCP, and so on.
Trickle controls and restricts the upload and download speed of applications by controlling the read and write of socket data. Note that Trickle uses dynamic linking and loading, so it is useful only for programs that use the Libc.so library, but not for others. Because trickle can set data transfer latency on the socket, it can be used to limit the network bandwidth of the application.
Trickle cannot be used to limit the bandwidth of applications that use the UDP protocol, only for TCP connections. Also fails to work on an executable program that uses static links.
2. How to determine trickle is valid for an application
Based on whether to use the Libc.so library to judge.
You can use the LDD command to see if an application is using a libc.so library. If your application uses this library, you can use trickle to limit network bandwidth, otherwise it will not work.

The code is as follows:
# Ldd/usr/bin/wget | grep libc.so
Libc.so.6 =>/lib64/libc.so.6 (0x00002adc30397000)
3. How to install Trickle on Linux
The Trickle tool has a number of dependencies that must be installed before installing and using trickle, but this library is installed by default on most current Linux machines.
On the Debian/ubuntu/linux Mint.
Run the Apt-get install trickle on the Debian/ubuntu/mint machine for installation. Make sure the source list is updated, and then install the application you want.
The code is as follows:
$ sudo apt-get update
$ sudo apt-get install trickle
On the Rhel/centos/fedora.
First you need to update the system and then use the following command to install trickle.
The code is as follows:
# Yum Update
# Yum Install trickle
How does trickle work?
Trickle controls and restricts the upload/download speed of the application by controlling the read and write of the socket data. It uses another version of the BSD socket API, but the difference is that trickle also manages socket calls.
Note that Trickle uses dynamic linking and loading, so it is only useful for programs that use the GLIBC library. Because trickle can set data transfer latency on the socket, it can be used to limit the network bandwidth of an application.
What Trickle can't do?
Trickle cannot be used to limit the bandwidth of applications that use the UDP protocol, it can only be used for TCP connections, but you should know that it is not valid for all TCP connections. If you have been reading this article carefully, you can guess what the reason is.

Also, trickle cannot work on an executable program that uses static links.

4. Use of trickle

The code is as follows:
# trickle--help
Usage:trickle [-HVVS] [D-<rate>] [-U <rate>] [-w <length>] [-t <seconds>]
[-l <LENGTH>] [-n <path>] command ...
-H Help (this)
-V Increase verbosity level
-V Print Trickle version
-S runs independently in standalone mode
-D <rate> Set maximum cumulative download rate of <rate> kb/s
-U <rate> set maximum cumulative upload speed of <rate> kb/s
-W <length> Set window length to <length> KB. Default 512KB.
-T <seconds> set default smoothing time <seconds> S. The smoothing time determines how many time intervals trickle will attempt to transfer data to the application. A smaller value (0.1-1 seconds) results in a more continuous (smooth) session, which is ideal for interactive applications. A larger value (1-10 seconds) can generate bursts of sending and receiving data, which is better for applications that require a lot of bandwidth.
-L <length> Set default smoothing length <length> KB. The default is ten KB.
-N <path> Specify trickled socket name <path>. Default/tmp/.trickled.sock.
-L <ms> Set delay.
5. For example
Limit wget download speed to 50kb/s

6. Limit all command bandwidth for a shell

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.