計算機網絡(自頂向下方法)配套課件Chapter3_第1頁
計算機網絡(自頂向下方法)配套課件Chapter3_第2頁
計算機網絡(自頂向下方法)配套課件Chapter3_第3頁
計算機網絡(自頂向下方法)配套課件Chapter3_第4頁
計算機網絡(自頂向下方法)配套課件Chapter3_第5頁
已閱讀5頁,還剩113頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

Chapter3

TransportLayerComputerNetworking:ATopDownApproach

4thedition.

JimKurose,KeithRoss

Addison-Wesley,July2007.

Anoteontheuseofthesepptslides:We’remakingtheseslidesfreelyavailabletoall(faculty,students,readers).They’reinPowerPointformsoyoucanadd,modify,anddeleteslides(includingthisone)andslidecontenttosuityourneeds.Theyobviouslyrepresentalotofworkonourpart.Inreturnforuse,weonlyaskthefollowing:Ifyouusetheseslides(e.g.,inaclass)insubstantiallyunalteredform,thatyoumentiontheirsource(afterall,we’dlikepeopletouseourbook!)Ifyoupostanyslidesinsubstantiallyunalteredformonawwwsite,thatyounotethattheyareadaptedfrom(orperhapsidenticalto)ourslides,andnoteourcopyrightofthismaterial.Thanksandenjoy!JFK/KWRAllmaterialcopyright1996-2007J.FKuroseandK.W.Ross,AllRightsReserved1TransportLayerChapter3:TransportLayerOurgoals:

understandprinciplesbehindtransportlayerservices:multiplexing/demultiplexingreliabledatatransferflowcontrolcongestioncontrollearnabouttransportlayerprotocolsintheInternet:UDP:connectionlesstransportTCP:connection-orientedtransportTCPcongestioncontrol2TransportLayerVocabularyandTermTransport(傳輸/運輸)Multiplex/De-multiplex(多路復用/多路分流)UDP(UserDatagramProtocol)

(用戶數據報協(xié)議)TCP(TransmissionControlProtocol)

(傳輸控制協(xié)議)Reliability(Error/Loss)

Control(可靠性(差錯/丟失)控制)QoS(QualityofService)(服務質量)Segments(報文段)datagram(數據報/報文段)Packet(包/分組)3TransportLayerChapter3outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol4TransportLayerTcessesrunningondifferenthoststransportprotocolsruninendsystems

sendside:breaksappl.messagesintosegments,passestonetworklayerreceiverside:re-assemblessegmentsintomessages,passestoapplicationlayermorethanonetransportprotocolavailabletoapplicationsInternet:TCPandUDPapplicationtransportnetworkdatalinkphysicalapplicationtransportnetworkdatalinkphysicallogicalend-endtransport5TransportLayerTworklayertransportlayer:

logicalcommunicationbetweenprocesses

relieson,enhances,networklayerservices

networklayer:

logicalcommunicationbetweenhosts6TransportLayerTworklayerHouseholdanalogy:12kidssendinglettersto12kidsprocesses=kidsapplicationmessages=lettersinenvelopeshosts=housestransportprotocol=AnnandBillnetwork-layerprotocol=postalservice7TransportLayerInternettransport-layerprotocolsreliable,in-orderdelivery:TCPcongestioncontrolflowcontrolconnectionsetupunreliable,unordereddelivery:UDPno-frillsextensionof“best-effort”IPservicesnotavailable:delayguaranteesbandwidthguaranteesapplicationtransportnetworkdatalinkphysicalnetworkdatalinkphysicalnetworkdatalinkphysicalnetworkdatalinkphysicalnetworkdatalinkphysicalnetworkdatalinkphysicalnetworkdatalinkphysicalapplicationtransportnetworkdatalinkphysicallogicalend-endtransport8TransportLayerChapter3outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol9TransportLayerMultiplexingAppl.1Port1UDPAppl.2Port2Appl.NPortNIPUDPdatagramtransmit10TransportLayerDe-multiplexingUDPIPUDPdatagramarrivesAppl.1Appl.2Appl.NPort1Port2PortN11TransportLayerMultiplexing/demultiplexingapplicationtransportnetworklinkphysicalP1applicationtransportnetworklinkphysicalapplicationtransportnetworklinkphysicalP2P3P4P1host1host2host3=process=socketdeliveringreceivedsegmentstocorrectsocketDemultiplexingatrcvhost:gatheringdatafrommultiplesockets,envelopingdatawithheader(fordemultiplexing)Multiplexingatsendhost:12TransportLayerHowde-multiplexingworkshostreceivesIPdatagramseachdatagramhassourceIPaddress,destinationIPaddresseachdatagramcarries1transport-layersegmenteachsegmenthassource,destinationportnumberhostusesIPaddresses&portnumberstodirectsegmenttoappropriatesocketsourceport#destport#32bitsapplicationdata(message)otherheaderfieldsUDPdatagram/segmentformat13TransportLayerConnectionlessdemultiplexingCreatesocketswithportnumbers:DatagramSocketmySocket1=newDatagramSocket(12534);DatagramSocketmySocket2=newDatagramSocket(12535);UDPsocketidentifiedbytwo-tuple:(IPaddress,portnumber)WhenhostreceivesUDPsegment:checksdestinationportnumberinsegmentdirectsUDPsegmenttosocketwiththatportnumberIPdatagramswithdifferentsourceIPaddressesand/orsourceportnumbersdirectedtosamesocket14TransportLayerConnectionlessdemuxltiplexingDatagramSocketserverSocket=newDatagramSocket(6428);ClientIP:BP2clientIP:AP1P1P3serverIP:CSP:6428DP:9157SP:9157DP:6428SP:6428DP:5775SP:5775DP:6428SPprovides“returnaddress”15TransportLayerConnection-orienteddemuxltiplexingTCPsocketidentifiedby4-tuple:sourceIPaddresssourceportnumberdestinationIPaddressdestinationportnumberreceivehostusesallfourvaluestodirectsegmenttoappropriatesocketSocketClientSocket=newSocket("hostname",6789)SocketconnectionSocket=welcomeSocket.accept()16TransportLayerConnection-orienteddemuxltiplexingServerhostmaysupportmanysimultaneousTCPsockets:eachsocketidentifiedbyitsown4-tupleWebservershavedifferentsocketsforeachconnectingclientnon-persistentHTTPwillhavedifferentsocketforeachrequest17TransportLayerConnection-orienteddemux(cont.)ClientIP:BP1clientIP:AP1P2P4serverIP:CSP:9157DP:80SP:9157DP:80P5P6P3D-IP:CS-IP:AD-IP:CS-IP:BSP:5775DP:80D-IP:CS-IP:B18TransportLayerConnection-orienteddemux:ThreadedWebServerClientIP:BP1clientIP:AP1P2serverIP:CSP:9157DP:80SP:9157DP:80P4P3D-IP:CS-IP:AD-IP:CS-IP:BSP:5775DP:80D-IP:CS-IP:B19TransportLayerChapter3outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol20TransportLayerWhyisthereaUDP?Simplenoconnectionstateatsender,receiverEfficientsmallsegmentheaderQuick(啟動快)noconnectionestablishment(whichcanadddelay)nocongestioncontrol(傳輸快)UDPcanblastawayasfastasdesiredApplicationshaveBettercontroloverwhatandwhentosent21TransportLayerUDP:UserDatagramProtocol[RFC768]“nofrills,”“barebones”Internettransportprotocol“besteffort”service,UDPsegmentsmaybe:lostdeliveredoutofordertoappconnectionless:nohandshakingbetweenUDPsender,receivereachUDPsegmenthandledindependentlyofothersWhyisthereaUDP?noconnectionestablishment(whichcanadddelay)simple:noconnectionstateatsender,receiversmallsegmentheadernocongestioncontrol:UDPcanblastawayasfastasdesired22TransportLayerUDP:moreoftenusedforstreamingmultimediaappslosstolerantratesensitiveotherUDPusesDNSSNMPreliabletransferoverUDP:addreliabilityatapplicationlayerapplication-specificerrorrecovery!sourceport#destport#32bitsApplicationdata(message)UDPsegmentformatlengthchecksumLength,inbytesofUDPsegment,includingheader23TransportLayerMultiplexingMultiplexing(多路復用)MultipleapplicationsusingonetransportprotocolIdentifyapplicationusingportnumber(ApplicationAddressing)

UDP

TCP

111

161

69

25

21

23

RPC

SNMP

TFTP

SMTP

FTP

TELNET

IP

24TransportLayerPortnumberandProtocolnumberDeterminethehigherlayerprotocoltransportnetworkTCPUDPProtocol

NumbersIP17625TransportLayerPortswell-knownPorts(眾所周知端口,公共端口)0~1023ReservedforstandardpublicserviceAlreadyallocated:1~1000RegisteredPorts(注冊端口)1024~49151Registered:1025~48619Dynamic/PrivatePorts(私有端口)Notforpublicuse49152~6553526TransportLayerPortsAllocationAllocationAuthority/assignments/port-numbers(lastupdated26March2008)27TransportLayerUDPchecksumSender:treatsegmentcontentsassequenceof16-bitintegerschecksum:addition(1’scomplementsum)ofsegmentcontentssenderputschecksumvalueintoUDPchecksumfieldReceiver:computechecksumofreceivedsegmentcheckifcomputedchecksumequalschecksumfieldvalue:NO-errordetectedYES-noerrordetected.Butmaybeerrorsnonetheless?Morelater….Goal:detect“errors”(e.g.,flippedbits)intransmittedsegment28TransportLayerInternetChecksumExampleNoteWhenaddingnumbers,acarryoutfromthemostsignificantbitneedstobeaddedtotheresultExample:addtwo16-bitintegers1111001100110011011101010101010101110111011101110111101110111011110010100010001000011wraparoundsumchecksum29TransportLayerHomework&ExtensiveReadingReviews:4Problems:130TransportLayerChapter3Outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol31TransportLayerTCP:Overview

point-to-pointonesender,onereceiversend&receivebuffers

reliable,in-orderbytestreamno“messageboundaries”pipelinedTCPcongestionandflowcontrolsetwindowsizesocketdoorTCPsendbufferTCPreceivebuffersocketdoorsegmentapplicationwritesdataapplicationreadsdata32TransportLayerTCPfullduplex(全雙工)databi-directionaldataflowinsameconnectionconnection-orientedhandshaking(exchangeofcontrolmsgs)initiatessender,receiverstatebeforedataexchangeflowcontrolledsenderwillnotoverwhelm(淹沒)

receiversocketdoorTCPsendbufferTCPreceivebuffersocketdoorsegmentapplicationwritesdataapplicationreadsdata33TransportLayerRFC:793,1122,1323,2001,2018,2581

RF793TransmissionControlProtocolJ.Postel.September1981.RFC2001TCPSlowStart,CongestionAvoidance,FastRetransmit,andFast

RecoveryAlgorithms.

W.Stevens.January1997RFC2018TCPSelectiveAcknowledgmentOptionsM.Mathis,J.Mahdavi,S.Floyd,A.Romanow,October1996.RFC2581TCPCongestionControlM.Allman,V.Paxson,W.Stevens.April1999.34TransportLayerTCPScientistTCP/IPInventor1970:Cerf,V.,Carr,C.,Crocker,S.,Kahn,R.-NetworkControlProtocol,"Host-hostCommunicationProtocolintheARPANetwork“,AFIPSProceedingsofSJCC.IEEETrans.onCommunicationTechnology,197435TransportLayer36TransportLayerTCPScientistActiveQueueManagementTCP-FriendlycongestioncontrolHigh-PerformanceTCPSallyFloydLixiaZhangTCPTimers37TransportLayerChapter3outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol38TransportLayerVocabularyandTermReliability(Error/Loss)

Control可靠性(差錯/丟失)控制FlowControl(流量控制)CongestionControl(擁塞控制)Acknowledge(ACK)確認Pipeline(流水線)RoundTripTime(RTT)往返時間Expire失效SlidingWindow

滑動窗口39TransportLayerTCPsegmentstructuresourceport#destport#32bitsapplicationdata(variablelength)sequencenumberacknowledgementnumberReceivewindowUrgdatapointerchecksumFSRPAUheadlennotusedOptions(variablelength)StartbyteinbytestreamsNextBytethereceiverexpectsForvariablelengthwithoptionsIt’sanACK.ACK#isValidSynchronize:initiateconnectionUrgentData:transmitimmediatelyPush(ImportantData):delivertoapp.quicklyDataFinished:teardowntheconnectionFatalError:Resettheconnection#bytesreceiver

iswilling

toaccept.UsedforflowcontrolInternet

checksum

(asinUDP)locationofthelastbyteof

urgentdataLikeMSS(MaximumSegmentSize)40TransportLayerTCPSequenceNo.’sandACKsSeq.#’s:bytestream“number”offirstbyteinsegment’sdataACKs:Seq#ofnextbyteexpectedfromothersideCumulative(累計)

ACKQ:howreceiverhandlesout-of-ordersegmentsA:TCPspecificationdoesn’tsay,-uptoimplementor(實現者)

HostAHostBSeq=42,ACK=79,data=‘C’Seq=79,ACK=43,data=‘C’Seq=43,ACK=80Usertypes‘C’hostACKsreceiptofechoed‘C’hostACKsreceiptof‘C’,echoesback‘C’timesimpletelnetscenario41TransportLayerWindowsize=1

Sender

ReceiverTCPSimple-ACKTCPSimple-ACKWindowsize=1

Sender

ReceiverSend1Receive1TCPSimple-ACKWindowsize=1

Sender

ReceiverSend1Receive1ReceiveACK2SendACK2TCPSimple-ACKWindowsize=1

Sender

ReceiverSend1Receive1ReceiveACK2SendACK2Send2Receive2TCPSimple-ACKWindowsize=1

Sender

ReceiverSend1Receive1ReceiveACK2SendACK2Send2Receive2ReceiveACK3SendACK3TCPSimple-ACKWindowsize=1

Sender

ReceiverSend1Receive1ReceiveACK2SendACK2Send2Receive2ReceiveACK3SendACK3Send3Receive3Windowsize=1

Sender

ReceiverSend1Receive1ReceiveACK2SendACK2Send2Receive2ReceiveACK3SendACK3Send3Receive3ReceiveACK4SendACK4TCPSimple-ACKPipelinedprotocolsPipelining:senderallowsmultiple,“in-flight”,yet-to-be-acknowledgedbytes/packetsrangeofsequencenumbersmustbeincreasedbufferingatsenderandreceiver49TransportLayerPipelining:increasedutilizationfirstpacketbittransmitted,t=0senderreceiverRTTlastbittransmitted,t=L/Rfirstpacketbitarriveslastpacketbitarrives,sendACKACKarrives,sendnextpacket,t=RTT+L/Rlastbitof2ndpacketarrives,sendACKlastbitof3rdpacketarrives,sendACKIncreaseutilizationbyafactorof3!50TransportLayerSourcePortDest.Port…Sequence#Acknowledgement#SourceDest.Seq.Ack.102823101TCP:seq.#’sandACKsData:40Bsent#10-#49.TCP:seq.#’sandACKsgot

#10-#49,nowIneed#50.SourcePortDest.Port…Sequence#Acknowledgement#102823SourceDest.10Seq.1Ack.102823SourceDest.50Seq.1Ack.sent#10-#49.Data:40BSourcePortDest.Port…Sequence#Acknowledgement#102823SourceDest.50Seq.2Ack.102823SourceDest.10Seq.1Ack.102823SourceDest.50Seq.1Ack.TCP:seq.#’sandACKsData:70BNowsent

#50-#119.SourcePortDest.Port…Sequence#Acknowledgement#102823SourceDest.50Seq.2Ack.102823SourceDest.10Seq.1Ack.102823SourceDest.50Seq.1Ack.102823SourceDest.120Seq.2Ack.TCP:seq.#’sandACKsData:70Bgot

#10-#119,nowIneed

#120.sent#50-#119.TCPRoundTripTimeandTimeoutQ:howtosetTCPtimeoutvalue?longerthanRTTbutRTTvariestooshort:prematuretimeoutunnecessaryretransmissionstoolong:slowreactiontosegmentloss55TransportLayerTCPRoundTripTimeandTimeoutQ:howtoestimateRTT?SampleRTT:measuredtimefromsegmenttransmissionuntilACKreceiptignoreretransmissionsSampleRTTwillvary,wantestimatedRTT“smoother”averageseveralrecentmeasurements,notjustcurrentSampleRTT56TransportLayerTCPRoundTripTimeandTimeoutEstimatedRTT=(1-)*EstimatedRTT+*SampleRTTExponentialWeightedMovingAverage(EWMA)(指數加權移動平均)influenceofpastsampledecreasesexponentiallyfasttypicalvalue:=0.12557TransportLayerExampleRTTestimation:58TransportLayerTCPRoundTripTimeandTimeoutSettingthetimeoutEstimtedRTTplus“safetymargin”largevariationinEstimatedRTT->largersafetymarginfirstestimateofhowmuchSampleRTTdeviatesfromEstimatedRTT:TimeoutInterval=EstimatedRTT+4*DevRTTDevRTT=(1-)*DevRTT+

*|SampleRTT-EstimatedRTT|(typically,=0.25)

Thensettimeoutinterval:59TransportLayerTCPRoundTripTimeandTimeoutTimeoutInterval=EstimatedRTT+4*DevRTTDevRTT=(1-)*DevRTT+*|SampleRTT-EstimatedRTT|

Thensettimeout(expiration)interval:EstimatedRTT=(1-)*EstimatedRTT+*SampleRTT60TransportLayerChapter3Outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4

Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol61TransportLayer

TCP

Transmission

State62TransportLayerTCPreliabledatatransferTCPcreatesrdtserviceontopofIP’sunreliableservicePipelinedsegmentsCumulativeAcksTCPusessingleretransmissiontimerRetransmissionsaretriggeredby:timeouteventsduplicateAcksInitiallyconsidersimplifiedTCPsender:ignoreduplicateAcksignoreflowcontrol,congestioncontrol63TransportLayerTCPsenderevents:Datareceivedfromapplication:Createsegmentwithseq#seq#isbyte-streamnumberoffirstdatabyteinsegment(報文段)starttimerifnotalreadyrunning(thinkoftimerasforoldestunackedsegment)expirationinterval:TimeOutInterval(超時間隔)64TransportLayerTCPsenderevents:timeout:retransmitsegmentthatcausedtimeoutrestarttimerAckreceived:Ifacknowledgespreviouslyunackedsegmentsupdatewhatisknowntobeackedstarttimerifthereareoutstandingsegments65TransportLayerTCP

sender

(simplified)

NextSeqNum=InitialSeqNumSendBase=InitialSeqNum

loop(forever){

switch(event)

event:datareceivedfromapplicationabovecreateTCPsegmentwithsequencenumberNextSeqNumif(timercurrentlynotrunning)starttimerpasssegmenttoIPNextSeqNum=NextSeqNum+length(data)

event:timertimeoutretransmitnot-yet-acknowledgedsegmentwithsmallestsequencenumberstarttimer

event:ACKreceived,withACKfieldvalueofyif(y>SendBase){SendBase=yif(therearecurrentlynot-yet-acknowledgedsegments)starttimer}

}/*endofloopforever*/

Comment:SendBase-1:lastcumulatively

ack’edbyteExample:SendBase-1=71;

y=73,sothercvr

wants73+;

y>SendBase,so

thatnewdatais

acked66TransportLayerTCP:retransmissionscenariosHostASeq=92,8bytesdataACK=100losstimeoutlostACKscenarioHostBXSeq=92,8bytesdataACK=100timeSendBase=10067TransportLayerTCP:retransmissionscenariosHostASeq=100,20bytesdataACK=100timeprematuretimeout(過早超時)HostBSeq=92,8bytesdataACK=120Seq=92,8bytesdataSeq=92timeoutACK=120Seq=92timeoutSendBase=120SendBase=120Sendbase=10068TransportLayerTCPretransmissionscenarios(more)HostASeq=92,8bytesdataACK=100losstimeoutCumulativeACKscenarioHostBXSeq=100,20bytesdataACK=120timeSendBase=12069TransportLayerTCPAckgeneration

[RFC1122,RFC2581]EventatReceiverArrivalofin-ordersegmentwithexpectedseq#.Alldatauptoexpectedseq#alreadyACKedArrivalofin-ordersegmentwithexpectedseq#.OneothersegmenthasACKpendingArrivalofout-of-ordersegmenthigher-than-expectseq.#.GapdetectedArrivalofsegmentthatpartiallyorcompletelyfillsgapTCPReceiveractionDelayedACK.Waitupto500msfornextsegment.Ifnonextsegment,sendACKImmediatelysendsinglecumulativeACK,ACKingbothin-ordersegmentsImmediatelysendduplicateACK,indicatingseq.#ofnextexpectedbyteImmediatesendACK,providedthatsegmentstartsatlowerendofgap70TransportLayerFastRetransmitTime-outperiodoftenrelativelylong:longdelaybeforeresendinglostpacketDetectlostsegmentsviaduplicate(冗余)

Acks.Senderoftensendsmanysegmentsback-to-backIfsegmentislost,therewilllikelybemanyduplicateACKs.71TransportLayerFastRetransmitIfsenderreceives3Acksforthesamedata,itsupposesthatsegmentafterAckeddatawaslost:fastretransmit:

resendsegmentbeforetimerexpires72TransportLayerFastRetransmit73TransportLayer

event:ACKreceived,withACKfieldvalueofyif(y>SendBase){SendBase=yif(therearecurrentlynot-yet-acknowledgedsegments)starttimer}else{incrementcountofdupACKsreceivedforyif(countofdupACKsreceivedfory=3){resendsegmentwithsequencenumbery}

Fastretransmitalgorithm:aduplicateACKforalreadyACKedsegmentfastretransmit74TransportLayerGo-Back-NSender:k-bitseq#inpktheader“window”ofuptoN,consecutiveunack’edpktsallowedACK(n):ACKsallpktsupto,includingseq#n-“cumulativeACK”mayreceiveduplicateACKs(seereceiver)timerforeachin-flightpkttimeout(n):retransmitpktnandallhigherseq#pktsinwindow75TransportLayerGBNin

action76TransportLayerGo-Back-N:strength“window”ofuptoN,consecutiveunack’edpktsallowednextseqnum:smallestunusedsequencenumberACK(n):ACKsallpktsupto,

includingseq#n

-

“cumulativeACK”ReduceACKmessages,goodthroughput!77TransportLayerGo-Back-N:weakpointsnextseqnum:smallestunusedsequencenumberACK(n):ACKsallpktsupto,includingseq#n-“cumulativeACK”timerforeachin-flightpkttimeout(n):retransmitpktnandallhigherseq#pktsinwindowLOSTRe-transmit78TransportLayerSelectiveRepeatreceiverindividuallyacknowledgesallcorrectlyreceivedpktsbufferspkts,asneeded,foreventualin-orderdeliverytoupperlayersenderonlyresendspktsforwhichACKnotreceivedsendertimerforeachunACKedpktsenderwindowNconsecutiveseq#’sagainlimitsseq#sofsent,unACKedpkts79TransportLayerSelectiverepeat:sender,receiverwindows80TransportLayerSelectiverepeatdatafromabove:ifnextavailableseq#inwindow,sendpkttimeout(n):resendpktn,restarttimerACK(n)in[sendbase,sendbase+N]:markpktnasreceivedifnsmallestunACKedpkt,advancewindowbasetonextunACKedseq#senderpktnin[rcvbase,rcvbase+N-1]sendACK(n)out-of-order:bufferin-order:deliver(alsodeliverbuffered,in-orderpkts),advancewindowtonextnot-yet-receivedpktpktnin[rcvbase-N,rcvbase-1]ACK(n)otherwise:

ignorereceiver81TransportLayerSelectiverepeatinaction82TransportLayerHomework&ExtensiveReadingReviews:5,6Problems:2283TransportLayerChapter3Outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol84TransportLayerTCPFlowControlreceivesideofTCPconnectionhasareceivebuffer:applicationprocessmaybeslowatreadingfrombuffer85TransportLayerTCPFlowControlspeed-matchingservice:matchingthesendratetothereceivingapplication’sdrain(排干)

rate!senderwon’toverflowreceiver’sbufferbytransmittingtoomuch,toofastflowcontrol86TransportLayerTCPFlowcontrol:howitworks(SupposeTCPreceiverdiscardsout-of-ordersegments)spareroominbuffer=RcvWindow=RcvBuffer-[LastByteRcvd-LastByteRead]ReceiveradvertisesspareroombyincludingvalueofRcvWindowinsegmentsSenderlimitsunACKeddatatoRcvWindowguaranteesreceivebufferdoesn’toverflow87TransportLayerChapter3outline3.1Transport-layerservices3.2Multiplexinganddemultiplexing3.3Connectionlesstransport:UDP3.4Principlesofreliabledatatransfer3.5Connection-orientedtransport:TCPsegmentstructurereliabledatatransferflowcontrolconnectionmanagement3.6Principlesofcongestioncontrol3.7TCPcongestioncontrol88TransportLayerTCPConnectionManagementRecall:TCPsender,receiverestablish“connection”beforeexchangingdatasegmentsinitializeTCPvariables:seq.#s【ISN,InitialSequenceNumber】buffers,flowcontrolinfo(e.g.RcvWindow)client:connectioninitiator

SocketclientSocket=newSocket("hostname","portnumber");

connect(server,destPort)

server:contactedbyclient

SocketconnectionSocket=welcomeSocket.accept();89TransportLayerTCPConnectionManagementSYN,SEQ=xSYN,SEQ=y,ACK=x+1SYN,SEQ=x+1,ACK=y+1Threewayhandshake:Step1:

clienthostsendsTCPSYNsegmenttoserverspecifiesinitialseq#nodataStep2:

serverhostreceivesSYN,replieswithSYNACKsegmentserverallocatesbuffersspecifiesserverinitialseq.#Step3:clientreceivesSYNACK,replieswithACKsegment,whichmaycontaindata90TransportLayerTCPConnectionManagement(cont.)Closingaconnection:clientclosessocket:

clientSocket.close();

Step1:

clientendsystemsendsTCPFINcontrolsegmenttoserver

Step2:

serverreceivesFIN,replieswithACK.Closesconnection,sendsFIN.clientFINserverACKACKFINclosecloseclosedtimedwait91TransportLayerTCPConnectionManagement(cont.)S

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論