23
htb Jeromy Fu

Htb

Embed Size (px)

DESCRIPTION

Give a brief introduction on the internals on htb. How link sharing works etc

Citation preview

Page 1: Htb

htb

Jeromy Fu

Page 2: Htb

Agenda

• Parameters• Tc example• Link sharing• Implementation• Case study

Page 3: Htb

Tc Parameters

Page 4: Htb

Internal Parameters

Page 5: Htb

example1

Page 6: Htb

example1

Page 7: Htb

example1

Page 8: Htb

example2

Page 9: Htb

example2

Page 10: Htb

example2

Page 11: Htb

Basic concepts

• Classful qdisc• Assured rate(AR)• Ceil rate(CR)• Actual rate(R)• Priority• Quantum, DRR

Page 12: Htb

Basic concepts

• Class mode

HTB_CANT_SEND: red, R>CR

HTB_MAY_BORROW: yellow, AR<R<=CR

HTB_CAN_SEND: green, R<=AR

Page 13: Htb

Link sharing• Rc = min(CRc, ARc+Bc)

- Rc, actual Rate of class c

- CRc, Ceil Rate of class c

- ARc, Assured Rate of class c

- Bc, Borrowed from parent class c

• D(p) – set of nodes

- all nodes are children of p

- all nodes are yellow, which need to borrow bandwidth from parent p

Page 14: Htb

Link sharing• If there are other nodes have higher priority than node c, then those ones will be

scheduled first, thus Bc = 0.

• Otherwise, the bandwidth of parent is divided according to the quantum of the nodes, which have the same priority with node c.

- Q, quantum

- P, Priority, smaller the higher

- Rp, actual rate of parent p

if min[Pi over D(p)] >= Pc: Bc = Qc * Rp/sum[Qi over D(p) where Pi=Pc]else: Bc = 0

Page 15: Htb

Principles

• Red nodes(HTB_CANT_SEND) have to wait• Yellow nodes(HTB_MAY_BORROW) will try

borrow from parent• Green nodes(HTB_CAN_SEND) will always

served first for it doesn’t borrow• Higher priority nodes are served first

Page 16: Htb

implementation• Self feed

each level has one self feed, and every priority has a self slot in self feed(each slot has the same priority and level).

All classes in the same slot has the same priority and level, and are all green nodes (HTB_CAN_SEND) of this level.

• Inner feed

every inner class(node) has one inner feed

All classes in the same slot has the same priority and level, and are all yellow nodes (HTB_MAY_BORROW) that are children of current inner node.

• Wait list

each level has one wait list, which stores the nodes that are yellow (HTB_MAY_BORROW) and red (HTB_CANT_SENT)

Page 17: Htb

implementation

• A htb tree with 3 levels

- red slot (high priority)

- blue slot (lower priority)

- white slot (wait list)

Page 18: Htb

implementation

• Start at the lowest level, choose one green node in the highest priority self slot of this self feed.

• If it’s leaf, then schedule it.• If it’s inner node, then check its inner feed,

and choose the highest priority inner slot, find a yellow node, then schedule it.

Page 19: Htb

Case study

• All nodes are initially green• Pkt arrived for C and D (thick circle)• C is lower priority (in blue self slot)• D is higher priority (in red self slot)• D is scheduled and token is

used

Page 20: Htb

Case study

• D exceed AR, but not CR• D changed to yellow• D is removed from self slot(red) of level 0• D is then put to inner slot(red) of B• D will change back to green in

the future, so it also put intowait list of level 0

• C is scheduled ( D is higher priority but C doesn’t need borrow)

Page 21: Htb

Case study• C exceed CR• C changed to red• C is removed from self slot(blue) of level 0• C can’t borrow so it won’t be put to the parent inner slot• C will change back to green in

the future, so it also put intowait list of level 0

• D is scheduled, and borrowed from B, and B changed to yellow

• B is removed from self slot(red) of level 1

• B is put to the parent inner slot(red) and also put to the wait list

• Only A and E are green now

Page 22: Htb

Case study

• E has no pkt, so D is scheduled• A changed to red• A is removed from self slot(red) of level 2• A is put to wait list of level2• Pkt arrived for E (thick circle)• E is green and lower priority,

so put to self slot(blue) of level 0• C changed back to green, and

removed from wait list, and putto self slot(blue) of level 0

Page 23: Htb

Case study

• Now both C and E are green and are of the same priority.

• DRR is used now, they’re scheduled according to quantum.

• Both C and D are changed toyellow, removed from self slot,put to inner slot and wait list

• B is added to both high and lower priority inner slot of A