計算機網(wǎng)絡(luò)自頂向下Chapter3_第1頁
計算機網(wǎng)絡(luò)自頂向下Chapter3_第2頁
計算機網(wǎng)絡(luò)自頂向下Chapter3_第3頁
計算機網(wǎng)絡(luò)自頂向下Chapter3_第4頁
計算機網(wǎng)絡(luò)自頂向下Chapter3_第5頁
已閱讀5頁,還剩105頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

第3章運輸層

運輸層要解決什么問題?

?IP層協(xié)議主機之間傳遞數(shù)據(jù)報

?IP地址只標識主機,并不區(qū)分應(yīng)用程序或哪個用戶,

-?區(qū)分應(yīng)用程序或用戶——

端到端的運輸層協(xié)議來完成的

2<A金

Chapter3outline

3.1Transport-layerservices

3.2Connectionlesstransport:UDP

3.3Principlesofreliabledatatransfer

3.4Corniection-orientedtransport:TCP

3.4.1segmentstructure

3.4.2connectionmanagement

3.4.3reliabledatatransfer

3.4.4flowcontrol

3.4.5congestioncontrol

3<A金

3.1Transport-layerservices

?providelogicalcommunicationbetweenapp

processesrunningondifferenthosts

4transportprotocolsruninendsystems

>sendside:breaksappmessagesintosegments,

passestonetworklayer

>revside:reassemblessegmentsintomessages,

passestoapplayer

?morethanonetransportprotocolavailabletoapps

>Internet:TCPandUDP

logicalcommunication

hostAhostB

router1router2

APAP

AP

------------IP協(xié)議的作用范圍--------

運輸層協(xié)議TCP和UDP的作用范圍a

3.1Transport-layerservices

Transportvs.networklayer

?networklayer:logicalcommunicationbetweenhosts

?transportlayer:logicalcommunicationbetweenprocesses

>reliesonfenhances,networklayerservices

Householdanalogy:

12kidssendinglettersto12kids

?processes=kids

?appmessages=lettersinenvelopes

?hosts=houses

?transportprotocol=AnnandBill

?network-layerprotocol=postalservice

3.1Transport-layerservices6<A金

Internettransport-layerprotocols

?reliable,in-orderdelivery:TCP

>congestioncontrol

>flowcontrol

>connectionsetup

?unreliable,unordereddelivery:UDP

>no-frillsextensionof%'best-effort/,IP

?servicesnotavailable:

>delayguarantees

>bandwidthguarantees

?Multiplexing/demultiplexing

3.1Transport-layerservices7<A金

Multiplexing/demultiplexing

Multiplexingatsendhost:Demultiplexingatrevhost:

gatheringdatafrommultiplesockets,deliveringreceivedsegments

envelopingdatawithheadertocorrectsocket

(laterusedfordemultiplexing)

3.1Transport-layerservices8

Howdemultiplexingworks

?hostreceivesIPdatagrams

>eachdatagramhassource

IPaddress,destinationIP<-------------32bits--------------->

addresssourceport#destport#

>eachdatagramcarries1

transport-layersegmentotherheaderfields

>eachsegmenthassource,

destinationportnumber

(recall:well-knownportapplication

data

numbersforspecific(message)

applications)

?hostusesIPaddresses&port

numberstodirectsegmenttoTCP/UbPsegmentformat

appropriatesocket

3.1Transport-layerservices9

port

?為每個需要通信的應(yīng)用程序分配一個通訊端口(Port),在

TCP/IP中,其值為1?216,用于唯一標識一個進程;

?端口的分配有:

?熟知端口,數(shù)值一般為。?1023。

>登記端口號,數(shù)值為1024?49151,為沒有熟知端口號的應(yīng)用程序

使用的。使用這個范圍的端口號必須在IANA登記,以防止重復。

>客戶端口號或短暫端口號,數(shù)值為49152?65535,留給客戶進程選

擇暫時使用。當服務(wù)器進程收到客戶進程的報文時,就知道了客戶進

程所使用的動態(tài)端口號。通信結(jié)束后,這個端口號可供其他客戶進程

以后使用。

3.1Transport-layerservices1。

Chapter3outline

3.1Transport-layerservices

3.2Connectionlesstransport:UDP

3.3Principlesofreliabledatatransfer

3.4Connection-orientedtransport:TCP

>segmentstructure

>connectionmanagement

>reliabledatatransfer

>flowcontrol

>congestioncontrol

UDP:UserDatagramProtocol[RFC768]

?"nofrills,”“barebones55Internettransportprotocol

?“besteffort99service,UDPsegmentsmaybe:

>lost

>deliveredoutofordertoapp

?connectionless:

>nohandshakingbetweenUDPsender,receiver

>eachUDPsegmenthandledindependentlyofothers

WhyisthereaUDP?

?noconnectionestablishment(whichcanadddelay)

?simple:noconnectionstateatsender,receiver

?smallsegmentheader(8:20)

?nocongestioncontrol:UDPcanblastawayasfastasdesired

3,2Connectionlesstransport:UDP12

面向報文的UDP

?發(fā)送方UDP對應(yīng)用程序交下來的報文,在添加首部后就向下交付IP層。

UDP對應(yīng)用層交下來的報文,既不合并,也不拆分,而是保留這些報文的

邊界。

?應(yīng)用層交給UDP多長的報文,UDP就照樣發(fā)送,即一次發(fā)送一個報文。

?接收方UDP對IP層交上來的UDP用戶數(shù)據(jù)報,在去除首部后就原封不動

地交付上層的應(yīng)用進程,一次交付一個完整的報文。

?應(yīng)用程序必須選擇合適大小的報文。

applicationlayermessageapplicationlayer

UDPheaderUDPseqementdataTransportlayer

IPheaderIPpacketdataNetworklayer

13

UDP:more

?oftenusedforstreaming32bits

multimediaapps

sourceport#destport#

>losstolerantLength,in

bytesofUbP^^lengthchecksum

>ratesensitivesegment,

?otherUDPusesincluding

>DNSheader

>SNMPApplication

?reliabletransferoverUDP:data

addreliabilityatapplication(message)

layer

>application-specificUbPsegmentformat

errorrecovery!

(rememberitzlatercomparewithTCP)

3,2Connectionlesstransport:UDP14

UDPsegment

UDPSourcePort(16)UDPDestinationPort(16)

MessageLength(16)UDPChecksum(16)

DATA

UDP偽首部

SourceIPAddress(32)

DestinationIPAddress(32)

Zero(8)Protocol(8)UDPLength(16)

?Protocol—協(xié)議類型,UDP:17;

?UDPLength—首部+數(shù)據(jù)區(qū)的總長度,不包括偽首部。

?注意:偽首部并不包括在UDP報文中,使用偽首部是為了驗證UDP是否到達

正確的目的端:當目的端收到UDP包后,計算出校驗和,當與UDP包中校驗

和相同時,則說明該UDP包到達了正確的主機和正確的端口。

3.2Connectionlesstransport:UDPis

Example:UDPchecksum(檢驗和)

1001100100010011一153.19

040000100001101000一8.104

12字節(jié)

偽首部,11010101100000011->171.3

全017150000111000001011一14.11

8字節(jié)10:57130000000000010001一0和17

UDP首部”15全00000000000001111一15

0000010000111111一1087

7字節(jié)datadatadatadata

0000000000001101一13

數(shù)據(jù)datadatadata全0

0000000000001111一15

填條0000000000000000一0(檢驗和)

0101010001000101—>data

0101001101010100—>data

0100100101001110—>data

0100011100000000—>data,0(填充)

按二進制反碼運算求和1001011011101101一求和得出的結(jié)果

將得出的結(jié)果求反碼0110100100010010一檢驗和

Chapter3outline

3.1Transport-layerservices

3.2Connectionlesstransport:UDP

3.3Principlesofreliabledatatransfer

3.4Connection-orientedtransport:TCP

>segmentstructure

>connectionmanagement

>reliabledatatransfer

>flowcontrol

>congestioncontrol

17

3.3Principlesofreliabledatatransfer

3.3.1stop-and-waitprotocol

AB

?在發(fā)送完一個分組后,必須暫時保留

已發(fā)送的分組的副本。

?分組和確認分組都必須進行編號。

⑻無差錯情況?超時計時器的重傳時間應(yīng)當比數(shù)據(jù)在

分組傳輸?shù)钠骄禃r間更長一些。

確認丟失和確認遲到

(a)確認丟失(b)確認遲到

3.3Principlesofreliabledatatransfer19

可靠通信的實現(xiàn)

?使用上述的確認和重傳機制,我們就可以在不

可靠的傳輸網(wǎng)絡(luò)上實現(xiàn)可靠的通信。

?這種可靠傳輸協(xié)議常稱為自動重傳請求ARQ

(AutomaticRepeatreQuest)。

?ARQ表明重傳的請求是自動進行的。接收方

不需要請求發(fā)送方重傳某個出錯的分組。

3.3Principlesofreliabledatatransfer20

信道利用率

?停止等待協(xié)議的優(yōu)點是簡單,但缺點是信道利用

率太低。

3.3Principlesofreliabledatatransfer21

流水線(Pipeline)傳輸

?發(fā)送方可連續(xù)發(fā)送多個分組,不必每發(fā)完一個分組就停

頓下來等待對方的確認。

?由于信道上一直有數(shù)據(jù)不間斷地傳送,這種傳輸方式可

獲得很高的信道利用率。

3.3Principlesofreliabledatatransfer22

3.3.2連續(xù)ARQ協(xié)議

發(fā)送窗口

1|2|3|4|5%7|8|9|10|H|12

(a)發(fā)送令維持發(fā)送窗口(發(fā)送窗口是5)

發(fā)送窗口「口

??向刖

12|3|4|5|67|8|9|10|H|12

(b)收到二了確及后發(fā)送窗口向前滑動

噬獻

發(fā)送

確認

按序

送確

到達

發(fā)

最后

典±■

分<

為r

使

現(xiàn)

溫馨提示

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

評論

0/150

提交評論