Anda di halaman 1dari 6

TrafficControlManualForLab1

Fortheseguyswhowanttounderstandthismanualverywell,pleasereferto:
http://www.tldp.org/HOWTO/html_single/TrafficControlHOWTO/
Thismanualhasthreeparts.Inthefirstpart,itshowsyouhowtoemulatethedelay,packet
loss,duplication,reorderinginourlabnetworkwithNetEM(NetworkEmulator),Thesecondpart
showsyouhowtolimitbandwidthwithTBF(TokenBucketFilter).Thethirdpartwillshowyou
howtocombineNetEmandTBFtogetherandprovethatthecombinationworks.
Alltheseshowswillbepresentedbyexamples.Itsenvironmentisexactlytheonewehaveset
upinthevirtualmachinewheretheubuntu1andtheFreeBSDareconnectedbythe
ubuntu2(router).
Exceptspecified,allthecommand(theboldcharacters)willbeinputontheterminalof
ubuntu2(router).
Part1Emulatingthedelay,packetloss,etcwithNetEM
1.Delay
sudotcqdiscadddeveth2rootnetemdelay100ms10ms25%
Thiscausestheaddeddelaytobe100ms10mswiththenextrandomelementdepending25%
onthelastone.Thisisn'ttruestatisticalcorrelation,butanapproximation.
Itestitinmyubuntu2:
ThenIusepingtoprovethatitworks:
wefoundthatalltherttisbetween100ms10msexceptthefirstonewhichisbecausethearp
requestandresponsepacketsalsotakeartt.(Inthefollowingpartofmanual,Youcanalsoverify
ifthetcruleworksinthiswaybyyourself.)
Typically,thedelayinanetworkisnotuniform.Itismorecommontouseasomethinglikea
normaldistributiontodescribethevariationindelay.Thenetemdisciplinecantakeatableto
specifyanonuniformdistribution:
sudotcqdiscchangedeveth2rootnetemdelay100ms20msdistributionnormal
Thiscommandwillreplacetheprevioustcruleandmakethedistributionofdelayisnormal
distributionbetweentherangeof100ms20ms.Theactualtables(normal,pareto,
paretonormal)aregeneratedaspartoftheiproute2compilationandplacedin/usr/lib/tcsoitis
possiblewithsomeefforttomakeyourowndistributionbasedonexperimentaldata.
2.Packetloss
Randompacketlossisspecifiedinthe'tc'commandinpercent.Thesmallestpossiblenonzero
valueis:232=0.0000000232%
sudotcqdiscchangedeveth2rootnetemloss5%
Thiscauses1/10thofapercent(i.e1outof1000)packetstoberandomlydropped.
Anoptionalcorrelationmayalsobeadded.Thiscausestherandomnumbergeneratortobeless
randomandcanbeusedtoemulatepacketburstlosses.
sudotcqdiscchangedeveth2rootnetemloss5%25%
Thiswillcause5%ofpacketstobelost,andeachsuccessiveprobabilitydependsbyaquarter
onthelastone.
Prob(n)=.25*Prob(n1)+.75*Random
3.Packetcorruption
Randomnoisecanbeemulatedwiththecorruptoption.Thisintroducesasinglebiterrorata
randomoffsetinthepacket.
sudotcqdiscchangedeveth2rootnetemcorrupt5%
4.PacketReordering
Therearetwodifferentwaystospecifyreordering.Thefirstmethodgapusesafixedsequence
andreorderseveryNthpacket.Asimpleusageofthisis:
sudotcqdiscchangedeveth2rootnetemgap5delay10ms
Thiscausesevery5th(10th,15th,...)packettogotobesentimmediatelyandeveryother
packettobedelayedby10ms.Thisispredictableandusefulforbaseprotocoltestinglike
reassembly.
Thesecondformreorderofreorderingismorelikereallife.Itcausesacertainpercentageof
thepacketstogetmisordered.
sudotcqdiscchangedeveth2rootnetemdelay10msreorder25%50%
Inthisexample,25%ofpackets(withacorrelationof50%)willgetsentimmediately,otherswill
bedelayedby10ms.
Newerversionsofnetemwillalsoreorderpacketsiftherandomdelayvaluesareoutoforder.
Thefollowingwillcausesomereordering:
sudotcqdiscchangedeveth2rootnetemdelay100ms75ms
Ifthefirstpacketgetsarandomdelayof100ms(100msbase0msjitter)andthesecond
packetissent1mslaterandgetsadelayof50ms(100msbase50msjitter)thesecond
packetwillbesentfirst.Thisisbecausethequeuedisciplinetfifoinsidenetem,keepspacketsin
orderbytimetosend.
Part2LimitBandwidthwithTBF
Thereisnoratecontrolbuiltintothenetemdiscipline,insteaduseoneoftheotherdisciplines
thatdoesdoratecontrol.Inthisexample,weuseTokenBucketFilter(TBF)tolimitoutput.
First,weneedtocleanupthesettingwemadeinthefirstpart.
sudotcqdiscdeldeveth2root
Thiswilldeletethetcrulewemadeinthefirstpartofthismanual.
Then,
sudotcqdiscadddeveth2roottbfrate256kbitburst1600limit3000
Thiswilllimittheonedirectionbandwidthfromtheubuntu1toFreeBSDto256kbps,justreplace
256kbitwithothervaluewithoutchangingotherpartsofthiscommandifyouwanttospecifya
differentbandwidth.IfyouwanttolimitthebandwidthfromFreeBSDtoubuntu1atthesame
time,youshould(justchangetheinterfacefrometh2toeth1):
sudotcqdiscadddeveth1roottbfrate256kbitburst1600limit3000
Part3CombinationofNetEMandTBF
First,weneedtocleanupthequeuedisciplinewemadeinthefirstpart.
sudotcqdiscdeldeveth2root
Then,
sudotcqdiscadddeveth2roothandle1:tbfrate256kbitbuffer1600limit3000
sudotcqdiscadddeveth2parent1:1handle10:netemdelay100ms
BelowistheproofthatthecombinationofNetEMandTBFworks:
First,Icleanupthetcrulewemadeinthefirstpart.
anduse
sudotcqdiscshowdeveth2
tocheckifwedeleteitsuccessfully.Ifwedo,wewillgetsomethinglikethese:
Then,emulatethenetworkbetweenubuntu1andFreeBSDbyinputtingtwocommandsinthe
terminalofubuntu2:
Final,IusepingcommandandiperftomakesurethiscombinationofNetEMandTBFworks:
1.pingtheem1(interface1)ofFreeBSDfromtheterminalofubuntu1for1000times):
pingc10010.1.2.55
Thepingresultis:
whichistheresultfromthemixedeffectofdelay,packetlosscorruptionandreordering.
2.useriperftotestthebandwidthbetweenubuntu1andFreeBSD:
(1)installiperfinFreeBSD:
(2).installiperfinubuntu1:
(3).runiperfasaserverinFreeBSD:
(4).runiperfasaclientinubuntu1:
IntheFreeBSD,wegettheresult:
Now,weshowthatthebandwidthfromubuntu1toFreeBSDislimitedto250kbit/s(youcanalso
seeothercharacterslikeJitterandpackerlossfromtheoutputintheterminalofFreeBSD.
ThusweprovedthatthecombinationofNetEMandTBFworks.
ENDOFSHOWS
THANKS
Acknowledge
AbigpartofthismanualcomesfromtheInternetandIcompiledthemandmadesomechange
sothatitisspeciallyforourlab.
Reference:
1.https://calomel.org/network_loss_emulation.html
2.http://mytestbed.net/projects/omf/wiki/NetEM_examples_of_rules
3.http://www.linuxfoundation.org/collaborate/workgroups/networking/netem

Anda mungkin juga menyukai