Linux's experience in bandwidth control-Linux Enterprise applications-Linux server application information. The following is a detailed description. In Linux, bandwidth control is implemented through queues. The principles are latency and Token. In addition, cbq queues are widely used. The joke is that this is exactly the most complicated and difficult queue, and the document is hard to understand. Now there is a new htq queue which is relatively easy to configure, but requires manual kernel compilation to support it.
In fact, if cbq has a Chinese document, it may be easier to understand. : O
The basic steps for using cbq are as follows:
1) bind a CBQ queue to network physical devices (such as the ethernet card eth0)
2) create a category on the queue
3) create a filter for each category
The configuration and comments may be clear. Even if the network is connected through adsl dial-up, a single network card is used.
Tc qdisc del dev eth0 root # Delete the previous queue
# Sfq is another queue, which means that the order of data packets passing through the 100:2 and 100:3 sub-classes is random, rather than the default fifo, for example, if you download the file first and then open ie, the ie page will not be displayed after loading.
Tc filter add dev eth0 parent 100:0 protocol ip prio 25 u32 match ip dst 192.168.202.219/32 flowid 100:2
Tc filter add dev eth0 parent 100:0 protocol ip prio 25 u32 match ip dst 192.168.202.245/32 flowid 100:2
Tc filter add dev eth0 parent 100:0 protocol ip prio 25 u32 match ip dst 192.168.202.216/32 flowid 100:2
Tc filter add dev eth0 parent 100:0 protocol ip prio 25 u32 match ip dst 192.168.202.218/32 flowid 100:2
Tc filter add dev eth0 parent 100:0 protocol ip prio 25 u32 match ip dst 192.168.202.0/24 flowid 100:3
# Create a filter based on the category and create a filter based on the destination ip address.
In linux, to control the bandwidth, you can only control the sent packets, but not the received packets. Because the speed at which others send packets to you cannot be controlled by you. Therefore, we need to limit the download speed of adsl, not on the ppp0 interface, but on the eth0 interface, that is, the intranet data sending interface.
Even more confusing is that the rate flag speed is not accurate. When it is set to 10 Kbps or 10 kbit, the download speed is kept at around 10 kb/s. It should be 10 kbit/8/1024 kb/s. So I simply use the bandwidth index to determine the rate.
The important parameter is bounded, indicating to limit this bandwidth. If no, the category occupies all bandwidth when the line is idle.
In addition to bounded, you can also set borrow, Isolated, sharing. Borrow can borrow the bandwidth of another category. Isolated designates a certain part of the bandwidth for the specified category. Even if there is no data transfer for that category, this part of the bandwidth will not be allocated to others. Sharing and Isolated are the opposite.
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.