TC(8) Linux TC(8) NAME tc−show/manipulatetrafficcontrolsettings SYNOPSIS tcqdisc[add|change|replace|link|delete]devDEV[parentqdisc-id|root][ handleqdisc-id]qdisc[qdiscspecificparameters] tcclass[add|change|replace|delete]devDEVparentqdisc-id[classidclass-id] qdisc[qdiscspecificparameters] tcfilter[add|change|replace|delete]devDEV[parentqdisc-id|root]protocol protocolpriopriorityfiltertype[filtertypespecificparameters]flowidflow-id tc[FORMAT]qdiscshow[devDEV] tc[FORMAT]classshowdevDEV tcfiltershowdevDEV tc[-force]-b[atch][filename] FORMAT:={−s[tatistics]|−d[etails]|−r[aw]|−p[retty]|−i[ec]} DESCRIPTION TcisusedtoconfigureTrafficControlintheLinuxkernel.TrafficControlconsistsofthefollowing: SHAPING Whentrafficisshaped,itsrateoftransmissionisundercontrol.Shapingmaybemore thanloweringtheavailablebandwidth-itisalsousedtosmoothoutburstsintrafficfor betternetworkbehaviour.Shapingoccursonegress. SCHEDULING Byschedulingthetransmissionofpacketsitispossibletoimproveinteractivityfortraffic thatneedsitwhilestillguaranteeingbandwidthtobulktransfers.Reorderingisalso calledprioritizing,andhappensonlyonegress. POLICING Whereasshapingdealswithtransmissionoftraffic,policingpertainstotrafficarriving. Policingthusoccursoningress. DROPPING Trafficexceedingasetbandwidthmayalsobedroppedforthwith,bothoningressandon egress. Processingoftrafficiscontrolledbythreekindsofobjects:qdiscs,classesandfilters. QDISCS qdiscisshortfor’queueingdiscipline’anditiselementarytounderstandingtrafficcontrol. Wheneverthekernelneedstosendapackettoaninterface,itisenqueuedtotheqdiscconfiguredforthatinterface.Immediatelyafterwards,thekerneltriestogetasmanypacketsaspossible fromtheqdisc,forgivingthemtothenetworkadaptordriver. AsimpleQDISCisthe’pfifo’one,whichdoesnoprocessingatallandisapureFirstIn,First iproute2 16December2001 1 TC(8) Linux TC(8) Outqueue.Itdoeshoweverstoretrafficwhenthenetworkinterfacecan’thandleitmomentarily. CLASSES Someqdiscscancontainclasses,whichcontainfurtherqdiscs-trafficmaythenbeenqueuedin anyoftheinnerqdiscs,whicharewithintheclasses.Whenthekerneltriestodequeueapacket fromsuchaclassfulqdiscitcancomefromanyoftheclasses.Aqdiscmayforexampleprioritizecertainkindsoftrafficbytryingtodequeuefromcertainclassesbeforeothers. FILTERS Afilterisusedbyaclassfulqdisctodetermineinwhichclassapacketwillbeenqueued.Whenevertrafficarrivesataclasswithsubclasses,itneedstobeclassified.Variousmethodsmaybe employedtodoso,oneofthesearethefilters.Allfiltersattachedtotheclassarecalled,untilone ofthemreturnswithaverdict.Ifnoverdictwasmade,othercriteriamaybeavailable.Thisdiffersperqdisc. Itisimportanttonoticethatfiltersresidewithinqdiscs-theyarenotmastersofwhathappens. CLASSLESSQDISCS Theclasslessqdiscsare: [p|b]fifo Simplestusableqdisc,pureFirstIn,FirstOutbehaviour.Limitedinpacketsorinbytes. pfifofast Standardqdiscfor’AdvancedRouter’enabledkernels.Consistsofathree-bandqueue whichhonorsTypeofServiceflags,aswellastheprioritythatmaybeassignedtoa packet. red RandomEarlyDetectionsimulatesphysicalcongestionbyrandomlydroppingpackets whennearingconfiguredbandwidthallocation.Wellsuitedtoverylargebandwidthapplications. sfq StochasticFairnessQueueingreordersqueuedtrafficsoeach’session’getstosenda packetinturn. tbf TheTokenBucketFilterissuitedforslowingtrafficdowntoapreciselyconfiguredrate. Scaleswelltolargebandwidths. CONFIGURINGCLASSLESSQDISCS Intheabsenceofclassfulqdiscs,classlessqdiscscanonlybeattachedattherootofadevice.Full syntax: tcqdiscadddevDEVrootQDISCQDISC-PARAMETERS Toremove,issue tcqdiscdeldevDEVroot Thepfifofastqdiscistheautomaticdefaultintheabsenceofaconfiguredqdisc. CLASSFULQDISCS Theclassfulqdiscsare: CBQ ClassBasedQueueingimplementsarichlinksharinghierarchyofclasses.Itcontains shapingelementsaswellasprioritizingcapabilities.Shapingisperformedusinglinkidle timecalculationsbasedonaveragepacketsizeandunderlyinglinkbandwidth.Thelatter maybeill-definedforsomeinterfaces. iproute2 16December2001 2 TC(8) Linux TC(8) HTB TheHierarchyTokenBucketimplementsarichlinksharinghierarchyofclasseswithan emphasisonconformingtoexistingpractices.HTBfacilitatesguaranteeingbandwidthto classes,whilealsoallowingspecificationofupperlimitstointer-classsharing.Itcontains shapingelements,basedonTBFandcanprioritizeclasses. PRIO ThePRIOqdiscisanon-shapingcontainerforaconfigurablenumberofclasseswhichare dequeuedinorder.Thisallowsforeasyprioritizationoftraffic,wherelowerclassesare onlyabletosendifhigheroneshavenopacketsavailable.Tofacilitateconfiguration, TypeOfServicebitsarehonoredbydefault. THEORYOFOPERATION Classesformatree,whereeachclasshasasingleparent.Aclassmayhavemultiplechildren. Someqdiscsallowforruntimeadditionofclasses(CBQ,HTB)whileothers(PRIO)arecreated withastaticnumberofchildren. Qdiscswhichallowdynamicadditionofclassescanhavezeroormoresubclassestowhichtraffic maybeenqueued. Furthermore,eachclasscontainsaleafqdiscwhichbydefaulthaspfifobehaviour,although anotherqdisccanbeattachedinplace.Thisqdiscmayagaincontainclasses,buteachclasscan haveonlyoneleafqdisc. Whenapacketentersaclassfulqdiscitcanbeclassifiedtooneoftheclasseswithin.Threecriteriaareavailable,althoughnotallqdiscswilluseallthree: tcfilters Iftcfiltersareattachedtoaclass,theyareconsultedfirstforrelevantinstructions.Filters canmatchonallfieldsofapacketheader,aswellasonthefirewallmarkappliedby ipchainsoriptables. TypeofService SomeqdiscshavebuiltinrulesforclassifyingpacketsbasedontheTOSfield. skb->priority Userspaceprogramscanencodeaclass-idinthe’skb->priority’fieldusingtheSOPRI-ORITYoption. Eachnodewithinthetreecanhaveitsownfiltersbuthigherlevelfiltersmayalsopointdirectly tolowerclasses. Ifclassificationdidnotsucceed,packetsareenqueuedtotheleafqdiscattachedtothatclass. Checkqdiscspecificmanpagesfordetails,however. NAMING Allqdiscs,classesandfiltershaveIDs,whichcaneitherbespecifiedorbeautomaticallyassigned. IDsconsistofamajornumberandaminornumber,separatedbyacolon.Bothmajorandminor numberarelimitedto16bits.Therearetwospecialvalues:rootissignifiedbymajorandminor ofallones,andunspecifiedisallzeros. QDISCS Aqdisc,whichpotentiallycanhavechildren,getsassignedamajornumber,calleda’handle’,leavingtheminornumbernamespaceavailableforclasses.Thehandleisexpressedas ’10:’.Itiscustomarytoexplicitlyassignahandletoqdiscsexpectedtohavechildren. iproute2 16December2001 3 TC(8) Linux TC(8) CLASSES Classesresidingunderaqdiscsharetheirqdiscmajornumber,buteachhaveaseparate minornumbercalleda’classid’thathasnorelationtotheirparentclasses,onlytotheir parentqdisc.Thesamenamingcustomasforqdiscsapplies. FILTERS FiltershaveathreepartID,whichisonlyneededwhenusingahashedfilterhierarchy. PARAMETERS ThefollowingparametersarewidelyusedinTC.Forotherparameters,seethemanpagesfor individualqdiscs. RATES Bandwidthsorrates.Theseparametersacceptafloatingpointnumber,possiblyfollowed byaunit(bothSIandIECunitssupported). bitorabarenumber Bitspersecond kbit Kilobitspersecond mbit Megabitspersecond gbit Gigabitspersecond tbit Terabitspersecond bps Bytespersecond kbps Kilobytespersecond mbps Megabytespersecond gbps Gigabytespersecond tbps Terabytespersecond TospecifyinIECunits,replacetheSIprefix(k-,m-,g-,t-)withIECprefix(ki-,mi-,gi-andti-)respectively. TCstoreratesasa32-bitunsignedintegerinbpsinternally,sowecanspecifyamaxrate of4294967295bps. TIMES Lengthoftime.Canbespecifiedasafloatingpointnumberfollowedbyanoptionalunit: s,secorsecs Wholeseconds ms,msecormsecs Milliseconds us,usec,usecsorabarenumber Microseconds. TCdefineditsowntimeunit(equaltomicrosecond)andstorestimevaluesas32-bit unsignedinteger,thuswecanspecifyamaxtimevalueof4294967295usecs. iproute2 16December2001 4 TC(8) Linux TC(8) SIZES Amountsofdata.Canbespecifiedasafloatingpointnumberfollowedbyanoptional unit: borabarenumber Bytes. kbit Kilobits kbork Kilobytes mbit Megabits mborm Megabytes gbit Gigabits gborg Gigabytes TCstoressizesinternallyas32-bitunsignedintegerinbyte,sowecanspecifyamaxsize of4294967295bytes. VALUES Othervalueswithoutaunit.Theseparametersareinterpretedasdecimalbydefault,but youcanindicateTCtointerpretthemasoctalandhexadecimalbyaddinga’0’or’0x’ prefixrespectively. TCCOMMANDS Thefollowingcommandsareavailableforqdiscs,classesandfilter: add Addaqdisc,classorfiltertoanode.Forallentities,aparentmustbepassed,eitherby passingitsIDorbyattachingdirectlytotherootofadevice.Whencreatingaqdiscora filter,itcanbenamedwiththehandleparameter.Aclassisnamedwiththeclassid parameter. delete Aqdisccanbedeletedbyspecifyingitshandle,whichmayalsobe’root’.Allsubclasses andtheirleafqdiscsareautomaticallydeleted,aswellasanyfiltersattachedtothem. change Someentitiescanbemodified’inplace’.Sharesthesyntaxof’add’,withtheexception thatthehandlecannotbechangedandneithercantheparent.Inotherwords,change cannotmoveanode. replace Performsanearlyatomicremove/addonanexistingnodeid.Ifthenodedoesnotexist yetitiscreated. link Onlyavailableforqdiscsandperformsareplacewherethenodemustexistalready. FORMAT Theshowcommandhasadditionalformattingoptions: −s,−stats,−statistics outputmorestatisticsaboutpacketusage. iproute2 16December2001 5 TC(8) Linux TC(8) −d,−details outputmoredetailedinformationaboutratesandcellsizes. −r,−raw outputrawhexvaluesforhandles. −p,−pretty decodefilteroffsetandmaskvaluestoequivalentfiltercommandsbasedonTCP/IP. −iec printratesinIECunits(ie.1K=1024). −b,−bfilename,−batch,−batchfilename readcommandsfromprovidedfileorstandardinputandinvokethem.Firstfailurewill causeterminationoftc. −force don’tterminatetconerrorsinbatchmode.Iftherewereanyerrorsduringexecutionof thecommands,theapplicationreturncodewillbenonzero. HISTORY tcwaswrittenbyAlexeyN.KuznetsovandaddedinLinux2.2. SEEALSO tc-bfifo(8),tc-cbq(8),tc-choke(8),tc-codel(8),tc-drr(8),tc-ematch(8),tc-fqcodel(8),tc-hfsc(7),tc-hfsc(8),tc-htb(8),tc-pfifo(8),tc-pfifofast(8),tc-red(8),tc-sfb(8),tc-sfq(8),tc-stab(8),tc-tbf(8), Userdocumentationathttp://lartc.org/,butpleasedirectbugreportsandpatchesto:<netdev@vger.kernel.org> AUTHOR Manpagemaintainedbyberthubert(ahu@ds9a.nl) iproute2 16December2001 6