Vous êtes sur la page 1sur 1

159.

201Algorithms&DataStructures
S12015
Assignment3
ConsiderarouterwithNports.Thereare4importantsourcesofdelays,transmission,nodalprocessing,propagationand
queueing.Thefirst3formsofdelaydependonthehardwareandlowlevelprotocols.However,the queueingdelayonly
dependsonthetrafficpattern,i.e.,onhowbusythenetworkisandwhattypeoftrafficisinvolved.Wearegoingtomodel
ourrouterasperFig.1.Everypackethasaspecificporttogoout(e.g.,blueforport1,orangeforport2etc).
Notethatthereareinputqueuesandoutputqueues,andthatthebottleneckisdefinedbythetransmissionandpropagation
delaysofthelinksoftherouter.Transmission,propagationandnodalprocessingarefixedfortherouter.Thethroughputof
eachlinkis1Gbit/sec,andthenodalprocessingissosmallthatitcanbedisregarded(inrealityitisgoingtotakethetime
toreadthedestinationofthepacket).Notealsothattherouterhasasharedbusbetweentheinputandoutputports.This
meansthatonlyonepacketatatimecanleavetheinputqueueandbecopiedtotheappropriateoutputqueue.
Thesimulationworksbymovingpacketsfrominputqueues(startwith1,then2N,thengobackto1)tooutputqueues
ateveryclockcycle.Youneedtouse Join(),Leave()andFront()intheappropriatequeues.Aftermovingapacket,a
globalarrayvariableCongestionSize[N]shouldkeepthestateofalloutputports.Thesevaluesshouldbeupdatedonly
whenthesum ofall packets islarger thanthecurrent sumof all elements ofCongestionSize[N]. At the end ofthe
simulation,whenallinputportsareempty,CongestionSize[N]willcontaintheinformationtobeprinted.

Figure1:Statusoftherouterwhentherouterisatits
maximumcongestion.
Yourtaskistocompletethesimulationcode,creatingtheappropriatequeuesandcalculatingwhatwasthemaximum
congestion(innumberofpackets)inallqueuesatsomepointinthesimulation.YourprogramshouldprintNlineswiththe
stateofeachoutputqueuewhenthecongestionwasatitspeak.Forexample,supposethatyouhavearouterwithN=3.
After running the simulation, the output should like this (suppose that the drawing above represents the maximum
congestion):
outputport1:3packets
outputport2:6packets
outputport3:5packets
Theinputqueuesarefilledatthestartofthesimulation,readingthevariousinputsfromatextfileatonce.Theformatof
thefilecontainsinformationabouthowmanypackets,packetsizesetc.Please,usethestartupcodegivenonStreamand
sticktotheinputformatgivenintheexamples,aswellastheoutputformatgivenabove.Themaximumnumberofports
usedinthesimulationwillbeN=128,thereforeyoucanuseastaticCongestionSize[N]array.However,queuesshouldonly
becreatedwhenneeded.Duetothesizeofthequeues,youmustusequeuesimplementedwithlinkedlists(please,donot
useSTLinthisassignment).
Useourvirtualmachinetotestyoursubmissions(hostname vm000296). Theinput/outputrequirementsareessential,
pleasefollowthemcarefullytoavoidlosingmarks.Spacesmatterandtextiscasesensitive.
Afteryouaresatisfiedwiththeperformanceofyourcodeastestedinthevirtualmachine,submitaonesourcefilecodeon
StreambyFriday20thofMarch2015.YournameandIDnumbermustappearontopofthefileascomments.Ifyou
areworkinginagroup,thenallnamesandIDsmustappearontopofthefileascomments,butyoustillneedto submit
individuallyinboththevirtualmachineandStream.

Vous aimerez peut-être aussi