From: http://yfydz.cublog.cn
0. Summary
QoS is currently a hot topic in network technology. This article will discuss some underlying technologies for QoS implementation.
1. Overview
QoS (Quality of Service) is used to describe the service quality and data priority of the network. In the early days of Internet connection
All types of data are equal, and network bandwidth is a first-come-first-served free way to seize resources. As data types on the Internet increase
First-level requirements are also raised. For example, the real-time performance of audio data is higher than that of video data, and paying users want to send their own data.
Priority is higher than that of free users. These requirements promote further research and development of QoS.
2. ToS (RFC 1349)
To implement QoS, data must be classified first, and the classification mark must be in the IP header field to facilitate identification by routing devices. For
For an IPv4 packet, there is a field used to describe the data packet service type, that is, the TOS (type of service) field, eight bits, in
In rfc791, there is almost no clear Function Description for this field. It may be too advanced. At that time, I could not think of scanning. True
The description of the TOS field is rfc1349.
The TOS value is not arbitrary. It is defined in rfc1349 as follows:
76543210
00010000 -- minimize delay 0x10
00001000 -- Maximize throughput 0x08
00000100 -- maximize reliability 0x04
00000010 -- minimize monetary cost 0x02
00000000 -- normal service 0x00
Minimize delay: Minimum latency, such as telnet and FTP
Maximize throughput: maximum throughput, such as FTP data channels
Maximize reliability: maximum reliability, such as SNMP
Minimize monetary cost: Minimum fee, such as NNTP
The above four digits can only have one digit as 1, and the last digit must be 0. The first three bits are used to indicate the data priority, but in general network implementation
The value is usually 0. In netscreen firewall, the first three digits of TOS are used as the data priority representation, so 0 can be set.
~ 7. There are 8 priorities in total.
The TOS function defined in rfc1349 is relatively weak, but many routing protocols such as OSPF can make routing decisions based on TOS.
In IPv6 (rfc2460), there is also an 8-bit field traffic class, which is used to distinguish the data priority, but the function definition does not comply
Rfc1349.
2. DiffServ (rfc2474, 2475)
In rfc2474, the TOS field of IPv4 is redefined and renamed to the DS field. The size is still 8 bits, and the definition in tfc1349 is abolished.
Definition in rfc2474:
0 1 2 3 4 5 6 7
+ --- +
| Dscp | Cu |
+ --- +
Dscp: Differentiated Services codepoint
Cu: currently unused
The value is valid for only 6 Characters lower than 63 characters.
This definition supports both IPv4 (TOS field) and IPv6 (Traffic class field ).
In rfc2475, the architecture of the differential service is described in detail.
3. QoS
With the data level, the rest is how the routing device forwards data packets based on the data level. The algorithms are simple and complex.
The most widely used is the queuing theory. After a university student went abroad to study for a doctor, his questions were related to QoS.
I haven't seen it yet, but I can't understand it even if I am too deep in mathematics.
In the Linux kernel, multiple QoS allocation algorithms are available. Under the net/sched directory, the algorithms include CBQ, htb, CSZ, ATM, and red.
, SFQ, teql, TBF, gred, etc. In user space, you can use iproute2 for control. For details, see advance routing.
Howto.
In netfilter, the TOS target is also used for the modification of TOS fields. You can use iproute2 to implement hierarchical data control.
4. Summary
The real difficulty of QoS lies in the distribution of data. However, it is quite good to use the existing open source in Linux.
The router with QoS function.