高级计算机网络 传输层协议详解

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Lecture5:TheTransportLayer(InternetTransportProtocols)AdvancedComputerNetworkYangQinDepartmentofComputerScienceShenzhenGraduateSchoolHarbinInstituteofTechnologyLayer4:TheTransportLayerAnOverviewofLayer4TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Layer4:TheTransportLayerTheTCP/IPProtocolStackIPisaLayer3protocolandTCPisaLayer4protocol.TCPisconnection-orientedandensuresreliabilitybutIPisconnection-lesswithbesteffortattemptsatdelivery.Flowcontrolandreliabilityofthetransportlayercanbecomparedtoastudentwhostudiesonlyoneyearofaforeignlanguage,thenvisitsthecountrythatusesthatlanguage.Wheneverthestudenttriestojoinaconversation,heorshehastoaskeveryone,frequently,torepeathis/herwords(reliability)andtospeakslowly(flowcontrol).TCP:connection-orientedreliabledividesoutgoingmessagesintosegmentsreassemblesmessagesatthedestinationstationre-sendsanythingnotreceivedUDP:connectionlessunreliabletransmitmessagesprovidesnosoftwarecheckingforsegmentdelivery(unreliable)doesnotreassembleincomingmessagesusesnoacknowledgmentsprovidesnoflowcontrolLayer4:TheTransportLayerLayer4:TheTransportLayerAnOverviewofLayer4TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Anapplication:NATandPATTCPServiceModelApplicationsaccessTCPservicesthrough“sockets”Socketispresentedas“(IPaddress,port)”Everyconnectionisexpressedas(socketsource,socketdestination),whichisapoint-to-pointfull-duplexchannelTCPdoesnotsupportmulticastandbroadcastBothTCPandUDPuseportnumberstokeeptrackofdifferentconversationsthatcrossthenetworkatthesametimeApplicationsoftwaredevelopershaveagreedtousethewell-knownportnumbersthataredefinedinRFC1700TCPServiceModelPortnumbersbelow255arereservedforTCPandUDPpublicapplications.Originatingsourceportnumbersaredynamicallyassignedbythesourcehost.Usually,itisanumberlargerthan1023.SequenceandacknowledgmentnumbersisnecessaryforTCPtotracksincetwosuccessiveIPpacketsmayinmanyinstancesNOTtravelthesamepathandarriveatthedestinationhostoutoforder.TCPServiceModelProblemsmustbesolvedinTCP:ReliabletransferFlowcontrolSlidingwindowcongestionavoidance…ConnectionmanagementEstablishconnection:threehandshakesReleaseconnection:fourhandshakesTCPProtocolTCPSegmentHeaderFielddefinitionsintheTCPsegment:sourceport-numberofthecallingportdestinationport-numberofthecalledportsequencenumber-numberusedtoensurecorrectsequencingofthearrivingdata,32bitsacknowledgmentnumber-nextexpectedTCPoctet,32bitsTCPheaderlength(HLEN)–numberof32-bitwordsintheheaderreserved-settozero,6bitscodebits-controlfunctions(suchassetupandterminationofasession)window-numberofoctetsthatthesenderiswillingtoacceptchecksum-calculatedchecksumoftheheaderanddatafieldsurgentpointer-indicatestheendoftheurgentdataoption-oneoption-maximumTCPsegmentsizedata-upper-layerprotocoldataTCPProtocolCodeBits:URG:workwiththeurgencypointertosendtheurgencydataACK:thissegmentisanACKsegmentPSH:Nodatacachewilldoneinbothsourceanddestinationhost.DatawillbesendorreceiveimmediatelyRST:resettheconnectionbecauseofthefaultsunabletoberecoveredSYN:indicateconnectionestablishingFIN:indicateconnectionreleasingTCPProtocolHostsexchangedatabyusingsegment(TPDU)betweeneachotherEachsegmenthasaheaderof20bytes(exceptoptionalparts)and0ormoredatabytesThesizeofthesegmentmustbematchedwithIPpackets,andalsomustsatisfythedemandofbottomlayers.Forexample,theMTU(MaximalTransferUnit)ofEthernetis1500bytesEachbytehasa32bitssequencenumberSlidingwindowprotocolisusedinTCPtocontrolthedataflow.Intheprotocol,thesequencenumberoftheACKsegmentisjustthesequencenumberoughttobereceivedTCPConnectionManagementRecall:TCPsender,receiverestablish“connection”beforeexchangingdatasegmentsinitializeTCPvariables:seq.#sbuffers,flowcontrolinfo(e.g.RcvWindow)client:connectioninitiatorSocketclientSocket=newSocket(hostname,portnumber);server:contactedbyclientSocketconnectionSocket=welcomeSocket.accept();Threewayhandshake:Step1:clienthostsendsTCPSYNsegmenttoserverspecifiesinitialseq#nodataStep2:serverhostreceivesSYN,replieswithSYNACKsegmentserverallocatesbuffersspecifiesserverinitialseq.#Step3:clientreceivesSYNACK,replieswithACKsegment,whichmaycontaindataTCP:EstablishConnectionSetupconnection:threehandshakesServer:executesLISTENandACCEPTprimitive,andmonitorspassivelyClient:executesCONNECTprimitive,generateaTCPsegmentwithSYN=1andACK=0,whichstandsforconnectionrequestThefirsthandshakeTCP:EstablishConnectionServerreceivestheTCPsegmentandcheckifthereisserviceprocessmonitoringtherequiredport.Ifnoneprocessismonitoringtheport,answeraTCPsegmentwithRST=1Ifthereisanyserviceprocessmonitoringtheport,theprocesscandeciderejectoraccepttheconnectionrequestIfaccepttheconnection,sendaTCPsegmentwithSYN=1andACK=1toacknowledgetheconnection,andrequesttheconnectiontotheotherside(thesecondhandshake)Whenreceivestheacknowledgement,theclientwillsendasegmentwithSYN=0andACK=1toacknowledgetheconnection(thethirdhandshake)Athree-wayhandshake/openconnectionsequencesynchronizesaconnectionatbothendsbeforethetransferreddatareachest

1 / 63
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功