这里是linux内核流控相关的基本概念,具体的代码请参考kernel/net/sched/目录下的相关代码
六个基本操作
- Shaping
- Scheduling:(re)arranging queued packets.
- Classifying:separating packets/flows.
- Policing: Matching a packet/flow to a rate.
- Dropping: discarding a packet/flow.
- Marking: Modifying the packet itself.
实现机制
- Queues.
- Tokens.
- Buckets.
Linux 对象
- qdisc: the queuing discpline.
- class: a flexible internal queue.
- filter: for classifying and policing.
- classifier: identifying flow/packets.
- policer: limiting matching flows.
基本原则
- For shaping traffic on a link, always be the bottleneck.
- You can only shape trasmiited traffic.
- Every interface must have a qdisc.
- Any newly created class contains a FIFO.
- A classful qdisc with no children classes only consumes CPU.
- Classes attached directly to the root qdisc can simulate vritual circuits.
- A filter can be attached to classes or a classful qdisc.
Classless qdisc
- FIFI: first-in, first out.
- SFQ: stochastic fair queue.
- TBF: token bucket filter.
- GRED: generic random early drop.
Classful qdisc
- CBQ: Class based queue.
- HTB: hierarchical token bucket.
- PRIO: prioritizing.
- WRR: Weighted round robin.
SFQ
TBF