Guide: Use Trickle to limit bandwidth usage of applications

Source: Internet
Author: User

Guide: Use Trickle to limit bandwidth usage of applications

Have you ever seen an application in the system monopolize all your network bandwidth? If you have such an experience, you will feel the value of the Trickle bandwidth adjustment application. Whether you are a system administrator or a common Linux user, you must learn how to control the upstream and downstream speeds of applications to ensure that your network bandwidth is not occupied by a program.

Install Trickle on Linux 

What is Trickle?

Trickle is a network bandwidth adjustment tool that allows us to manage the network uplink and downlink speeds of applications, so that one of the applications can avoid occupying all or most of the available bandwidth. In other words, Trickle allows you to control the network traffic rate based on a single application, rather than just targeting a single user-this is a classic bandwidth adjustment in the client network environment.

How does Trickle work?

In addition, trickle can help us to define priorities based on applications. Therefore, when global limits are set for the entire system, applications with high priorities will still get more bandwidth automatically. To achieve this goal, trickle sets traffic limits on the data sending and receiving of sockets on TCP connections. We must note that in addition to affecting the transmission rate, trickle will not change the data in any way at any time in this process.

What does Trickle do?

The only restriction is that trickle does not support applications with static links or binary programs with SUID or SGID bit settings, because it uses dynamic links to load it between the process to be adjusted and its associated network socket. Trickle then acts as a proxy between the two software components.

Because trickle does not require superuser permissions to run, users can set their own traffic limits. Maybe this is not what you want. We will explore how to use global settings to limit the traffic limit of all users in the system. That is to say, each user in the system has a traffic rate to manage, but in any case, it is subject to the overall limit set by the system administrator.

In this article, we will describe how to use trickle to manage the network bandwidth used by applications on linux. To generate the required traffic, ncftpput and ncftpget will be used on the client (CentOS 7 server-dev1: 192.168.0.17) and on the server (Debian Wheezy 7.5-dev2: 192.168.0.15) vsftpd is used for demonstration. The same command can also be used in systems such as RedHat, Fedora, and Ubuntu.

Prerequisites
  1. For RHEL/CentOS 7/6, enable the EPEL repository. These additional software packages for Enterprise Edition Linux are a high-quality, open-source software warehouse maintained by the Fedora Project, and are compatible with their derivatives, such as Enterprise Edition Linux and CentOS. Both trickle and ncftp are available in this repository.

  2. Install ncftp as follows:

    1. # Yum update & sudo yum install ncftp [RedHat-based system]
    2. # Aptitude update & aptitude install ncftp [Debian-based system]
  3. Set up an FTP server on a separate server. It should be noted that, although FTP is inherently insecure, it is still widely used in uploading and downloading files that are irrelevant to security. In this article, we use it to demonstrate the advantages of trickle, and it also shows the transmission rate in the standard output stream of the client. We will discuss whether to use it at other times.

    1. # Yum update & yum install vsftpd [RedHat-based system]
    2. # Aptitude update & aptitude install vsftpd [Debian-based system]

    Edit the/etc/vsftpd. conf file on the FTP server as follows.

    1. anonymous_enable=NO
    2. local_enable=YES
    3. chroot_local_user=YES
    4. allow_writeable_chroot=YES

    After that, make sure that vsftpd is started in your current session and enabled automatically later.

    1. # Systemctl start vsftpd [systemd-based system]
    2. # systemctl enable vsftpd
    3. # Service vsftpd start [init-based system]
    4. # chkconfig vsftpd on
  4. If you choose to build an FTP server in CentOS/RHEL 7 that uses an SSH key for remote access, you need a password-protected user account that can access a directory other than the root directory, it also has the permission to upload and download files.

    You can enter the following URL in your browser to browse your home directory. A logon window prompts you to enter a valid user name and password on the FTP server.

    1. ftp://192.168.0.15

    If the verification succeeds, you will see the contents in your home directory. Later in this tutorial, You can refresh the page to display the files you have uploaded before.

    FTP directory tree

 

How to install trickle in Linux
  1. Install trickle through yum or aptitude.

    To ensure successful installation, it is best to ensure that the current installation package is the latest version before installing the tool.

    1. # Yum-y update & yum install trickle [RedHat-based system]
    2. # Aptitude-y update & aptitude install trickle [Debian-based system]
  2. Check whether trickle is useful for a specific Binary Package.

    We have previously explained that trickle is only useful for Binary packages using dynamic or shared libraries. To confirm whether we can use trickle for a specific application, we can use the famous ldd (list dynamic dependencies) tool. In particular, we will view the dynamic dependency of any given program on its current glibc, because it accurately defines the system calls used for socket communication.

    Run the following command on a given binary package to check whether the bandwidth can be adjusted using trickle:

    1. # ldd $(which [binary]) | grep libc.so

    For example,

    1. # ldd $(which ncftp) | grep libc.so

    The output is:

    1. # libc.so.6 => /lib64/libc.so.6 (0x00007efff2e6c000)

    The characters in the brackets in the output may be different on different system platforms, and even the same command may run differently at different times, because it represents the address where the package is loaded into the physical memory.

    If the preceding command does not return any results, it means that the binary package does not use the libc package, so the trickle cannot adjust the bandwidth.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.