版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
OSILayer4:
TransportLayerOSILayer4:TransportLayerAnoverviewoflayer4
TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Anapplication:NATandPATLayer4performsmultiplefunctions:segmentingupper-layerapplicationdataestablishingend-to-endoperationssendingsegmentsfromoneendhosttoanotherFlowcontrolandreliabilitycanbecomparedtotalkingtoaforeigner.Oftenyouwouldasktheforeignertorepeathis/herwords(reliability)andtospeakslowly(flowcontrol)OSILayer4:TransportLayer
TwoparticularlyimportantLayer4protocols:
TransmissionControlProtocol(TCP)UserDatagramProtocol(UDP)Layer4:TheTransportLayerDivideoutgoingmessagesintosegmentsReassemblemessagesatthedestinationstationTCP:reliableConnection-orientedSoftwarecheckingforsegmentRe-sendanythinglostorerrorUsesacknowledgmentsProvidesflowcontrolUDP:
unreliable
connectionless
providesnosoftwarecheckingforsegmentusesnoacknowledgmentsprovidesnoflowcontrolLayer4:TheTransportLayerBothTCPandUDPuseport
tokeeptrackofdifferentconversationsthatcrossthenetworkatthesametimeApplicationsoftwaredevelopershaveagreedtousethewell-knownportnumbersthataredefinedinRFC1700
Portnumbersbelow255arereservedforTCPandUDPpublicapplications.ServiceModelSocketispresentedas(IP_address,port)Everyconnectionisexpressedas(socketsource,socketdestination),whichisapoint-to-pointfull-duplexchannelDoesnotsupportmulticastandbroadcastSocketLayer4:TheTransportLayerAnoverviewoflayer4TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Anapplication:NATandPATTCPServiceModelProblemsmustbesolvedinTCP:ReliabletransferFlowcontrolSlidingwindowcongestionavoidance…ConnectionmanagementEstablishconnection:threehandshakesReleaseconnection:fourhandshakesTCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充源端口和目的端口字段——各占2字節(jié)端口是運(yùn)輸層與應(yīng)用層的服務(wù)接口運(yùn)輸層的復(fù)用和分用功能都要通過端口才能實現(xiàn)TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充序號字段——占4字節(jié)TCP傳送的數(shù)據(jù)流中的每一個字節(jié)都編上一個序號序號字段的值指本報文段所發(fā)送的數(shù)據(jù)的第一個字節(jié)的序號TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充確認(rèn)號字段——占4字節(jié),是期望收到對方的下一個報文段的數(shù)據(jù)的第一個字節(jié)的序號TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充數(shù)據(jù)偏移(即首部長度)——占4位指出TCP報文段的數(shù)據(jù)起始處距TCP報文段的起始處的長度單位是32位字(以4字節(jié)為計算單位)TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充保留字段——占6位,保留為今后使用,目前置0TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充緊急URG1時,表明緊急指針字段有效告訴系統(tǒng)此報文段中有緊急數(shù)據(jù),應(yīng)盡快傳送(相當(dāng)于高優(yōu)先級的數(shù)據(jù))
TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充ACK1時確認(rèn)號字段有效ACK0時確認(rèn)號字段無效TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充推送PSH(PuSH)——接收TCP收到PSH=1的報文段,就盡快地交付接收應(yīng)用進(jìn)程,而不再等到整個緩存都填滿了后再向上交付TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充復(fù)位RST(ReSeT1時,表明TCP連接中出現(xiàn)嚴(yán)重差錯(如由于主機(jī)崩潰或其他原因),必須釋放連接,然后再重新建立運(yùn)輸連接TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充同步SYN=1表示這是一個連接請求或連接接受報文TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充終止FIN(FINis)——用來釋放一個連接。FIN1表明此報文段的發(fā)送端的數(shù)據(jù)已發(fā)送完畢,并要求釋放運(yùn)輸連接。TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充窗口字段——占2字節(jié),用來讓對方設(shè)置發(fā)送窗口的依據(jù),單位為字節(jié)。TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充檢驗和——占2字節(jié)。檢驗和字段檢驗的范圍包括首部和數(shù)據(jù)這兩部分TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充緊急指針字段——占16位,指出在本報文段中緊急數(shù)據(jù)共有多少個字節(jié)(緊急數(shù)據(jù)放在本報文段數(shù)據(jù)的最前面)
TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG比特08162431填充TCP最初只有一種選項,即最大報文段長度MSS(MaximumSegmentSize)MSS告訴對方緩存所能接收的報文段的數(shù)據(jù)字段的最大長度是MSS個字節(jié)數(shù)據(jù)字段加上TCP首部才等于整個的TCP報文段。TCP首部20字節(jié)固定首部目的端口數(shù)據(jù)偏移檢驗和選項(長度可變)源端口序號緊急指針窗口確認(rèn)號保留FINSYNRSTPSHACKURG位08162431填充填充字段——這是為了使整個首部長度是4字節(jié)的整數(shù)倍。TCPProtocolHostsexchangedatabyusingsegment(TPDU)Eachsegmenthas:aheaderof20bytes(exceptoptionalparts)
0ormoredatabytesThesizeofthesegmentmustbematchedwithIPpackets,andalsomustsatisfythedemandofbottomlayersForexample,theMTU(MaximalTransferUnit)ofEthernetis1500bytesEachbytehasa32bitssequencenumberReliableConnection?
Two-armyProblem
TCP:EstablishConnectionSYN=1,seq=xClosedClosedActiveopenPassiveopenABClientServerTheFirstHandshakeServer:executesLISTEN
andACCEPTprimitive,andmonitorspassivelyClient:executesCONNECTprimitive,generateaTCPsegmentwithSYN=1andACK=0,whichstandsforconnectionrequestSYN=1,seq=xSYN=1,ACK=1,seq=y,ack=x1TheSecondHandshakeServerchecksifexistsserviceprocessmonitoringtheportIfnoneprocess,answeraTCPsegmentwithRST=1Ifexistsprocess,decidestorejectortoaccepttherequestIfaccepttheconnectionrequest,sendasegmentwithSYN=1andACK=1ClosedClosedActiveopenPassiveopenABClientServer
TCP:EstablishConnectionSYN=1,seq=xACK=1,seq=x+1,ack=y1SYN=1,ACK=1,seq=y,ack=x1TheThirdHandshakeTheclientsendsasegmentwithSYN=0andACK=1
toacknowledgetheconnectionClosedClosedActiveopenPassiveopenABClientServer
TCP:EstablishConnectionSYN=1,seq=xACK=1,seq=x+1,ack=y1DataTransferSYN=1,ACK=1,seq=y,ack=x1Whentheserverreceivestheacknowledgement,itinformstheupperlayerapplications
TCP:EstablishConnectionClosedClosedActiveopenPassiveopenABClientServerSYN-SENTESTAB-LISHEDSYN-RCVDLISTENESTAB-LISHEDSYN=1,seq=xACK=1,seq=x+1,ack=y1DataTransferSYN=1,ACK=1,seq=y,ack=x1
TCP:EstablishConnectionClosedClosedActiveopenPassiveopenABClientServerExample:EstablishConnection
TCPATCPB1.CLOSEDLISTEN2.SYN-SENT--><SEQ=100><CTL=SYN>-->SYN-RECEIVED3.ESTABLISHED<--<SEQ=300><ACK=101><CTL=SYN,ACK><--SYN-RECEIVED4.ESTABLISHED--><SEQ=101><ACK=301><CTL=ACK>-->ESTABLISHED5.ESTABLISHED--><SEQ=101><ACK=301><CTL=ACK><DATA>-->ESTABLISHEDBasic3-WayHandshakeforConnectionSynchronizationNotethattheACKdoesnotoccupysequencenumberspace(ifitdid,wewouldwindupACKingACK's!)Datatransfer
——stop-and-waitprotocol(a)NoerrorASend
M1ACK
M1BSend
M2Send
M3ACKM2ACK
M3ASend
M1BResend
M1Send
M2ACK
M1Disposethesegment(b)OutoftimettttDatatransfer
——stop-and-waitprotocolAftersendingasegment,preserveabackuptemporarilyEachsegmentandACKmusthaveIDTheresend-timemustbemorethanaverage-travel-time*2stop-and-waitprotocolisasimpleprotocol,buthaspoorefficiencyDatatransfer
——LostACKandLateACKASend
M1BOutoftimeResendM1SendM2DisposetherepeatedM1andresendACKM2(a)LostACKACK
M1ASend
M1BOutoftimeResendM1Send
M2DisposetherepeatedM1andresendACKM1(b)LateACKACKM1ReceivethelateACKanddonothingttttReliableCommunicationARQ(AutomaticRepeatreQuest)。Itmeansthe‘resendrequest’isautomaticallysentandthereceiverneednotrequestthesendertoresendtheerrorsegmentContiguousARQProtocol123456789101112(a)發(fā)送方維持發(fā)送窗口(發(fā)送窗口是5)發(fā)送窗口(b)收到一個確認(rèn)后發(fā)送窗口向前滑動向前123456789101112發(fā)送窗口SegmentttACKFIN=1,seq=uESTAB-LISHEDCLOSEDDataTransferESTAB-LISHEDTCP:ReleaseConnectionActiveClosePassiveCloseABClientServerFIN=1,seq=uACK=1,seq=v,ack=u1ESTAB-LISHEDDataTransferESTAB-LISHEDActiveCloseInformUpperLayerABClientServerTCP:ReleaseConnectionFIN=1,seq=uACK=1,seq=v,ack=u1FIN=1,ACK=1,seq=w,ack=u1PassiveCloseDataTransferESTAB-LISHEDDataTransferESTAB-LISHEDActiveCloseInformUpperLayerABClientServerTCP:ReleaseConnectionFIN=1,seq=uACK=1,seq=v,ack=u1FIN=1,ACK=1,seq=w,ack=u1ACK=1,seq=u+1,ack=w1TCP:ReleaseConnectionPassiveCloseDataTransferESTAB-LISHEDDataTransferESTAB-LISHEDActiveCloseInformUpperLayerABClientServerCLOSEDACK=1,seq=u+1,ack=w1FIN=1,seq=uACK=1,seq=v,ack=u1FIN=1,ACK=1,seq=w,ack=u1FIN-WAIT-1CLOSE-WAITFIN-WAIT-2LAST-ACKWait
2MSLTIME-WAITCLOSEDBeforereleasingconnection,theclientmustwaitfor2MSLTCP:ReleaseConnectionPassiveCloseDataTransferESTAB-LISHEDDataTransferESTAB-LISHEDActiveCloseInformUpperLayerABClientServerWhymustwaitfor2MSL?ToensurethelastACKsentbyAcanreachBTopreventanyinvalidconnectionrequestsegmentfromemergingAfterwaitingfor2MSL,wecanmakesurethatallsegmentsontheconnectionhavedisappearedT
C
P
的
有
限
狀
態(tài)
機(jī)CLOSEDESTABLISHEDLISTENCLOSE_WAITFIN_WAIT_1SYN_RCVDFIN_WAIT_2CLOSINGTIME_WAITSYN_SENTLAST_ACK主動打開被動打開被動關(guān)閉主動關(guān)閉起點被動打開主動打開發(fā)送SYN同時打開收到SYN,發(fā)送SYN,ACK收到ACK數(shù)據(jù)傳送階段
關(guān)閉發(fā)送FIN
關(guān)閉發(fā)送FIN
關(guān)閉發(fā)送FIN收到RST
收到SYN發(fā)送SYN,ACK
關(guān)閉或超時收到ACK
收到SYN,ACK發(fā)送ACK收到ACK收到ACK收到FIN發(fā)送ACK收到FIN,ACK
發(fā)送ACK收到FIN發(fā)送ACK同時關(guān)閉收到FIN發(fā)送ACK發(fā)送SYN定時經(jīng)過兩倍報文段壽命后關(guān)閉Layer4:TheTransportLayerAnOverviewofLayer4TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Anapplication:NATandPATUDP(UserDatagramProtocol)WhydoweneedUDP?Noconnectionestablishment(whichcanadddelay)Simple:noconnectionstateatsender,receiverSmallsegmentheaderNocongestioncontrol:UDPcanblastawayasfastasdesiredUDP(UserDatagramProtocol)Connectionless:nohandshakingbetweenUDPsender,receivereachUDPsegmenthandledindependentlyofothersOftenusedforstreamingmultimediaapplicationslosstolerantratesensitiveUDPareusedin:RIP:TosendtherouteinformationperiodicallyDNS:AvoidthedelaytosetuptheTCPconnectionSNMP:Whencongestion,SNMPmuststillrunable.Withoutthecongestionandreliabilitycontrolmechanism,UDPhasbetterperformancethanTCPunderthecircumstances.OtherprotocolsincludeTFTP,DHCPAddreliabilityatapplicationlayerifnecessaryUDP(UserDatagramProtocol)Layer4:TheTransportLayerAnOverviewofLayer4TCP(TransmissionControlProtocol)UDP(UserDatagramProtocol)Anapplication:NATandPATNAT,istheprocessofswappingoneaddressforanotherintheIPpacketheaderInpractice,NATisusedtoallowhoststhatareprivatelyaddressedtoaccesstheInternetOneofsolutionstoIPaddressdepletionConservesregistered(legal)addressesIncreasesFlexibilitywhenconnectingtoInternetRFC1631-
NetworkAddressTranslator(NAT)WhatisNAT?NATasimpleconceptPrivateaddresses
Registeredaddresses
NATtypesStaticNAT: FixedmappingofaninternaladdresstoanregisteredaddressDynamicNAT: Mappingisdonedynamicallyonafirstcomefirst
servedbasisPAT(Overload):
Portaddresstranslationisusedtoallowmanyinternaluserstoshareasingle‘insideglobal’
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 橋梁建設(shè)干挖法施工作業(yè)方案
- 助產(chǎn)人員培訓(xùn)與管理制度
- 小學(xué)生愛國主義教育心理輔導(dǎo)方案
- 青島飛洋職業(yè)技術(shù)學(xué)院《人工智能原理與應(yīng)用》2023-2024學(xué)年第一學(xué)期期末試卷
- 青島濱海學(xué)院《數(shù)字化版面設(shè)計ndesgn》2023-2024學(xué)年第一學(xué)期期末試卷
- 秦皇島工業(yè)職業(yè)技術(shù)學(xué)院《人工智能科學(xué)計算》2023-2024學(xué)年第一學(xué)期期末試卷
- 黔西南民族職業(yè)技術(shù)學(xué)院《中小學(xué)綜合實踐活動》2023-2024學(xué)年第一學(xué)期期末試卷
- 黔南民族職業(yè)技術(shù)學(xué)院《文本設(shè)計》2023-2024學(xué)年第一學(xué)期期末試卷
- 城市公共設(shè)施消防應(yīng)急預(yù)案方案
- 高校防災(zāi)減災(zāi)應(yīng)急響應(yīng)方案
- 工程建設(shè)監(jiān)理收費標(biāo)準(zhǔn)(發(fā)改價格【2007】670號)
- 摩托車品牌文化營銷與品牌故事的構(gòu)建
- 2024江蘇南京大數(shù)據(jù)集團(tuán)有限公司招聘筆試參考題庫附帶答案詳解
- FZT 73032-2017 針織牛仔服裝
- 企業(yè)并購與資產(chǎn)重組智慧樹知到期末考試答案2024年
- 貨物包裝承諾函
- 治療用碘131I化鈉膠囊-臨床用藥解讀
- 2024人教版五年級上冊數(shù)學(xué)期末口算題訓(xùn)練
- 2024外研版初中英語單詞表匯總(七-九年級)中考復(fù)習(xí)必背
- 安徽省合肥市包河區(qū)2023-2024學(xué)年三年級上學(xué)期期末英語試卷
- 勞動爭議調(diào)解仲裁法
評論
0/150
提交評論