企业内部网络有足够的带宽可以使用。但是,一般在企业接入Internet的部分都是一个有限的流量。为了提高网络的使用质量,保证用户按照网络中业务设计的要求来使用整个网络的带宽,可以从流量控制服务器的角度分析、优化Linux系统,给企业服务带来便利和高效。现在对流量控制(TC)的具体使用做个介绍。首先是TC的总用法。
TC命令,内核支持需设置QoS support、QoS and/or fair queueing = y。用法为:
#tc [ OPTIONS ] OBJECT { COMMAND | help }
其中
OBJECT := { qdisc | class | filter }
OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] }
下面分别介绍TC中队列、分类和过滤器的用法。
1.TC中队列(qdisc)的用法
队列的使用中,内核支持需设置QoS support、QoS and/or fair queueing = y。用法为:
- #tc qdisc [ add | del | replace | change | get ] dev STRING
- [ handle QHANDLE ] [ root | ingress | parent CLASSID ]
- [ estimator INTERVAL TIME_CONSTANT ]
- [ [ QDISC_KIND ] [ help | OPTIONS ] ]
- #tc qdisc show [ dev STRING ] [ingress]
其中
- QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }
- OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help
- CBQ队列(qdisc cbq)的使用中,内核支持需设置 QoS support、QoS and/or fair queueing、CBQ packet scheduler、Rate estimator = y,用法为:
- ... cbq bandwidth BPS avpkt BYTES [ mpu BYTES ]
- [ cell BYTES ] [ ewma LOG ]
2.TC中分类(class)的用法
分类的使用中,内核支持需设置QoS support、QoS and/or fair queueing、Packet classifier API = y。用法为:
- #tc class [ add | del | change | get ] dev STRING
- [ classid CLASSID ] [ root | parent CLASSID ]
- [ [ QDISC_KIND ] [ help | OPTIONS ] ]
- #tc class show [ dev STRING ] [ root | parent CLASSID ]
其中
- QDISC_KIND := { prio | cbq | etc. }
- OPTIONS := ... try tc class add <desired QDISC_KIND> help
- TC CBQ分类(class cbq)的用法为:
- <ccid_nobr>
- <table width="400" border="1" cellspacing="0" cellpadding="2"
- bordercolorlight = "black" bordercolordark = "#FFFFFF" align="center">
- <tr>
- <td bgcolor="e6e6e6" class="code" style="font-size:9pt">
- <pre><ccid_code> ... cbq bandwidth BPS rate BPS maxburst PKTS [ avpkt BYTES ]
- [ minburst PKTS ] [ bounded ] [ isolated ]
- [ allot BYTES ] [ mpu BYTES ] [ weight RATE ]
- [ prio NUMBER ] [ cell BYTES ] [ ewma LOG ]
- [ estimator INTERVAL TIME_CONSTANT ]
- [ split CLASSID ] [ defmap MASK/CHANGE ]
3.TC中过滤器(filter)的用法
过滤器的使用中,内核支持需设置QoS support、QoS and/or fair queueing、Packet classifier API = y。用法为:
- #tc filter [ add | del | change | get ] dev STRING
- [ pref PRIO ] [ protocol PROTO ]
- [ estimator INTERVAL TIME_CONSTANT ]
- [ root | classid CLASSID ] [ handle FILTERID ]
- [ [ FILTER_TYPE ] [ help | OPTIONS ] ]
- #tc filter show [ dev STRING ] [ root | parent CLASSID ]
其中
- FILTER_TYPE := { rsvp | u32 | fw | route | etc. }
- FILTERID := ... format depends on classifier, see there
- OPTIONS := ... try tc filter add <desired FILTER_KIND> help
TC U32过滤器(filter u32)的用法:
- ... u32 [ match SELECTOR ... ] [ link HTID ] [ classid CLASSID ]
- [ police POLICE_SPEC ] [ offset OFFSET_SPEC ]
- [ ht HTID ] [ hashkey HASHKEY_SPEC ]
- [ sample SAMPLE ]
- 或 u32 divisor DIVISOR
其中
- SELECTOR := SAMPLE SAMPLE ...
- SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} } SAMPLE_ARGS
- FILTERID := X:Y:Z
TC FW过滤器(filter fw)的用法:
... fw [ classid CLASSID ] [ police POLICE_SPEC ]
其中
POLICE_SPEC := ... look at TBF
CLASSID := X:Y
【编辑推荐】