TC(8) Linux TC(8) NAME tc−show/manipulatetrafficcontrolsettings SYNOPSIS tcqdisc[add|change|replace|link]devDEV[parentqdisc-id|root][handle qdisc-id]qdisc[qdiscspecificparameters] tcclass[add|change|replace]devDEVparentqdisc-id[classidclass-id]qdisc[qdisc specificparameters] tcfilter[add|change|replace]devDEV[parentqdisc-id|root]protocolprotocol priopriorityfiltertype[filtertypespecificparameters]flowidflow-id tc[-s|-d]qdiscshow[devDEV] tc[-s|-d]classshowdevDEV tcfiltershowdevDEV DESCRIPTION TcisusedtoconfigureTrafficControlintheLinuxkernel.TrafficControlconsistsofthefollowing: SHAPING Whentrafficisshaped,itsrateoftransmissionisundercontrol.Shapingmaybemore thanloweringtheavailablebandwidth-itisalsousedtosmoothoutburstsintrafficfor betternetworkbehaviour.Shapingoccursonegress. SCHEDULING Byschedulingthetransmissionofpacketsitispossibletoimproveinteractivityfortraffic thatneedsitwhilestillguaranteeingbandwidthtobulktransfers.Reorderingisalso calledprioritizing,andhappensonlyonegress. POLICING Whereshapingdealswithtransmissionoftraffic,policingpertainstotrafficarriving. Policingthusoccursoningress. DROPPING Trafficexceedingasetbandwidthmayalsobedroppedforthwith,bothoningressandon egress. Processingoftrafficiscontrolledbythreekindsofobjects:qdiscs,classesandfilters. QDISCS qdiscisshortfor’queueingdiscipline’anditiselementarytounderstandingtrafficcontrol. Wheneverthekernelneedstosendapackettoaninterface,itisenqueuedtotheqdiscconfiguredforthatinterface.Immediatelyafterwards,thekerneltriestogetasmanypacketsaspossible fromtheqdisc,forgivingthemtothenetworkadaptordriver. AsimpleQDISCisthe’pfifo’one,whichdoesnoprocessingatallandisapureFirstIn,First Outqueue.Itdoeshoweverstoretrafficwhenthenetworkinterfacecan’thandleitmomentarily. iproute2 16December2001 1 TC(8) Linux TC(8) 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. redRandomEarlyDetectionsimulatesphysicalcongestionbyrandomlydroppingpackets whennearingconfiguredbandwidthallocation.Wellsuitedtoverylargebandwidthapplications. sfqStochasticFairnessQueueingreordersqueuedtrafficsoeach’session’getstosenda packetinturn. tbfTheTokenBucketFilterissuitedforslowingtrafficdowntoapreciselyconfiguredrate. Scaleswelltolargebandwidths. CONFIGURINGCLASSLESSQDISCS Intheabsenceofclassfulqdiscs,classlessqdiscscanonlybeattachedattherootofadevice.Full syntax: tcqdiscadddevDEVrootQDISCQDISC-PARAMETERS Toremove,issue tcqdiscdeldevDEVroot Thepfifofastqdiscistheautomaticdefaultintheabsenceofaconfiguredqdisc. CLASSFULQDISCS Theclassfulqdiscsare: CBQClassBasedQueueingimplementsarichlinksharinghierarchyofclasses.Itcontains shapingelementsaswellasprioritizingcapabilities.Shapingisperformedusinglinkidle timecalculationsbasedonaveragepacketsizeandunderlyinglinkbandwidth.Thelatter maybeill-definedforsomeinterfaces. HTBTheHierarchyTokenBucketimplementsarichlinksharinghierarchyofclasseswithan emphasisonconformingtoexistingpractices.HTBfacilitatesguaranteeingbandwidthto classes,whilealsoallowingspecificationofupperlimitstointer-classsharing.Itcontains iproute2 16December2001 2 TC(8) Linux TC(8) shapingelements,basedonTBFandcanprioritizeclasses. PRIOThePRIOqdiscisanon-shapingcontainerforaconfigurablenumberofclasseswhichare dequeuedinorder.Thisallowsforeasyprioritizationoftraffic,wherelowerclassesare onlyabletosendifhigheroneshavenopacketsavailable.Tofacilitateconfiguration, TypeOfServicebitsarehonoredbydefault. THEORYOFOPERATION Classesformatree,whereeachclasshasasingleparent.Aclassmayhavemultiplechildren. Someqdiscsallowforruntimeadditionofclasses(CBQ,HTB)whileothers(PRIO)arecreated withastaticnumberofchildren. Qdiscswhichallowdynamicadditionofclassescanhavezeroormoresubclassestowhichtraffic maybeenqueued. Furthermore,eachclasscontainsaleafqdiscwhichbydefaulthaspfifobehaviourthough anotherqdisccanbeattachedinplace.Thisqdiscmayagaincontainclasses,buteachclasscan haveonlyoneleafqdisc. Whenapacketentersaclassfulqdiscitcanbeclassifiedtooneoftheclasseswithin.Threecriteriaareavailable,althoughnotallqdiscswilluseallthree: tcfilters Iftcfiltersareattachedtoaclass,theyareconsultedfirstforrelevantinstructions.Filters canmatchonallfieldsofapacketheader,aswellasonthefirewallmarkappliedby ipchainsoriptables.Seetc-filters(8). TypeofService SomeqdiscshavebuiltinrulesforclassifyingpacketsbasedontheTOSfield. skb->priority Userspaceprogramscanencodeaclass-idinthe’skb->priority’fieldusingtheSOPRI-ORITYoption. Eachnodewithinthetreecanhaveitsownfiltersbuthigherlevelfiltersmayalsopointdirectly tolowerclasses. Ifclassificationdidnotsucceed,packetsareenqueuedtotheleafqdiscattachedtothatclass. Checkqdiscspecificmanpagesfordetails,however. NAMING Allqdiscs,classesandfiltershaveIDs,whichcaneitherbespecifiedorbeautomaticallyassigned. IDsconsistofamajornumberandaminornumber,separatedbyacolon. QDISCS Aqdisc,whichpotentiallycanhavechildren,getsassignedamajornumber,calleda’handle’,leavingtheminornumbernamespaceavailableforclasses.Thehandleisexpressedas ’10:’.Itiscustomarytoexplicitlyassignahandletoqdiscsexpectedtohavechildren. CLASSES Classesresidingunderaqdiscsharetheirqdiscmajornumber,buteachhaveaseparate minornumbercalleda’classid’thathasnorelationtotheirparentclasses,onlytotheir parentqdisc.Thesamenamingcustomasforqdiscsapplies. iproute2 16December2001 3 TC(8) Linux TC(8) FILTERS FiltershaveathreepartID,whichisonlyneededwhenusingahashedfilterhierarchy,for whichseetc-filters(8). UNITS Allparametersacceptafloatingpointnumber,possiblyfollowedbyaunit. Bandwidthsorratescanbespecifiedin: kbpsKilobytespersecond mbpsMegabytespersecond kbitKilobitspersecond mbitMegabitspersecond bpsorabarenumber Bytespersecond Amountsofdatacanbespecifiedin: kbork Kilobytes mborm Megabytes mbitMegabits kbitKilobits borabarenumber Bytes. Lengthsoftimecanbespecifiedin: s,secorsecs Wholeseconds ms,msecormsecs Milliseconds us,usec,usecsorabarenumber Microseconds. TCCOMMANDS Thefollowingcommandsareavailableforqdiscs,classesandfilter: addAddaqdisc,classorfiltertoanode.Forallentities,aparentmustbepassed,eitherby passingitsIDorbyattachingdirectlytotherootofadevice.Whencreatingaqdiscora filter,itcanbenamedwiththehandleparameter.Aclassisnamedwiththeclassid parameter. removeAqdisccanberemovedbyspecifyingitshandle,whichmayalsobe’root’.Allsubclasses andtheirleafqdiscsareautomaticallydeleted,aswellasanyfiltersattachedtothem. changeSomeentitiescanbemodified’inplace’.Sharesthesyntaxof’add’,withtheexception thatthehandlecannotbechangedandneithercantheparent.Inotherwords,change cannotmoveanode. replacePerformsanearlyatomicremove/addonanexistingnodeid.Ifthenodedoesnotexist yetitiscreated. iproute2 16December2001 4 TC(8) Linux TC(8) linkOnlyavailableforqdiscsandperformsareplacewherethenodemustexistalready. HISTORY tcwaswrittenbyAlexeyN.KuznetsovandaddedinLinux2.2. SEEALSO tc-cbq(8),tc-htb(8),tc-sfq(8),tc-red(8),tc-tbf(8),tc-pfifo(8),tc-bfifo(8),tc-pfifofast(8), tc-filters(8) AUTHOR Manpagemaintainedbyberthubert(ahu@ds9a.nl) iproute2 16December2001 5