Vro configuration in Linux

Source: Internet
Author: User
Article title: vro configuration in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Policy Control on vro: IP bandwidth management (QoS)
  
Why manage bandwidth?
  
The success of the Internet is mainly caused by the simplicity and stability of the IP Protocol family. Almost all people are now moving towards IP addresses, and even traditional telecommunications companies are switching their circuit-based voice networks to IP networks. However, the Internet based on the IP protocol has encountered a great difficulty. It is not an ATM protocol. it treats any business equally, that is to say, all data transmitted over an IP network is equally transmitted as much as possible (called a best-effort service ). If I want to pay twice more, I cannot double the download speed on my homepage. This introduces the concept of QoS, that is, service quality assurance. In this case, the way to treat all IP service data equally will be abandoned, while trying to distinguish different users or services and then allocate different bandwidth. This is the allocation and management of the bandwidth on the vro.
  
Over the years, different technologies have developed rapidly. Internet Engineering Task Force has released several standards, including integrated services, differentiated services, and resource reservation technologies. These standards are implemented in Linux. However, their use is a comprehensive problem and requires the cooperation of other vrouters on the network (such as resource reservation). Therefore, it is not widely used in practice. However, as Internet services keep increasing, they will be gradually used by more and more people.
  
In Linux kernel 2.1.x and later versions, the traffic control code is introduced to implement IP bandwidth allocation and management.
  
TC features
  
TC is short for Traffic Control, which means "Traffic Control" in Chinese ". TC has great scalability. As an ISP that provides VM services, it can use Linux traffic control to ensure the service quality that different customers do not provide. Traditional ISPs that sell virtual hosts or provide homepage storage services usually provide different disk space for different levels of services. for example, 100 RMB a month can earn MB of space. If we use Linux's traffic control (TC), we can provide a differentiated service. for example, if you are an ISP that provides the VM service, you can have the following service options:
· Service Level 1: $100/month ?? The page browsing speed is kbps.
· Service Level 2: It costs $150/month-250 Kbps, but if the bandwidth is allowed, it can reach 1 Mbps between midnight and am.
· Service Level 3: It costs $200/month-250 Kbps, but the maximum bandwidth can reach 1 Mbps if permitted (no time limit is exceeded from Service Level 2 ).
· Service Level 4: cost $500/month-1 Mbps high-speed bandwidth assurance. Suitable for video and audio stream services.
In the above example, we can use TC to easily specify various controllable service rules. As mentioned above, different services are provided in different time periods every day. we can easily use crontab to regularly run some scripts to change the bandwidth allocation rules. This is a good example. we will introduce an instance later.
  
TC usage example
  
Below is an example of using TC to implement different bandwidth policies for two virtual hosts on a Linux server. In this example, we will describe how to configure and test TC.
  
Compile the kernel
As for how to compile a new kernel is no longer within the scope of this chapter, we assume that you already know how to re-compile a kernel.
When compiling the kernel, select the following kernel options: "kernel/User netlink socket" and "Netlink device emulation ". In this way, TC can use netlink to transmit information with the kernel. Select all queuing algorithms, including
"Fair queueing"
"CBQ packet scheduler"
"CSZ packet scheduler"
"The simples PRIO pseudo doscheduler"
"RED queue"
"SFQ queue"
"TBF queue"
"QoS support"
"Rate estimator"
"Packet classifier API"
"Routing-tables-based classifier"
"U32 classifier"
"Special RSVP classifier and special RSVP classifier for IPv6 ".
  
After these options are selected, follow the normal kernel compiling steps to compile the kernel, then install the new kernel, and then restart the system with the new kernel.
  
Compile the TC software package
  
You can download the required software at the following address and compile it according to the instructions in the software package:
Ftp://linux.wauug.org/pub/net/ip-routing/iproute2-current.tar.gz
Generally, all we need to do is simply input make.
  
TC settings
  
  
  
. CBQ tree chart
Is a simple tree chart demonstration of the system we will configure. The two leaf nodes allocate bandwidth from the parent node. the IP address 10.0.0.10 (identifier 1:1) and the IP address 10.0.0.11 (identifier) are the IP aliases on the eth0 interface. they share the parent node (identifier 1:0) bandwidth. This example only involves traffic control over one interface. you can follow this example to construct configurations that control multiple interface devices that you are interested in.
The first step to configure QoS is to add qdisc to an interface. for example, in this example:
Qdisc add dev eth0 root handle 1 :...
  
Then define the categories you want to differentiate. Different types correspond to different traffic control types. In our example, use the following statement:
  
Tc class add dev eth0 parent 1:0 classid X: Y...
  
In our example, only a deep category tree is used. Of course, we can construct a complex tree with multiple layers of depth. The basic principle is the same: a subnode (1) inherit the resources of a parent node and further allocate the resources of the parent node according to the class definition. For example, if the parent class has full bandwidth of the device from, the bandwidth of the sub-node cannot exceed 10 Mbits. In this example, the bandwidth is limited to 1 Mbps.
Finally, the ing rule "IP Group-category" is defined to tell the system classifier of the corresponding type of an IP group scheduled by the router. First, associate a classifier with the output interface:
Filter add dev eth0 parent 1:0 protocol ip...
  
Then, define the ing rule for "IP Group-Category. In this example, the source address of the IP Group is used as the keyword for classification. The following script completes this function. For the parameters of commands such as TC in the script, you can refer to the random document, which is limited by space.
  
#! /Bin/sh
# Path to tc and the ip utilities;
# Change to reflect yours.
TC =./iproute2/tc
IP =./iproute2/ip
######################################## ##########
# Addresses to be aliased
# Change or add more to reflect yours
#
ALIAS1 = 10.0.0.10
ALIAS2 = 10.0.0.11
######################################## ##########
# Add ip aliasing support
# Uncomment if you want to use the ip utility
# Add ip-aliasing for you
#
# $ IP addr add $ ALIAS1 dev eth0
# $ IP addr add $ ALIAS2 dev eth0
######################################## ##########
# Attaching a device queue discipline to
# Interface a device queue discipline is
# Equivalent almost to a device manager
#
# Attach CBQ to eth0
# Things you might need to change:
# Bandwidth -- the bandwidth of the eth0 device
# Note it must match the device's real bandwidth
# Allot -- it is safe to leave it at the MTU
# The device
# Avpkt -- the average packet size that you
# Suspect will be seen safe to leave at 1000
# For Ethernet with MTU of 1514 bytes
# Mpu -- minimum packet size
#
$ TC qdisc add dev eth0 root handle 1: cbq
Bandwidth 10 Mbit allot 1514 cell 8 avpkt 1000
Mpu 64
######################################## ##########
# Attaching class queue disciplines
# Bounded -- it is bound to the rate allocated;
# Can't borrow even if there is a lot of idle
# Bandwidth just sitting there isolated -- cannot
# Share its bandwidth to other classes prio is
# Priority assigned 0 being the highest and 7
# Lowest weight -- safer to leave at 1
# Queue discipline setup. Classid 1:1 will have
# Rate of 1 Mbps which is bounded.
#
$ TC class add dev eth0 parent 1:0 classid 1:1 cbq
Bandwidth 10 Mbit rate 1 Mbit avpkt 1000 prio 5
Bounded isolated allot 1514 weight 1 maxburst 21
# Rate 1 Mbit avpkt 1000 prio 5 bounded allot 1514
# Weight 1 maxburst 21
# Classid will have a rate of 3 Mbps which is
# Bounded.
$ TC class add dev eth0 parent 1:0 classid 1:2 cbq
Bandwidth 10 Mbit rate 3 Mbit avpkt 1000 prio 5
Bounded allot 1514 weight 1 maxburst 21
######################################## ##########
# Define the filter to be attached to eth0
# Create with hash table of 256 slots with ID 1:
#
$ TC filter add dev eth0 parent 1:0 protocol ip
Prio 5 handle 1: u32 divisor 256
######################################## ##########
# Define the criteria for mapping incoming packets
# To classes. Add to the 5th slot of hash table
# Rule to select virtual address ALIAS1 direct it
# To class 1:1
#
$ TC filter add dev eth0 parent 1:0 prio 5 u32
Ht 1: 6: match ip src $ ALIAS1 flowid 1:1
# Add to 6th slot of hash table rule to select
# ALIAS2 direct it to class
$ TC filter add dev eth0 parent 1:0 prio 5 u32
Ht 1: 6: match ip src $ ALIAS2 flowid
Related Article

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.