1
COMP331/931ComputerNetworksandApplications
AssignmentforSesion2,2016
Version1.0
Due:11:59pmFriday,16September2016(Wek8)
1.ChangeLog
Version1.0releasedon1
th
August2016.
2.Goalandlearningobjectives
Forthisasignment,youwilbeaskedtoimplementareliabletransportprotocolovertheUDP
protocol.Wewilrefertothereliabletransportprotocolthatyouwilbeprograminginthis
asignmentasSimpleTransportProtocol(STP).STPwilincludemost(butnotal)ofthefeatures
thataredescribedinSections3.5.4and3.5.6ofthetextComputerNetworking(6thed.).Examples
ofthesefeaturesincludetimeout,ACK,sequencenumberetc.Notethatthesefeaturesare
commonlyfoundinmanytransportprotocols.Therefore,thisasignmentwilgiveyouan
opportunitytoimplementsomeofthesebasicfeaturesofatransportprotocol.Inaddition,youmay
havewonderedwhythedesigneroftheTCP/IPprotocolstackincludessuchfeature-lestransport
protocolasUDP.Youwilfindinthisasignmentthatyoucandesignyourowntransportprotocol
andrunitoverUDP.ThisisthecaseforsomeexistingmultimediadeliveryservicesintheInternet,
wheretheyhaveimplementedtheirownproprietarytransportprotocoloverUDP.
NotethatitismandatorythatyouimplementSTPoverUDP.DonotuseTCPsockets.You
wilnotreceiveanymarkforthisassignmentifyouuseTCPsocket.
2.1LearningObjectives
Oncompletingthisasignmentyouwilgainsuf?cientexpertiseinthefollowingskils:
1.DetailedunderstandingofhowreliabletransportprotocolssuchasTCPfunction.
2.SocketprogramingforUDPtransportprotocol.
3.Protocolandmesagedesign.
3.Overview
Aspartofthisasignment,youwilhavetoimplementSimpleTransportProtocol(STP),apieceof
softwarethatconsistsofasenderandreceivercomponentthatalowsreliableunidirectionaldata
transfer.STPincludessomeofthefeaturesoftheTCPprotocolsthataredescribedinsections3.5.4
and3.5.6ofthetextbook(6thedition).YouwiluseyourSTPprotocoltotransfersimpletext
Updatestotheasignment,includinganycorrectionsandclari?cations,wilbepostedonthe
subjectwebsite.Pleasemakesurethatyoucheckthesubjectwebsiteregularlyforupdates.
2
(ASCII)files(examplesprovidedontheasignmentwebpage)fromthesendertothereceiver.You
shouldimplementSTPastwoseparateprograms:SenderandReceiver.Youonlyhaveto
implementunidirectionaltransferofdatafromtheSendertotheReceiver.AsilustratedinFigure1,
datasegmentswilflowfromSendertoReceiverwhileACKsegmentswilflowfromReceiverto
Sender.Letusreiteratethis,STPmustbeimplementedontopofUDP.DonotuseTCPsockets.If
youuseTCPyouwilnotreceiveanymarksforyourasignment.
Youwilfinditusefultoreviewsections3.5.4and3.5.6ofthetext.Itmayalsobeusefultoreview
thebasicconceptsofreliabledatatransferfromsection3.4.
4.AsignmentSpecifications
Thissectiongivesdetailedspecificationsoftheasignment.Therearetwoversionsofthis
asignment,astandardversion(withatotalof15marks)andanextendedversion(withatotalof
17marksofwhich2marksarebonusmarks).Thespecificationsfortheextendedversioncanbe
foundinSection5ofthespecification.Notethatthebonusmarksmaynotbeproportionaltothe
amountofextraworkthatyouwilhavetodo.Theyaretheretoencourageyoutogobeyondthe
standardasignment.Thebonusmarkscanbeusedtomakeupforlostmarksinthelabexercises
andthesecondasignmentbutNOTforanyoftheexams(mid-sesionandfinal).
4.1FileNames
Themaincodeforthesenderandreceivershouldbecontainedinthefollowingfiles:sender.c,
orSender.javaorsender.py,andreceiver.corReceiver.javaorreceiver.py.
Youarefreetocreateadditionalfilessuchasheaderfilesorotherclasfilesandnamethemasyou
wish.
4.2ListoffeaturesprovidedbytheSenderandReceiver
YouarerequiredtoimplementthefollowingfeaturesintheSenderandReceiver:
1.Athree-wayhandshake(SYN,SYN+ACK,ACK)fortheconnectionestablishment.TheACK
sentbythesendertoconcludethethree-wayhandshakeshouldnotcontainanypayload(i.e.data).
SeSection3.5.6forfurtherdetails.
2.Thefour-segmentconnectiontermination(FIN,ACK,FIN,ACK).TheSenderwilinitiatethe
Figure 1: The basic setup of your asignment. A file is to be transfered from the Sender to the
Receiver. Sender wil run on the sender side while Receiver wil run on the receiver side. Note that data
segments wil flow from the sender to receiver, while ACK segments wil flow from the receiver to
sender.
Data
Ack
Sender Receiver
UDPSocket1
Let OS pick the port number
UDPSocket2
RECEIVER_PORT specified as argument
3
connectioncloseoncetheentirefilehasbeensuccesfullytransmited.SeSection3.5.6forfurther
details.
3.Sendermustmaintainasingle-timerfortimeoutoperation(Section3.5.4ofthetext).
4.SendershouldimplementalthefeaturesmentionedinSection3.5.4ofthetext,withthe
exceptionofdoublingthetimeout.TheSTPprotocolmustincludethesimplifiedTCPsender
(Figure3.33ofthetext)andfastretransmit(pages247-248).Youwilneedtouseanumberof
conceptsthatwehavediscussedinclas,e.g.,sequencenumbers,cumulativeacknowledgements,
timers,buffers,etc.forimplementingyourprotocol.
5.ReceivershouldimplementthefeaturesmentionedinSection3.5.4ofthetext.However,youdo
notneedtofollowTable3.2forACKgeneration.Alpacketsshouldbeimediately
acknowledged,i.e.youdonothavetoimplementdelayedACKs.
6.STPisabyte-streamorientedprotocol.Youwilneedtoincludesequencenumberand
acknowledgementnumberfieldsintheSTPheaderforeachsegment.Themeaningofsequence
numberandacknowledgmentnumberarethesameasTCP.
7.MS(Maximumsegmentsize)isthemaximumnumberofbytesofdatathatyourSTPsegment
cancontain.Inotherwords,MScountsdataONLYanddoesNOTincludeheader.Sendermustbe
abletodealwithdiferentvaluesofMS.ThevalueofMSwilbesuppliedtoSenderasaninput
argument.
8.AnotherinputargumentforSenderisMaximumWindowSize(MWS).MWSisthemaximum
numberofun-acknowledgedbytesthattheSendercanhaveatanytime.ScountsONLYdata.
HeaderlengthshouldNOTbecountedaspartofMWS.
Remarks:NotethatTCPdoesnotexplicitlydefineamaximumwindowsize.InTCP,themaximum
numberofun-acknowledgedbytesislimitedbythesmallerofreceivewindowandthecongestion
controlwindow.Sinceyouwilnotbeimplementingfloworcongestioncontrol,youwilbelimiting
thenumberofun-acknowledgedbytesbyusingtheMWSparameter.Inotherwords,youwilneed
toensurethatduringthelifetimeoftheconnection,thefollowingconditionissatisfied:
?LastByteSent–LastByteAcked≤MWS
10.EventhoughyouwiluseUDPsincethesenderandreceiverwilmostlyberunningon
machinesthatarewithincloseproximityofeachother(e.g.:onthesameEthernetLANorevenon
thesamephysicalmachine),therewilbenorealpossibilityofdatagramsbeingdropped.Inorder
totestthereliabilityofyourprotocol,itisimperativetointroduceartificialyinducedpacketloss
anddelays.ForthispurposeyoumustalsoimplementaPacketLossandDelay(PLD)Moduleas
partoftheSenderprogram.Thedetailsforthismoduleareexplainedlaterinthespecification.
Remarks:Forthestandardversionoftheassignment,thePLDmodulewilonlyneedtodrop
packetswhileforextendedversion,thePLDmodulewilneedtodropanddelaypackets.For
simplicity,IhavechosentocallbothofthemthePLDmodule,eventhoughthePLDmoduleforthe
standardversiondoesnotdelaypackets.
11.Youmustuseaconstanttimeoutinyourprogram.Thevalueofthetimeoutwilbesuppliedto
Senderasaninputargument.Notethat,thisrequirementappliestothestandardversionofthe
asignment.Theextendedversionhasadiferentrequirement.
4.3Featuresexcluded
ThereareanumberoftransportlayerfeaturesadoptedbyTCPthatareexcludedfromthis
asignment:
4
1.Youdonotneedtoimplementtimeoutestimationunlesyouwanttoatempttheextended
versionoftheasignment.
2.Youdonotneedtodoubletimeoutintervalunlesyouwanttoatempttheextendedversion
oftheasignment.
3.Youdonotneedtoimplementanyflownorcongestioncontrol.
4.STPdoesnothavetodealwithcorruptedpackets.Packetswilveryrarelybecorruptedinour
testtopology,ifatal.Inshort,itissafeforyoutoasumethatpacketsareonlylost.
4.4PacketheaderandMS
Indesigningthesegmentheader,youonlyneedtoincludethefieldsthatyouthinkarenecesaryfor
STP.YoucandrawinspirationfromTCPbuttheexactformatoftheSTPpacketheaderisforyou
todecide.Theheaderportioncanincludeasmanyfieldsasyouthinkarenecesary.Twoimportant
fieldsthatwilbeneededarethesequencenumberandacknowledgementnumber.Youwilalso
needanumberofflagsforconnectionestablishmentandteardown.
ThedataportionmustnotcontainmorethanMSbytesofdata.YoumustusethesameSTP
segmentformatfordatatransferaswelasfortheacknowledgementsflowingbackfromthe
receivertothesender.Theonlydiferencewilbethattheacknowledgementsegmentswilnot
containanydata.Alinformationthatisnecesaryfortheproperfunctioningofyourprotocolmust
beprovidedintheSTPheaders.YoushouldnotuseanyinformationfromtheheaderoftheUDP
datagramthatwilencapsulatetheSTPpackets.
4.5Sender
ThissectionprovidesdetailsontheSender.
Forthestandardversionoftheasignment,theSendershouldaceptthefollowingeight(8)
arguments(notethatthelasttwoargumentsareusedexclusivelybythePLDmodule):
1.receiver_host_ip:theIPaddresofthehostmachineonwhichtheReceiverisrunning.
2.receiver_port:theportnumberonwhichReceiverisexpectingtoreceivepacketsfrom
thesender.
3.file.txt:thenameofthetextfilethathastobetransferredfromsendertoreceiverusing
yourreliabletransportprotocol.
4.MWS:themaximumwindowsizeusedbyyourSTPprotocolinbytes.
5.MSS:MaximumSegmentSizewhichisthemaximumamountofdata(inbytes)carriedin
eachSTPsegment.
6.timeout:thevalueoftimeoutinmiliseconds.
ThefollowingtwoargumentsareusedexclusivelybythePLDmodule:
7.pdrop:theprobabilitythataSTPdatasegmentwhichisreadytobetransmitedwillbe
dropped.Thisvaluemustbebetwen0and1.Forexampleifpdrop=0.5,itmeansthat
50%ofthetransmitedpacketsaredroppedbythePLD.
8.seed:Thesedforyourrandomnumbergenerator.Theuseofsedwilbeexplainedin
Section4.5.2ofthespecification.
TheSendershouldbeinitiatedasfollows:
IfyouuseJava:
5
javaSenderreceiver_host_ipreceiver_portfile.txtMWSMStimeoutpdropsed
IfyouuseC:
./senderreceiver_host_ipreceiver_portfile.txtMWSMSStimeoutpdropseed
IfyouusePython:
pythonsender.pyreceiver_host_ipreceiver_portfile.txtMWSMSStimeoutpdrop
seed
Notethat,youshouldfirststarttheReceiverbeforeinitiatingtheServer.
4.5.1ThePLDModule
ThePLDmoduleshouldbeimplementedaspartofyourSenderprogram.ThefunctionofthePLD
istoemulatesomeoftheeventsthatcanoccurintheInternetsuchaslossofpacketsanddelays.
EventhoughtheoreticalyUDPpacketswilgetlostanddelayedontheirown,inourtest
environmenttheseeventswiloccurveryrarely.FurthertotestthereliabilityofyourSTPprotocol
wewouldliketobeabletocontrolthepercentageofpacketsbeinglost.Asmentionedbefore,the
PLDmoduleforthestandardversionofthisasignmentwilonlydropthepacket.
ThefollowingdescribesthesequenceofstepsthatthePLDshouldperformonreceivingaSTP
segment:
1.IftheSTPsegmentisforconnectionestablishmentorteardown,thenpasthesegmentto
UDP,donotdropit.
Remark:Inordertoreducethecomplexityofconnectionsetup,theconnectionestablishment
andteardownsegmentsfromtheSendercanbypassthePLDmoduleandwilnotbedropped.
2.IftheSTPsegmentisnotforconnectionestablishmentorteardown,thePLDmustdooneof
thefollowing:
(a)withprobabilitypdropdropthedatagram.
(b)Withprobability(1-pdrop),forwardthedatagram.
Toimplementthissimplygeneratearandomnumberbetwen0and1.Ifthechosennumber
isgreaterthanpdroptransmitthepacket,elsethepacketisdropped.
Remark:ThefilePingServer.javainLabExercise2containsanexampleofrandomly
droppingpackets.
OncethePLDisreadytotransmitaSTPsegment,theSendershouldencapsulatetheSTPsegment
inaUDPdatagram(i.e.createaUDPdatagramwiththeSTPsegmentasthepayload).Itshould
thentransmitthisdatagramtotheReceiverthroughtheUDPsocketcreatedearlier.(Usethe
RECEIVER_HOST_IPandRECEIVER_PORTasthedestinationIPaddresandportnumber
respectively).Oncetheentiretextfilehasbeentransmitedreliably(i.e.thesenderwindowis
emptyandthefinalACKisreceived)theSendercanclosetheUDPsocketandterminatethe
program.
NotethattheACKsegmentsfromthereceivermustcompletelybypasthePLDmodules.Inother
words,ACKsegmentsareneverlost.
4.5.2Sedforrandomnumbergenerators
YouwilbeaskedtorunyourSenderandReceiverpairtoshowusthattheyarerunningcorrectly,
seSection8ofthespecificationfortheexperimentsthatyouneedtoconduct.Inorderforusto
6
checkyourresults,wewilbeaskingyoutoinitialiseyourrandomnumbergeneratorwithaspecific
sedinSection8sothatwecanrepeatyourexperiments.
Ifyouhavenotlearntabouttheprinciplesbehindrandomnumbergenerators,youneedtoknowthat
randomnumbersareinfactgeneratedbyadeterministicformulabyacomputerprogram.
Therefore,strictlyspeaking,randomnumbergeneratorsarecaledpseudo-randomnumber
generatorsbecausethenumbersarenottrulyrandom.Thedeterministicformulaforrandom
numbergenerationinPython,JavaandCusesaninputparametercaledaseed.Ifthesamesedis
used,thenthesamesequenceofrandomnumberswilbeproduced.
ThefollowingcodefragmentinPython,JavaandCwilgeneraterandomnumbersbetwen0and1
usingasuppliedsed.
1.InPython,youinitialisearandomnumbergenerator(asumingthesedis50)byusing
random.seed(50);.Afterthatyoucangeneratearandomfloatingpointnumberbetwen
(0,1)byusingrandom.random();
2.InJava,youinitalisearandomnumbergenerator(asumingthesedis50)byusingRandom
random=newRandom(50);.Afterthat,youcangeneratearandomfloatingpoint
numberbetwen(0,1)byusingfloatx=random.nextFloat();
3.InC,youinitalisearandomnumbergenerator(asumingtheseedis50)byusing
srand(50);.Afterthat,youcangeneratearandomfloatingpointnumberbetwen(0,1)by
usingfloatx=rand()/((float)(RAND_MAX)+1);Notethat,RAND_MAXisthe
maximumvaluereturnedbytherand()function.
Youwilfindthatifyouspecifydiferentseds,adiferentsequenceofpseudo-randomnumbers
wilbeproduced.
4.5.3AditionalrequirementsforSender
YourSenderwilreceiveacknowledgementsfromtheReceiverthroughthesamesocket,whichthe
senderusestotransmitdata.TheSendermustfirstextracttheSTPacknowledgementfromtheUDP
datagramthatitreceivesandthenprocesitaspertheoperationofyourSTPprotocol.Theformat
oftheacknowledgementsegmentsshouldbeexactlythesameasthedatasegmentsexceptthatthey
shouldnotcontainanydata.NotethattheseacknowledgementsshouldbypasthePLDmodule.
ThesendershouldmaintainalogfiletitledSender_log.txtwhereitrecordstheinformation
abouteachsegmentthatitsendsandreceives.Informationaboutdroppedsegments(anddelayed
segmentsincaseoftheextendedasignment)packetsshouldalsobeincluded.Starteachentryona
newline.Theformatshouldbeasfollows:
|
|