linux man tc工具手冊颈走,需要時(shí)查一查

中文介紹可以看這篇Linux TC:一個(gè)能控制發(fā)送端流量的工具,模擬網(wǎng)絡(luò)異常的原理介紹

看了中文拷泽,再看英文man tc疫鹊,原來如此,英文的措辭更清晰司致,且不斷更新拆吆。

SYNOPSIS命令格式

? ? ? tc [ OPTIONS ] qdisc [ add | change | replace | link | delete ] dev DEV [ parent qdisc-id | root ] [ handle qdisc-id ] qdisc [qdisc specific parameters ]

? ? ? tc [ OPTIONS ] class [ add | change | replace | delete ] dev DEV parent qdisc-id [ classid class-id ] qdisc [? qdisc? specific parameters ]

? ? ? tc? [? OPTIONS ] filter [ add | change | replace | delete ] dev DEV [ parent qdisc-id | root ] protocol protocol prio priority filtertype [ filtertype specific parameters ] flowid flow-id

? ? ? tc [ OPTIONS ] [ FORMAT ] qdisc show [ dev DEV ]

? ? ? tc [ OPTIONS ] [ FORMAT ] class show dev DEV

? ? ? tc [ OPTIONS ] filter show dev DEV

DESCRIPTION描述

Tc is used to configure Traffic Control in the Linux kernel. Traffic Control consists of the following:

SHAPING:When traffic is shaped, its rate of transmission is under control. Shaping may be? more? than? lowering? the? available? bandwidth - it is also used to smooth out bursts in traffic for better network behaviour. Shaping occurs on egress.

SCHEDULING:By scheduling the transmission of packets it is possible to improve interactivity for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering is also called prioritizing, and happens only on egress.

POLICING:Whereas shaping deals with transmission of traffic, policing pertains to traffic arriving.? Policing? thus? occurs? on ingress.

DROPPING:Traffic exceeding a set bandwidth may also be dropped forthwith, both on ingress and on egress.

Processing of traffic is controlled by three kinds of objects: qdiscs, classes and filters.

QDISCS

qdisc is short for 'queueing discipline' and it is elementary to understanding traffic control. Whenever the kernel needs to send a packet to an interface, it is enqueued to the qdisc configured for that interface. Immediately afterwards,? the kernel tries to get as many packets as possible from the qdisc, for giving them to the network adaptor driver.

A? simple QDISC is the 'pfifo' one, which does no processing at all and is a pure First In, First Out queue. It does however store traffic when the network interface can't handle it momentarily.

CLASSES

Some qdiscs can contain classes, which contain further qdiscs - traffic may then be enqueued in any of the inner qdiscs, which are within the classes.? When the kernel tries to dequeue a packet from such a classful qdisc it can come from any of the classes. A qdisc may for example prioritize certain kinds of traffic by trying to dequeue from certain classes before others.

FILTERS

A filter is used by a classful qdisc to determine in which class a packet will be enqueued.? Whenever traffic arrives at a class with subclasses, it needs to be classified. Various methods may be employed to do so, one of these are the filters. All filters attached to the class are called, until one of them returns with a verdict. If no verdict was made, other criteria may be available. This differs per qdisc.

It is important to notice that filters reside within qdiscs - they are not masters of what happens.

The available filters are:

basic Filter packets based on an ematch expression. See tc-ematch(8) for details.

bpf? Filter packets using (e)BPF, see tc-bpf(8) for details.

cgroup Filter packets based on the control group of their process. See tc-cgroup(8) for details.

flow, flower Flow-based classifiers,? filtering packets based on their flow (identified by selectable keys). See tc-flow(8) and tc-flower(8) for details.

fw? Filter based on fwmark. Directly maps fwmark value to traffic class. See tc-fw(8).

route? Filter packets based on routing table. See tc-route(8) for details.

rsvp? Match Resource Reservation Protocol (RSVP) packets.

tcindex Filter packets based on traffic control index. See tc-tcindex(8).

u32? Generic filtering on arbitrary packet data, assisted by? syntax to abstract? common? operations. See? tc-u32(8)? for details.

matchall Traffic control filter that matches every packet. See tc-matchall(8) for details.

QEVENTS

? ? ? Qdiscs may invoke user-configured? actions when certain interesting events? take place in the qdisc. Each qevent can either be unused, or can have a block? attached to it. To this block are then? attached filters using the "tc block BLOCK_IDX" syntax. The block is executed? when the qevent associated with the attachment point takes place. For example, packet could be dropped, or delayed, etc.,? depending on the qdisc and the qevent? in question.

For example: tc qdisc add dev eth0 root handle 1: red? limit 500K avpkt 1K \ qevent early_drop? block 10

tc filter add block 10 matchall action mirred egress mirror dev eth1

CLASSLESS QDISCS

? ? ? The classless qdiscs are:

choke? CHOKe (CHOose and Keep for? responsive flows, CHOose and Kill for? unresponsive flows) is a classless qdisc? designed? to both identify and penalize? flows that monopolize the queue. CHOKe? is a variation of RED, and the configuration? is similar to RED.

codel? CoDel (pronounced "coddle") is an adaptive "no-knobs" active queue? management algorithm (AQM) scheme that was developed to address the? shortcomings of RED and its variants.

[p|b]fifo Simplest usable qdisc, pure? First In,? First Out behaviour.Limited in? packets or in bytes.

fq? ? Fair Queue Scheduler realises TCP pacing and scales to millions of concurrent? flows per qdisc.

fq_codel Fair Queuing Controlled Delay? is queuing discipline that combines Fair? Queuing with the CoDel AQM scheme. FQ_Codel uses a stochastic model to classify? incoming packets into different flows and? is used to provide a fair share of the bandwidth to all the flows using the queue. Each such flow is managed by the CoDel queuing discipline. Reordering within a flow is avoided since Codel internally uses a FIFO queue.

fq_pie FQ-PIE (Flow Queuing with? Proportional Integral controller Enhanced)? is a queuing discipline that combines FlowQueuing with the PIE AQM scheme. FQ-PIE uses a Jenkins hash function to? classify incoming packets into different flows and is used to provide a fair share of? the bandwidth to all the flows using the? qdisc. Each such flow is managed by? the PIE algorithm.

gred? Generalized Random Early Detection combines multiple RED queues in order to? achieve multiple drop priorities. This is? required to realize Assured Forwarding (RFC 2597).

hhf? ? Heavy-Hitter Filter differentiates? between small flows and the opposite,? heavy-hitters. The goal is to catch the heavy-hitters and move them to a separate? queue with less priority so that bulk traffic? does not affect the latency of critical traffic.

ingress This is a special qdisc as it applies to incoming traffic on an interface, allowing? for it to be filtered and policed.

mqprio The Multiqueue Priority Qdisc is a simple queuing discipline that allows? mapping traffic flows to hardware queue ranges using priorities and a configurable priorit to traffic class mapping. A traffic class in this context is a set of contiguous qdisc classes which map 1:1 to a set of hardware exposed queues.

multiq Multiqueue is a qdisc optimized for devices with multiple Tx queues. It has been added for hardware that wishes to avoid head-of-line blocking.? It will cycle though the bands and verify that the hardware queue associated with the band is not stopped prior to dequeuing a packet.

netem? Network Emulator is an enhancement of the Linux traffic control facilities that allow to add delay, packet loss, duplication and more other characteristics to packets outgoing from a selected network interface.

pfifo_fast? Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band queue which honors Type of Service flags, as well as the priority that may be assigned to a packet.

pie? ? Proportional Integral controller-Enhanced (PIE) is a control theoretic active queue management scheme. It is based on the proportional integral controller but aims to control delay.

red? ? Random Early Detection simulates physical congestion by randomly dropping packets when nearing configured bandwidth allocation. Well suited to very large bandwidth applications.

rr? ? Round-Robin qdisc with support for multiqueue network devices. Removed from Linux since kernel version 2.6.27.

sfb? ? Stochastic Fair Blue is a classless qdisc to manage congestion based on packet loss and link utilization history while trying to prevent non-responsive flows (i.e. flows that do not react to congestion marking or dropped packets) from impacting performance of responsive flows. Unlike RED, where the marking probability has to be configured, BLUE tries to determine the ideal marking probability automatically.

sfq? ? Stochastic Fairness Queueing reorders queued traffic so each 'session' gets to send a packet in turn.

tbf? ? The Token Bucket Filter is suited for slowing traffic down to a precisely configured rate. Scales well to large bandwidths.

CLASSFUL QDISCS

? ? ? The classful qdiscs are:

ATM? ? Map flows to virtual circuits of an? underlying asynchronous transfer mode? device.

CBQ? ? Class Based Queueing implements a rich linksharing hierarchy of classes.? It? contains shaping elements as well as? prioritizing capabilities. Shaping is? performed using link idle time calculations? based on average packet size and? underlying link bandwidth. The latter may? be ill-defined for some interfaces.

DRR? ? The Deficit Round Robin Scheduler? is a more flexible replacement for Stochastic Fairness Queuing. Unlike SFQ, there are no built-in queues -- you need? to add classes and then set up filters? to classify packets accordingly. This can be useful e.g. for using RED? qdiscs with different settings for particular? traffic. There is no default class -- if a? packet cannot be classified, it is dropped.

DSMARK Classify packets based on TOS? field, change TOS field of? packets based? on classification.

ETS? ? The ETS qdisc is a queuing discipline that merges functionality of PRIO and? DRR qdiscs in one scheduler. ETS makes it? easy to configure a set of strict and? bandwidth-sharing bands to implement the transmission selection described in? 802.1Qaz.

HFSC? Hierarchical Fair Service Curve guarantees precise bandwidth and delay? allocation for leaf classes and allocates? excess bandwidth fairly. Unlike HTB, it? makes use of packet dropping to achieve? low delays which interactive sessions? benefit from.

HTB? ? The Hierarchy Token Bucket? implements a rich linksharing hierarchy of? classes with an emphasis on conforming toexisting practices. HTB facilitates? guaranteeing bandwidth to classes, while? also allowing specification of upper limits? to inter-class? sharing. It contains shaping? elements, based on TBF and can prioritize? classes.

PRIO? The PRIO qdisc is a non-shaping? container for a configurable number of? classes which are dequeued in order. This? allows for easy prioritization of traffic,where lower classes are only able to send if? higher ones have no packets available. To? facilitate configuration,Type Of Service bits are honored by default.

QFQ? ? Quick Fair Queueing is an O(1) scheduler that provides near-optimal guarantees,? and is the first to achieve that goal with a? constant cost also with respect to the? number of groups and the packet? length. The QFQ algorithm has no loops,? and uses very simple instructions and data? structures that lend themselves very well to a hardware implementation.

THEORY OF OPERATION操作原理

Classes? form a tree, where each class has a single parent.? A class may have multiple children. Some qdiscs allow for runtime addition of classes (CBQ, HTB) while others (PRIO) are created with a static number of children.

Qdiscs which allow dynamic addition of classes can have zero or more subclasses to which traffic may be enqueued.

Furthermore, each class contains a leaf qdisc which by default has pfifo behaviour, although another qdisc can be attached? in? place. This qdisc may again contain classes, but each class can have only one leaf qdisc.

When a packet? enters a classful qdisc it? can be classified to one of the classes within. Three criteria are available,although not all qdiscs will use all three:

tc filters

? ? ? If tc filters are attached to a class, they are consulted first for relevant instructions. Filters can match on all fields of a packet header, as well as on the firewall mark applied by ipchains or iptables.

Type of Service

? ? ? Some qdiscs have built in rules for classifying packets based on the TOS field.

skb->priority

? ? ? Userspace programs can encode a class-id in the 'skb->priority' field using the SO_PRIORITY option.

Each node within the tree can have its own filters but higher level filters may also point directly to lower classes.

If classification? did? not succeed, packets are enqueued to the leaf qdisc attached to that class. Check qdisc specific man‐pages for details, however.

AUTHOR

Manpage maintained by bert hubert (ahu@ds9a.nl)

COLOPHON

? ? ? This page is part of the iproute2 (utilities for controlling TCP/IP networking and traffic) project.? Information about the project can be found at? ?http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2?.

? ? ? If you have a bug report for this manual page, send it to netdev@vger.kernel.org, shemminger@osdl.org.? This page was? obtained from the project's upstream Git repository ?https://git.kernel.org/pub/scm/network/iproute2/iproute2.git? on 2021-08-27.? (At that time, the date of the most recent commit that was found in the repository was 2021-08-18.)? If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the? information in this COLOPHON (which is not part of the original manual page), send a mail to man-pages@man7.org

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市脂矫,隨后出現(xiàn)的幾起案子枣耀,更是在濱河造成了極大的恐慌,老刑警劉巖庭再,帶你破解...
    沈念sama閱讀 218,122評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件捞奕,死亡現(xiàn)場離奇詭異,居然都是意外死亡拄轻,警方通過查閱死者的電腦和手機(jī)颅围,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來恨搓,“玉大人院促,你說我怎么就攤上這事筏养。” “怎么了常拓?”我有些...
    開封第一講書人閱讀 164,491評論 0 354
  • 文/不壞的土叔 我叫張陵渐溶,是天一觀的道長。 經(jīng)常有香客問我弄抬,道長茎辐,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,636評論 1 293
  • 正文 為了忘掉前任掂恕,我火速辦了婚禮拖陆,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘竹海。我一直安慰自己严里,他們只是感情好捷绑,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,676評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般藤韵。 火紅的嫁衣襯著肌膚如雪夹供。 梳的紋絲不亂的頭發(fā)上抚官,一...
    開封第一講書人閱讀 51,541評論 1 305
  • 那天猜旬,我揣著相機(jī)與錄音,去河邊找鬼甩卓。 笑死鸠匀,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的逾柿。 我是一名探鬼主播缀棍,決...
    沈念sama閱讀 40,292評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼机错!你這毒婦竟也來了爬范?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,211評論 0 276
  • 序言:老撾萬榮一對情侶失蹤弱匪,失蹤者是張志新(化名)和其女友劉穎青瀑,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體萧诫,經(jīng)...
    沈念sama閱讀 45,655評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡斥难,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,846評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了帘饶。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片哑诊。...
    茶點(diǎn)故事閱讀 39,965評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖及刻,靈堂內(nèi)的尸體忽然破棺而出搭儒,到底是詐尸還是另有隱情穷当,我是刑警寧澤,帶...
    沈念sama閱讀 35,684評論 5 347
  • 正文 年R本政府宣布淹禾,位于F島的核電站,受9級特大地震影響茴扁,放射性物質(zhì)發(fā)生泄漏铃岔。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,295評論 3 329
  • 文/蒙蒙 一峭火、第九天 我趴在偏房一處隱蔽的房頂上張望毁习。 院中可真熱鬧,春花似錦卖丸、人聲如沸纺且。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,894評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽载碌。三九已至,卻和暖如春衅枫,著一層夾襖步出監(jiān)牢的瞬間嫁艇,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,012評論 1 269
  • 我被黑心中介騙來泰國打工弦撩, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留步咪,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,126評論 3 370
  • 正文 我出身青樓益楼,卻偏偏與公主長得像猾漫,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子感凤,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,914評論 2 355

推薦閱讀更多精彩內(nèi)容