vipe 发表于 2006-12-9 00:11:49

ROS这篇分层桶 探讨"原理"而已

Introduction to HTB
HTB (Hierarchical Token Bucket) is a classful queuing discipline that is useful for applying
different handling for different kinds of traffic. Generally, we can set only one queue for an
interface, but in RouterOS queues are attached to the main Hierarchical Token Bucket (HTB) and
thus have some properties derived from that parent queue. For example, we can set a maximum data
rate for a workgroup and then distribute that amount of traffic between the members of that
workgroup.
HTB qdisc in detail:

[ 本帖最后由 vipe 于 2006-12-9 00:19 编辑 ]

vipe 发表于 2006-12-9 00:12:59

HTB terms:
• queuing discipline (qdisc) - an algorithm that holds and maintains a queue of packets. It
specifies the order of the outgoing packets (it means that queuing discipline can reorder
packets). Qdisc also decides which packets to drop if there is no space for them
• filter - a procedure that classifies packets. The filter is responsible for classifying packets so
that they are put in the corresponding qdiscs
• level - position of a class in the hierarchy
• inner class - a class that has one or more child-classes attached to it. Inner classes do not store
any packets, but they do traffic shaping. The class also does not have its own priority
• leaf class - a class that has a parent but does not have any child-classes. Leaf classes are always
located at level 0 of the hierarchy. Each leaf class has a qdisc, attached to it
• self feed - an object that represents the exit for the packets from all the classes active at its level
of the hierarchy. It consists of 8 self slots
• self slot - an element of a self feed that corresponds to each particular priority. All classes,
active at the same level, of one priority are attached to one self slot that they are using to send
packets out through
• active class (at a particular level) - a class that is attached to a self slot at the given level
• inner feed - similar to self feed object, which consists of inner self slots, present on each inner
class
• inner feed slot - similar to self slot. Each inner feed consists of inner slots which represent a
priority
Each class has a parent and may have one or more children. Classes that do not have children, are
put at level 0, where queues are maintained, and are called 'leaf classes'
Each class in the hierarchy can prioritize and shape traffic. There are 2 main parameters in
RouterOS which refer to shaping and one - to prioritizing:

vipe 发表于 2006-12-9 00:14:23

• limit-at - data rate that is guaranteed to a class (CIR)
• max-limit - maximal data rate that is allowed for a class to reach (MIR)
• priority - order in which classes are served at the same level (8 is the lowest priority, 1 is the
highest)
Each HTB class can be in one of 3 states, depending on data rate that it consumes:
• green - a class the actual rate of which is equal or less than limit-at. At this state, the class is
attached to self slot at the corresponding priority at its level, and is allowed to satisfy its limit-at
limitation regardless of what limitations its parents have. For example, if we have a leaf class
with limit-at=512000 and its parent has max-limit=limit-at=128000, the class will get its
512kbps!
• yellow - a class the actual rate of which is greater than limit-at and equal or less than max-limit.
At this state, the class is attached to the inner slot of the corresponding priority of its parent's
inner feed, which, in turn, may be attached to either its parent's inner slot of the same priority
(in case the parent is also yellow), or to its own level self slot of the same priority (in case the
parent is green). Upon the transition to this state, the class 'disconnects' from self feed of its
level, and 'connects' to its parent's inner feed
• red - a class the actual rate of which exceeds max-limit. This class cannot borrow rate from its
parent class
Priorities
When a leaf class wants to send some traffic (as they are the only classes that hold packets), HTB
checks its priority. It will begin with the highest priority and the lowest level and proceed until the
lowest priority at highest level is reached:
As you can see from the picture, leaf-classes which are at the green state, will always have a higher
priority than those which are borrowing because their priority is at a lower level (level0). In this
picture, Leaf1 will be served only after Leaf2, although it has a higher priority (7) than Leaf1 (8).
In case of equal priorities and equal states, HTB serves these classes, using round robin algorithm.
HTB Examples
Page 419 of 695
Copyright 1999-2005, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

[ 本帖最后由 vipe 于 2006-12-9 00:16 编辑 ]

vipe 发表于 2006-12-9 00:16:59

As you can see from the picture, leaf-classes which are at the green state, will always have a higher
priority than those which are borrowing because their priority is at a lower level (level0). In this
picture, Leaf1 will be served only after Leaf2, although it has a higher priority (7) than Leaf1 (8).
In case of equal priorities and equal states, HTB serves these classes, using round robin algorithm.

[ 本帖最后由 vipe 于 2006-12-9 00:23 编辑 ]

legou 发表于 2006-12-9 14:29:03

vipe 发表于 2006-12-9 17:33:04

回复 #5 legou 的帖子

legou 厉害,每次都被你看穿
打心底佩服你
页: [1]
查看完整版本: ROS这篇分层桶 探讨"原理"而已