




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
TCP/IP協(xié)議原理網(wǎng)絡(luò)工程系通信與信息:
wPhone:
61830521
(O)Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/232Introduction應(yīng)用的需求:reliability傳輸大量的數(shù)據(jù),要求可靠的通信服務(wù)自身的可靠性機(jī)制弱底層網(wǎng)絡(luò)和IP網(wǎng)絡(luò)是不可靠、無連接投遞TCPProcess-to-process
comm.:
same
withUDPToadd
connection-oriented
and
reliabilityfeatures
to
the
services
of
IP?TCP/IP
Protocol
Suite2020/11/233理解TCP的功能提供process-to-process
communication在IP層上建立起:可靠的,順序的(reliable,sequential)分組傳輸服務(wù)面向連接的通信Error-control源端到目的端的流量控制(flow-control
)To
prevent
a
fast
source
of
packets
fromoverwhelming
a
slowsinkAdaptive
bandwidth
sharing
in
the
network→congestion
control?TCP/IP
Protocol
Suite2020/11/234TCP的功能ResponsibilitiesTo create
a
process-to-process
communication使用兩個端點(diǎn)地址(IP+端
)通信To
providea
flow-control
and
error-controlmechanism
at
the
transport
layerError
control:
ARQ
→
Window
based
controlAcknowledgement
packetTime-outRetransmissionFlow
control:
sliding
window
protocol
→
Window
basedcontrolTo provide
a
congestion
control:
sliding
windowprotocolTo
provide
a
connection
mechanism
for
theprocesses?TCP/IP
Protocol
Suite2020/11/235OverviewIPLANsMANsWANsICMPIGMPARPRARPNetworkLayerNetworkAccess
LayerTransmission
Control
Protocol,TCPRFC
793,傳輸控制協(xié)議ApplicationLayerTCPUDP?TCP/IP
Protocol
Suite2020/11/236TransportLayerProcess-to-process
Communication端口、端點(diǎn)概念與方式與UDP完全一樣連接:TCP上通信雙方抽象的虛電路連接80Port:
80416250Endpoint:
(,
80)Connection:
(,
80)
and
(4,16250)?TCP/IP
Protocol
Suite2020/11/237Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/238TCP
ServicesStream
delivery
service(流交付服務(wù))Full-duplex
service(全雙工服務(wù))Connection-oriented
serviceReliable
service?TCP/IP
Protocol
Suite2020/11/239理解:Stream
Delivery與UDP交付區(qū)別:進(jìn)程把預(yù)先定義好邊界的一組報(bào)文(用戶數(shù)據(jù)報(bào))發(fā)送給UDPUDP對這些報(bào)文中的每一個添加首部,傳遞給
IP傳輸U(kuò)DP和IP都無法識別這些數(shù)據(jù)報(bào)之間是否存在任何關(guān)系——獨(dú)立處理每一個數(shù)據(jù)報(bào)?TCP/IP
Protocol
Suite2020/11/2310TCP
Services:Stream
Delivery
ServiceStream
delivery
service
requires:Sending
process
candeliver
data
as
astream
ofbytesReceiving
process
canobtain
data
as
astreamofbytesstream
of
bytes
→進(jìn)程間使用自己認(rèn)為適宜的任何大小的數(shù)據(jù)片進(jìn)行發(fā)送或接收(最小1字節(jié))發(fā)送進(jìn)程 接收進(jìn)程Stream
of
byteTCPTCPTCP
creates
a
environment
in
which
the
two
processes
seem
to
beconnected
by
an
“tube”
that
carriers
their
data
across
the
InternetSending
and
receiving
buffersTCP為什么需要buffer?原因:the
sending
and
the
receiving
processes
may
notnecessarily
write
or
read
data
at
the
samerateTCP要為進(jìn)程構(gòu)建”tube”——“可靠傳輸”流量控制發(fā)送進(jìn)程與接收進(jìn)程產(chǎn)生和消耗數(shù)據(jù)的速率不一致差錯控制2u13TCP
segmentsTCP是如何發(fā)送“字節(jié)流”的?按報(bào)文段(segment)傳輸——Why?報(bào)文段:若干字節(jié)構(gòu)成IP是按分組(Package)處理的(而非字節(jié)流),1個segment就封裝在1個Package上述過程對于接收進(jìn)程是透明的字節(jié)流按照報(bào)文段傳輸?shù)?/p>
:接收方TCP收到報(bào)文段可能失序、損傷、重復(fù),或者丟失!TCP
ServicesStream
delivery
service(流交付服務(wù))Full-duplex
service(全雙工服務(wù))Connection-oriented
serviceReliable
service?TCP/IP
Protocol
Suite2020/11/2314TCP
Services:Full-Duplex
Service全雙工:數(shù)據(jù)可以在同一時間雙向流動每一個TCP都有發(fā)送緩存和接收緩存DataACKPiggybacking捎帶D
an
flow
inboth
direction
atthe
same
time?TCP/IP
Protocol
Suite2020/11/2315TCP
ServicesStream
delivery
service(流交付服務(wù))Full-duplex
service(全雙工服務(wù))Connection-oriented
serviceReliable
service?TCP/IP
Protocol
Suite2020/11/2316TCP
Services:Connection-OrientedService建立連接,使用連接,拆除連接建立的是虛連接(virtualconnection),而非物理連接(physical
connection)封裝成IP分組的TCP報(bào)文段可能走不同的路徑到達(dá)目的地接收到的TCP報(bào)文段可能:亂序、丟失、損壞、重復(fù)而TCP需要向上層按順序交付數(shù)據(jù)IP網(wǎng)絡(luò)?TCP/IP
Protocol
Suite2020/11/2317TCP
ServicesStream
delivery
service(流交付服務(wù))Full-duplex
service(全雙工服務(wù))Connection-oriented
serviceReliable
service?TCP/IP
Protocol
Suite2020/11/2318TCP
Services:Reliable
ServiceReliabilitySequential,
without
error,
and
without
anypart
lostorduplicated如何實(shí)現(xiàn)可靠傳輸?——ARQ(AutomaticRepeat
reQuest)基本思路:接收方:must
continuously
return
acknowledgments(ACK)for
successfully
received
data發(fā)送方:每一個發(fā)送的數(shù)據(jù)都需要接收方的確認(rèn)(ACK)發(fā)送每一個數(shù)據(jù)都需要緩存,并啟動定時器,超時重傳?TCP/IP
Protocol
Suite2020/11/2319Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2320Window
based control
Protocol——基本協(xié)議技術(shù)序號(Sequence
number)確認(rèn)(Acknowledgment)超時重傳機(jī)制窗口滑動(sliding)擴(kuò)展(expanding)縮回(shrinking)關(guān)閉(closing)?TCP/IP
Protocol
Suite2020/11/2321TCPNumbering
Bytes(給字節(jié)
)To
number
all
data
bytes
transmittedin
aconnection
→字節(jié)號,而不是給每個報(bào)文段分配Numbering
is
independentin
each
directionThe
numbering
starts
randomly,
NOT
from
0選取范圍:0
~
232-1某個TCP連接上的某個報(bào)文段的序號(sequence
number)=報(bào)文段中第一個數(shù)據(jù)字節(jié)的字節(jié)號TCPSendingSending
bufferReceiving
bufferReceivingDatestreamSegmentData?TCP/IP
Protocol
Suite2020/11/2322練習(xí)Imagine
a
TCP
connection
is
transferring
a
file
of6000
bytes.
The
byte
is
numbered
10010.What
are
the
sequence
numbers
for
each
segmentfourif
data
is
sent
in
five
segments
with
thesegments
carrying
1,000
bytes
and
the
lastsegment
carrying
2,000
bytes?The
following
shows
the
sequence
number
foreach
segment:Segment
1
→
10,010Segment
2
→
11,010Segment
3
→
12,010Segment
4
→
13,010Segment
5
→
14,010(10,010
to
11,009)(11,010
to
12,009)(12,010
to
13,009)(13,010
to
14,009)(14,010
to
16,009)Sender1301014010100101101012010Seg1
Seg2
Seg3
Seg4Seg5?TCP/IPProtocol
Suite2020/11/2323報(bào)文段的序號報(bào)文段的序號=
報(bào)文段中第一個數(shù)據(jù)字節(jié)的字節(jié)號,那么如果報(bào)文段不攜帶數(shù)據(jù),那么這個報(bào)文段是否需要
?如何
?原則:需要確認(rèn)的報(bào)文,才需要序號?TCP/IP
Protocol
Suite2020/11/2324Window
based control
Protocol——基本協(xié)議技術(shù)序號(Sequence
number)確認(rèn)(Acknowledgment)超時重傳機(jī)制窗口滑動(sliding)擴(kuò)展(expanding)縮回(shrinking)關(guān)閉(closing)?TCP/IP
Protocol
Suite2020/11/2325Acknowledgment
(確認(rèn),ACK)Acknowledgment
number(確認(rèn)號):對已經(jīng)收到的字節(jié)表示確認(rèn)Positive
ACK(肯定確認(rèn))The
number
of
the
next
data
byte
apartyexpects
to
receiveCumulative
ACK(累計(jì)確認(rèn))例如
TCP報(bào)文段中的確認(rèn)號是:1234,意味著:已經(jīng)收到了字節(jié)號=1234的以前的所有字節(jié)希望收到了下一個TCP報(bào)文段的序號=1234?TCP/IP
Protocol
Suite2020/11/2326Discussion例1:
a
segment
with
Seq#
=X, Data
Len=LThen the
Seq#
of
the
next
segment:例2:a
segment
with
Ack#
=XThis
means
all
bytes
from
the
beginning
up
toX-1
has
been
receivedFeatures報(bào)文的順序關(guān)系數(shù)據(jù)流的位置,更便于流的復(fù)原需較大的序號空間(32bit,232→4Gbyte)序號不連續(xù),n1<n2<n3…X+L?TCP/IP
Protocol
Suite2020/11/2327Window
based control
Protocol——基本協(xié)議技術(shù)序號(Sequence
number)確認(rèn)(Acknowledgment)超時重傳機(jī)制窗口滑動(sliding)擴(kuò)展(expanding)縮回(shrinking)關(guān)閉(closing)?TCP/IP
Protocol
Suite2020/11/2328超時重傳機(jī)制發(fā)送方每發(fā)送一個報(bào)文段(Segment),就啟動一個定時器,如果在定時內(nèi),沒有收到對該報(bào)文段的確認(rèn)(ACK),重傳該報(bào)文段發(fā)送方必須緩存已經(jīng)發(fā)送但未收到確認(rèn)的報(bào)文段發(fā)方在定時內(nèi)沒有收到確認(rèn)(ACK),該報(bào)文段損壞或者該報(bào)文段丟失或者ACK丟失?TCP/IP
Protocol
Suite2020/11/2329Window
based control
Protocol——基本協(xié)議技術(shù)序號(Sequence
number)確認(rèn)(Acknowledgment)超時重傳機(jī)制窗口滑動(sliding)擴(kuò)展(expanding)縮回(shrinking)關(guān)閉(closing)?TCP/IP
Protocol
Suite2020/11/2330滑動窗口The
size
of
the
sliding
windows
is
72020/11/23TCP/IP
Protocol
Suite312020/11/23TCP/IP
Protocol
Suite窗口:緩存中一組字節(jié)號(或者報(bào)文序號)的集合——窗口覆蓋了緩存中的一部分單元窗口有左、右兩沿,均可向右滑動落在發(fā)送窗口(sending
window)字節(jié)號可能存在兩部分?jǐn)?shù)據(jù):發(fā)方已發(fā)送但還未收到確認(rèn)的字節(jié)號(或者報(bào)文號)集合發(fā)方可以立即發(fā)送的字節(jié)號(或者報(bào)文號)集合發(fā)送窗口大小Ws= 連續(xù)發(fā)送的最大字節(jié)數(shù)落在接收窗口(receiving
window
)的字節(jié)號:收方希望接收的字節(jié)號(或者報(bào)文號)集合接收窗口大小Wr=允許 接收的最大字節(jié)數(shù)(即接收緩存大?。┳止?jié)號不在發(fā)送窗口的數(shù)據(jù)不能發(fā)送字節(jié)號不在接收窗口的數(shù)據(jù)不能接收通過設(shè)置窗滑動窗口:發(fā)送窗口與接收窗口口大小控制發(fā)送數(shù)據(jù)量發(fā)送窗口與接收窗口接收窗口,rwnd=12020/133發(fā)送窗口24發(fā)送窗口——滑動且大小變化!發(fā)送窗口大小=min(rwnd,
cwnd)rwnd:接收窗口cwnd:擁塞窗口滑動(sliding)——TCP允許隨時改變滑動窗口的大小!擴(kuò)展(expanding):右沿右移允許發(fā)送 的字節(jié)縮回(shrinking):右沿左移回退N協(xié)議關(guān)閉/合攏(closing):左沿右移某些字節(jié)已被確認(rèn),移出窗口2020/11/23TCP/IP
ProtocolSuite35TCP中的滑動窗口既實(shí)現(xiàn)高效的可靠傳輸,又提供了流量控制高效可靠傳輸:發(fā)方在等待確認(rèn)之前,可以發(fā)送多個分組流量控制:端到端:接收方控制發(fā)送窗口的大小→控制發(fā)送速率擁塞控制:路由器超載→擁塞→TCP減小發(fā)送窗口→控制發(fā)送速率6ExampleFigure
shows
an
unrealistic
example
of
a
sliding
window.
Thesender
has
sent
bytes
up
to
202.
We
assume
that
cwnd
is20
(in
reality
this
value
is
thousands
of
bytes).
The
receiverhas
sent
an
acknowledgment
number
of
200
with
anrwnd
of9
bytes
(in
reality
this
value
is
thousands
of
bytes).
The
sizeof
the
sender
window
is
the
minimum
of
rwnd
and
cwnd
or
9bytes.
Bytes
200
to
202
are
sent,
but
not
acknowledged.Bytes
203
to
208
can
be
sent
without
worrying
aboutacknowledgment.
Bytes
209
and
above
cannot
be
sent.Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2337FlowControl(流量控制)TCP采用的流控方法:控制發(fā)送窗口的大小發(fā)送方根據(jù)接收方反饋的信息控制發(fā)送窗口的操作關(guān)鍵:發(fā)送窗口大小(WS)??
接收方 窗口(advertisementwindow)的大?。╮wnd)rwnd:接收方允許發(fā)送方連續(xù)發(fā)送的數(shù)據(jù)量,也就等于接收方空閑緩存的大小?TCP/IP
Protocol
Suite2020/11/2338Sender
Buffer
&
Sender
WindowSender
Windowcan
be
sentimmedia
ysent,
notacknowledgednext
byteto
be
sentWs?TCP/IP
Protocol
Suite2020/11/2339TCP/IP
ProtocolSuiteReceiver
WindowReceiver
bufferTo
store
TCP
segments
in
order
(緩存亂序到達(dá)的報(bào)文段,向上層提供順序數(shù)據(jù))接收方
窗口的大小(rwnd)=Wr
-
已占用的緩存字節(jié)數(shù)Consider:
Howtoprocess
an
out-of-order
TCP
segment? (
acceptornot)next
byteto
be
receivedRFC
1122:
section0and
1Receiver
WindowTo
store
TCP
segments
in
orderReceiverSeg(1901)
)
ACK(19)2)?TCP/IP
Protocol
Suite2020/11/2341Expanding
the
senderwindow(發(fā)送窗口的擴(kuò)展)The
receiving
process
consumes
datafaster
than it
receives→
rwnd
??→將rwnd通知發(fā)送方(反饋)→發(fā)送方擴(kuò)展Ws
(Ws
=
rwnd)0Sender02
3
45Receiver
Wr=10rwnd=48ACK6,rwnd=801Ws==84?TCP/IP
Protocol
Suite2020/11/2342Shrinking
the
sender
window(發(fā)送窗口的縮?。?Sender02
3
45The
receiving
process
consumes
data
slowerthan
it
receives→
rwnd
??→將rwnd通知發(fā)送方(反饋)→發(fā)送方收縮為Ws
=
rwndReceiver
Wr=10rwnd=34ACK7,rwnd=301Ws==346?TCP/IP
Protocol
Suite2020/11/2343Closing
thesenderwindow(發(fā)送窗口的關(guān)閉)The
receiver
buffer
is
totally
full→
rwnd=0→將rwnd通知發(fā)送方(反饋)→發(fā)送方關(guān)閉窗口(窗口左邊=右邊),停止數(shù)據(jù)的發(fā)送Q:When
to
star
ding??TCP/IP
Protocol
Suite2020/11/2344Window
Management1000
3000Buffer4000SenderReceiver?TCP/IP
Protocol
Suite2020/11/2345TCP的糊涂窗口綜合癥SillyWindowSyndrome,SWS(糊涂窗口綜合癥)RFC
813SymptomTosend data
in
very
small
segments,
whichreduces
the
efficiency
of
the
operationExample:
1
byte
of
data,40
bytes
of
TCPand
IPheadersCauseThe
sending
application
program
creates
dataslowlyThe
receiving
application
program
consumesdataslowlyor
both?TCP/IP
Protocol
Suite2020/11/2346發(fā)送方SWS解決方案發(fā)送方SWS:原因:發(fā)送進(jìn)程數(shù)據(jù)產(chǎn)生緩慢現(xiàn)象:發(fā)端TCP逐個字節(jié)地發(fā)送TCP報(bào)文段解決思路:避免TCP逐個字節(jié)發(fā)送發(fā)送方延遲發(fā)送,收集應(yīng)用程序的發(fā)送數(shù)據(jù), 合理的數(shù)據(jù)量關(guān)鍵問題:延遲時間如何確定延遲長:通信延遲增加延遲短:產(chǎn)生短的TCP報(bào)文段延遲策略:Nagle’s
algorithm發(fā)送方TCP發(fā)送第一塊從應(yīng)用進(jìn)程收到的數(shù)據(jù)發(fā)送方等待ACK,并且累積數(shù)據(jù),發(fā)送方發(fā)送條件:數(shù)據(jù)累積到可以封裝成最大長度的報(bào)文段或者收到上一報(bào)文段的ACK?TCP/IP
Protocol
Suite2020/11/2347接收方SWS解決方案接收方SWS:原因:接收進(jìn)程數(shù)據(jù)消耗緩慢現(xiàn)象:發(fā)端TCP逐個字節(jié)地發(fā)送TCP報(bào)文段解決思路:Clark解決方案:目前接收窗口大?。┙邮辗绞盏綀?bào)文段就進(jìn)行確認(rèn)(如果空閑緩存空間:小于1個報(bào)文段最大長度或者小于緩存空間的1/2接收方
:目前接收窗口=0延遲確認(rèn):發(fā)送方延遲發(fā)送ACK,直到有足夠空閑緩存空間?TCP/IP
Protocol
Suite2020/11/2348Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2349Error
Control目標(biāo):接收應(yīng)用程序從TCP收到的數(shù)據(jù)流是按序的、無差錯的、無丟失、無重復(fù)的差錯控制分兩步:Detecting
and
correctingCorrupted
segmentsLost
segmentsOut-of-order
segmentsDuplicatedsegmentsTCP中實(shí)現(xiàn)差錯控制的三種工具Checksum:用來檢查受損報(bào)文Acknowledgment:
positive
and
cumulativeTime-out:
retransmissionHow
to
detect
?How
to
correct??TCP/IP
Protocol
Suite2020/11/2350確認(rèn)ACK報(bào)文段不消耗序號,也不被確認(rèn)什么時候產(chǎn)生ACK報(bào)文段(規(guī)則1)捎帶確認(rèn):發(fā)送數(shù)據(jù)報(bào)文段時——減少ACK報(bào)文段(規(guī)則2)推遲確認(rèn):接收端無數(shù)據(jù)發(fā)送,按序收到數(shù)據(jù),且前一個報(bào)文段已確認(rèn)——減少ACK報(bào)文段立即確認(rèn):(規(guī)則3)接收端無數(shù)據(jù)發(fā)送,按序收到數(shù)據(jù),且前一個報(bào)文段未確認(rèn)——避免不必要的重傳(規(guī)則4)當(dāng)收到失序報(bào)文段——快速重傳(規(guī)則5)當(dāng)丟失的報(bào)文段到達(dá)(規(guī)則6)重復(fù)報(bào)文段到達(dá)——解決ACK丟失?TCP/IP
Protocol
Suite2020/11/2351確認(rèn)類型累計(jì)確認(rèn)(ACK)表示希望收到的下一個字節(jié)的序號并對該字節(jié)以前的所有字節(jié)的累計(jì)確認(rèn)選擇確認(rèn)(SACK)報(bào)告失序,重復(fù)的報(bào)文段?TCP/IP
Protocol
Suite2020/11/2352重傳差錯控制的 :重傳報(bào)文段當(dāng)報(bào)文段受損、丟失時,就需要重傳什么時候重傳?重傳超時(RTO)定時器超時發(fā)送端連續(xù)收到3個重復(fù)的ACK重傳超時定時器超時發(fā)送方就認(rèn)為:對應(yīng)報(bào)文段受損或者丟失收到3個重復(fù)的ACK發(fā)送方就認(rèn)為:某個報(bào)文丟失,且收方收到大量亂序報(bào)文快速重傳?TCP/IP
Protocol
Suite2020/11/2353Normal
operation?TCP/IP
Protocol
Suite2020/11/2354Corrupted
Segment(報(bào)文段受損)Sender
ReceiverSegment3corruptedOK
OKTime-outOK2020/11/23TimeTime?TCP/IP
Protocol
Suite55Lost
SegmentSenderReceiverSegment3
lostOK
OKTime-outOK2020/11/23TimeTime?TCP/IP
Protocol
Suite56Lost
Segment?TCP/IP
Protocol
Suite2020/11/2357Duplicate
Segment(重復(fù)報(bào)文段)CauseWhen
the
acknowledgment
does
not
arrive
beforethetime-out重復(fù)報(bào)文段解決方案:the
destination
TCP
(接收方TCP)檢測出重復(fù)報(bào)文段Sequence
numberSimply
discard
the
packetReceiver124524924假設(shè),TCP報(bào)文長為400ByteSeg(524A)
CK(1324)?TCP/IP
Protocol
Suite582020/11/23Out-of-Order
Segment(失序報(bào)文段)CauseTCP
uses
the
services
of
IP,
an
unreliable,connectionless
network
layer
service解決方案:the
destination
TCP
(接收方TCP)檢測出失序的報(bào)文段:sequence
numberCorrectingTCP
does
NOT
acknowledge
an
out-of-order
segmentuntil
it
receives
all
of
the
segments
that
precede
itIf
the
acknowledgment
is
delay,
the
timer
of
the
out-of-order
segment
may
mature
at
the
source
TCP
andthe
segment
may
be
resent
——
duplicate
segmentSeg(1910)
)
ACK(19)2)Receiver?TCP/IP
Protocol
Suite2020/11/2359206Fast
retransmissionLost
AcknowledgmentSender
ReceiverTimeTimeAcknowledgmentlostOK
OK
OK?TCP/IPProtocol
Suite2020/11/2361Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2362Congestion
Control(擁塞控制)Congestion:網(wǎng)絡(luò)中,路由器接收過多的分組,超過其處理能力時,發(fā)生擁塞
→
分組被丟棄Some
packets
could
be
dropped
by
the
router→
no
ack
is
sent
from
the
destination→TCP發(fā)送端會重傳超時定時器會超時→
the
sender
retransmits
the
lost
packetTo
create
more
congestion
and
more
drop→
more
retransmission
and
more
congestionFinally,
the
whole
system
collapses結(jié)論:擁塞引起的重傳,會使情況更糟?TCP/IP
Protocol
Suite2020/11/2363Capacity(網(wǎng)絡(luò)容量):網(wǎng)絡(luò)能處理的分組數(shù)Throughput(吞吐率):單位時間內(nèi)通過網(wǎng)絡(luò)的分組數(shù)Packet
delay,
ThroughputVS.networkload?TCP/IP
Protocol
Suite2020/11/2364Router
queues?TCP/IP
Protocol
Suite2020/11/2365Congestion
Control端點(diǎn)(主機(jī))上的TCP是無法準(zhǔn)確知道網(wǎng)絡(luò)因何原因或者在何處發(fā)生擁塞擁塞對于端點(diǎn)而言,表現(xiàn)為:TCP傳輸延遲增加,導(dǎo)致超時重傳TCP應(yīng)該在網(wǎng)絡(luò)出現(xiàn)擁塞時,必須減慢發(fā)送速率(或停止傳輸)→
擁塞控制問題:TCP如何發(fā)現(xiàn)網(wǎng)絡(luò)的擁塞呢?TCP
assumes(關(guān)鍵假設(shè))The
causeof
a
lost
segment
is
dueto
congestion
in
thenetwork問題:發(fā)現(xiàn)擁塞如何處理?——控制發(fā)送速率In
flowcontrol,發(fā)送窗口由接收方直接控制Sender
window
=
Receiver
window網(wǎng)絡(luò)中擁塞,發(fā)送窗口還要取決于網(wǎng)絡(luò)的擁塞情況?TCP/IP
Protocol
Suite2020/11/2366Congestion
Window(擁塞窗口)Sender
window
=
Min
{rwnd,
cwnd}rwnd:
receiver’s
advertised
window
(接收方 窗口)——areceiver-sidelimit——流量控制cwnd:congestion
window(擁塞窗口)
——asender-side
limit(反映了網(wǎng)絡(luò)的擁塞狀況)——擁塞控制?TCP/IP
Protocol
Suite2020/11/2367小結(jié):TCP中的幾個窗口接收方
窗口(
rwnd
):接收方通過反饋告訴發(fā)送方的允許傳輸?shù)臄?shù)據(jù)量(單位:可以是字節(jié),也可以是報(bào)文段)擁塞窗口(
cwnd
):發(fā)送方為了進(jìn)行擁塞控制而限制自己傳輸?shù)臄?shù)據(jù)量實(shí)際發(fā)送窗口的大?。組in
{rwnd,cwnd}哪個窗口值小,那種控制就起作用擁塞窗口如何確定——擁塞策略?TCP/IP
Protocol
Suite2020/11/2368Congestion
ControlAlgorithmsSlow
start(慢啟動)
congestion
avoidance(擁塞避免)以及擁塞檢測慢啟動:指數(shù)增大擁塞避免:加法增大擁塞檢測:乘法減小Fast
retransmit/Fast
recovery(快速重傳和快速恢復(fù))To
detect
and
repairloss
based
on ing
duplicate
ACKsTCP
assumes3
or
more
duplicate
ACKs
→
a
segment
has
beenlost參考文獻(xiàn)Van
Jacobson,Congestion
Avoidance
and
Control,
M88RFC2001,TCP
Slow
Start,
Congestion
Avoidance,
Fast
Retransmit,and
Fast
Recovery
AlgorithmsRFC
2581,TCP
Congestion
ControlWilliam
Stallings,高速網(wǎng)絡(luò)與互聯(lián)網(wǎng)絡(luò)——性能與服務(wù)質(zhì)量(第二版),第12章TCP通信量控制,電子工業(yè)
,2003?TCP/IP
Protocol
Suite2020/11/2369Slow
start(慢啟動)建立一條新的TCP連接以后,執(zhí)行慢啟動:初始狀態(tài)cwnd=1(1個最大報(bào)文段MSS)發(fā)送
允許發(fā)送1個TCP報(bào)文段(因?yàn)榘l(fā)送窗口=1)等待ACK每收到1個ACK,發(fā)送窗口向右滑動1個報(bào)文段的長度cwnd+1
→發(fā)送方連續(xù)發(fā)送2個報(bào)文段0直到發(fā)送窗口大?。╓s)=ssthresh(慢啟動閾值)慢啟動過程實(shí)際上是發(fā)送TCP在TCP連接建立初期試探網(wǎng)絡(luò)的擁塞狀況,以避免因一次發(fā)送過多的報(bào)文段而引起網(wǎng)絡(luò)的擁塞sender0ACK1
ACK2
ACK3注:慢啟動實(shí)際并不慢,每過1個RTT,cwnd就翻倍,呈2的指數(shù)增長?TCP/IP
Protocol
Suite2020/11/2370Congestion
avoidance(擁塞避免)在慢啟動階段,擁塞窗口以指數(shù)形式增長,要避免發(fā)生擁塞,當(dāng)擁塞窗口達(dá)到某個值后,必須減慢擁塞窗口的增長規(guī)律當(dāng)發(fā)送窗口大小=ssthresh時,發(fā)送方進(jìn)入擁塞避免階段在這個階段中,只有當(dāng)窗口中所有報(bào)確認(rèn)后,擁塞窗口+1實(shí)質(zhì)上:每收到1個ACK,cwnd=cwnd+1/cwnd當(dāng)RTT較大時,可以認(rèn)為是每隔一個RTT,擁塞窗口cwnd+1→加性增加(Addictive
Increase)擁塞避免直到出現(xiàn)重傳超時定時器超時,即發(fā)生擁塞?TCP/IP
Protocol
Suite2020/11/2371Congestion
avoidance?TCP/IP
Protocol
Suite2020/11/2372擁塞檢測推測擁塞:超時重傳ssthresh(慢啟動閾值)設(shè)置為當(dāng)前cwnd(擁塞窗口)的一半即ssthresh
=
[cwnd
/2]cwnd(擁塞窗口)=1重新執(zhí)行慢啟動0sender0cwnd=
16
ssthresh=
83?TCP/IP
Protocol
Suite2020/11/2373快速重傳和快速恢復(fù)如果不是超時,而是連續(xù)收到3個ACK,處理方式是:ssthresh(慢啟動閾值)設(shè)置為當(dāng)前cwnd(擁塞窗口)的一半cwnd=當(dāng)前閾值開始擁塞避免階段為什么這樣做?連續(xù)收到3個ACK,說明1個報(bào)文段可能丟失了,但后面的幾個報(bào)文段又安全到達(dá)?TCP/IP
Protocol
Suite2020/11/2374TCP擁塞策略小結(jié)?TCP/IP
Protocol
Suite2020/11/2375擁塞舉例Number
of
transmitted
segmentsCongestion
window
size(
insegments)SlowstartCongestionavoidance?TCP/IP
Protocol
Suite2020/11/2376Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2377TCPTimerRetransmission
timer(重傳超時定時器)The
waiting
time
for
an
ack
of
a
segmentTo
control
a
lost
or
discarded
segmentPersistencetimer(持久)To
deal
with
the
zero
window-size
advertisementThe
waiting
time
for
an
ack
with
a
non-zero
window
sizeKeepalive
timer(保活)To
prevent
a
long
idle
connection
between
two
TCPThe
waiting
time
for
some
data
from
a
clientTime-waited
timer(時間等待)To
be
used
during
connection
termination?TCP/IP
Protocol
Suite2020/11/2378Retransmission
Timer功能:處理重傳超時發(fā)送方可以重傳報(bào)文段→某些報(bào)文段在傳輸過程中可能丟失或者被丟棄(
lost
or
discarded
)The
waiting
time for
an
ack
of
asegmentUsage(如何使用重傳超時定時器)When
TCPsends
a
segment,
it
creates
aretransmission
timer
for
that
segmentIf
anackis
received
for
that segment
beforetime-out,
the
timer
is
destroyedOtherwise
the
segment
is
retransmitted
and
thetimer
is
reset關(guān)鍵問題:重傳超時(RTO)時間如何確定??TCP/IP
Protocol
Suite2020/11/2379重傳超時時間RTT
(Round-Trip
Time):報(bào)文段傳輸?shù)耐禃r延從發(fā)送一個報(bào)文到收到這個報(bào)文的時間重傳超時時間取值一般是基于RTT的例如(一種簡單算法):Retransmission
timer=2
x
RTTInternet的上的RTT不同TCP連接具有各自不同的路徑長度,時延差異大同一個TCP連接,發(fā)送方從發(fā)送報(bào)文段到收到確認(rèn)的時間隨網(wǎng)絡(luò)的擁塞狀況而改變分組經(jīng)過路由器,路由器產(chǎn)生的時延取決于通信量結(jié)論:分組的傳輸時延無法預(yù)先確定→重傳超時時間無法事先 ,是動態(tài)變化的?TCP/IP
Protocol
Suite2020/11/2380Internet上的100個Packet的往返傳輸時間圖u2020/11/2381RTT的測量In
TCP,
there
can
be
only
be
one
RTTmeasurement
inprogress
at
any
time——RTTM(M:measure)TCP報(bào)文段和它的確認(rèn)并非1-1對應(yīng)某個TCP報(bào)文段的RTT是該報(bào)文段到達(dá)終點(diǎn)并被確認(rèn)所需的時間,雖然這個確認(rèn)可能包含對其它報(bào)文段的確認(rèn)平滑RTTS——Internet中測量的RTTM起伏大,需要平滑——
平均初始:沒有數(shù)值第一次測量后:RTTS=RTTM其它任何測量后:RTTS
=
(
1-
α)
x
RTTS
+
αx
RTTM,
α
=1/8?TCP/IP
Protocol
Suite2020/11/2382RTT偏差(RTTD)初始:沒有數(shù)值第一次測量后:
RTTD
=
RTTM
/
2其它任何測量后:RTTD
=
(
1-β)
x
RTTD
+β|RTTS-RTTM|Β一般取值為1/4?TCP/IP
Protocol
Suite2020/11/2383重傳超時RTO的計(jì)算初值:初始值其它任何次測量后:RTO =
RTTS
+
4×RTTDRTT偏差(RTTD)?TCP/IP
Protocol
Suite2020/11/2384Karn’s
algorithm解決的問題:發(fā)送方無法準(zhǔn)確判斷在啟動重傳后收到ACK所確認(rèn)的報(bào)文段(原始?重
傳?)不對重傳的報(bào)文段更新RTT但需要采用時延補(bǔ)償技術(shù)(針對重傳)——指數(shù)退避Internetworking
with
TCP/IP
Volume
1:Principles,
Protocols,
and
Architectures,Chapter
13?TCP/IP
Protocol
Suite2020/11/23852020/11/C
/I o
oco Sui
e86指數(shù)退避原則:每產(chǎn)生一次重傳,RTO數(shù)值就加倍2020/11/23TCP/IP
Protocol
Suite87Persistence
Timer(持久定時器)功能:To
deal
with
the
loss
of
non-zero
window
size非零窗口值advertisement當(dāng)發(fā)送方窗口關(guān)閉后,直到收方發(fā)送一個確認(rèn)來如果該確認(rèn)丟失,雙方將陷入死鎖UsageWhen
the
sending
TCP
receives
anack
with
a
window
size
ofzero,
it
starts
a
persistence
timerIf
an
ack
with
anon-zerowindow
size
is
not
received
from
thereceiver
before
time-out,
then
senda
probe
segment
(發(fā)送探測報(bào)文段)探測報(bào)文段有序號,但不需要確認(rèn)The
value
of
the
timer
is
set
to
the
value
of
the
retransmissiontimerThe
sender
continues
sending
the
probe
segment
and
doublingand
resetting
the
value
of
the
timer
until
the
value
reaches
athreshold
(usually
60
s)TCP中,不對ACK確認(rèn)Keepalive
Timer功能:To
prevent
a
long
idle
connectionbetween
two
TCPUsageEach
time
the
server
hears
from
a
client,
itresets
this
timerThe
time-out
is
usually
2
hoursIf the
server
does
not
hear
from
the
clientafter
2
hours,
i ds
a
probesegmentIf
there
is
no
response
after
10
probe,
each
ofwhich
is
75s
apart,
then the
server
assumesthat
the
client is
down
and
terminates
theconnection?TCP/IP
Protocol
Suite2020/11/2388Time-waited
TimerUsageWhen
TCP
closes
a
connection,itdoesnot
consider
the
connection
really
closed.The
connection
is
held
in
limbo
(過渡期)for
a
time-waitedperiodThe
value
for
this
timer
is
usually
2times
the
expected
lifetime
of
a
segment( um
Segment
Lifetime,MSL)2
minutes:
an
engineering
choice?TCP/IP
Protocol
Suite2020/11/2389Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2390Segment(0
~
40
bytes)控制字段Segment差錯控制以字節(jié)為單位流控同UDP標(biāo)識應(yīng)用進(jìn)程Initial
sequence
number?TCP/IP
Protocol
Suite2020/11/2391初始序號(ISN)在建立連接時,通信雙方的TCP各自隨機(jī)產(chǎn)生初始序號例:假設(shè)站點(diǎn)A的TCP向站點(diǎn)B發(fā)起建立連接,其ISN=2367,意味著:A的第1個TCP報(bào)文段的序號為2367第1個TCP報(bào)文段用于建立連接,數(shù)據(jù)長度=0A的第2個TCP報(bào)文段的序號為2368第2個TCP報(bào)文段用于建立連接,數(shù)據(jù)長度=0A的第3個TCP報(bào)文段的序號為2368,第3個TCP報(bào)文段攜帶數(shù)據(jù),長度≠0問題:假設(shè)第3個TCP報(bào)文段數(shù)據(jù)長度=1000,那么A的第4個TCP報(bào)文段的序號是多少?2368+1000=3368TCP中,建立連接階段的控制報(bào)文段有序號,但數(shù)據(jù)部分為0?TCP/IP
Protocol
Suite2020/11/2392Control
Field控制域(6bit)用于:FlowcontrolConnection
establishment
and
terminationThe
mode
of
data
transfer
in
TCPURG
ACK
PSH
RST
SYN
FINURG:
Urgent
pointer
is
validRST:
Reset
the
connectionACK:
Acknowledgment
is
validSYN:
Synchronize
sequence
numbersPSH:
Request
for
pushFIN:
Terminate
the
connection?TCP/IP
Protocol
Suite2020/11/23932020/11/2394校驗(yàn)和2020/11/23TCP/IP
ProtocolSuite95緊急指針與緊急(帶外)數(shù)據(jù)緊急數(shù)據(jù):不需要接收進(jìn)程按序緊急指針:只有當(dāng)控制域中的URG置位時,才有效指向帶外數(shù)據(jù)的最后一個字節(jié)帶外數(shù)據(jù)(out-of-band
data,urgent
data)發(fā)送端TCP立即創(chuàng)建報(bào)文段帶外數(shù)據(jù)位于數(shù)據(jù)域的首部接收端TCP:不在數(shù)據(jù)流中排隊(duì),直接遞交上層提供快速傳遞數(shù)據(jù)的功能UR
GTCPHeaderTCP
Data帶外(緊急)數(shù)據(jù)2020/11/23TCP/IP
ProtocolSuite96Option(
)選項(xiàng)Option單字節(jié)Single-byte多字節(jié)Multiple-byte無操作No
operation最大報(bào)文段長度Max
segmentsize選項(xiàng)結(jié)束End
of
option窗口比例因子Window
scale
factor時間戳TimestampRFC
1323Chapter
10
TCPOverviewTCP
servicesWindow
based
control
ProtocolFlow
controlErrorcontrolTCPtimersCongestion
controlSegmentConnectionTCPoperationTCPpackage?TCP/IP
Protocol
Suite2020/11/2397ConnectionConnection連接由1對端點(diǎn)標(biāo)識:
{(IP1,port1),
(IP2,port2)}連接數(shù)量受機(jī)器內(nèi)存容量限制一個機(jī)器上某個TCP端 可被多個連接共享面向連接的傳輸包括以下幾個操作:連接建立連接拆除連接復(fù)位TCPTCPServerClient
2App3 App2TCPApp1Client
1App2App1 App
3?TCP/IP
Protocol
Suite2020/11/23982020/11/23TCP/IP
Protocol
Suite99連接建立(Connection
Establishment)Active
open(主動打開)發(fā)起建立連接,ClientPassive
open( 打開)接受連接,Server
打開方一般先于主動打開方啟動,但不發(fā)起連接建立過程,而是在某個端口上等待主動方的連接請求——服務(wù)器TCP連接的任意一方都可以主動打開連接3-way
HandshakingClient
ServerWaits
for
apassive
openRequests
forAn
active
open包含初始序號(同步序號),不包括確認(rèn)號,也沒定義窗口對第一次握手進(jìn)行確認(rèn),同時定義
窗口確認(rèn)第二次握手,定義
窗口;可以在第三個報(bào)文段中發(fā)送數(shù)據(jù)D an
be
sent
wi
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 體育個人課題申報(bào)書范例
- 課題申報(bào)書點(diǎn)評模板
- 兵團(tuán)立項(xiàng)課題申報(bào)書
- 課題申報(bào)書格式
- 陜西課題申報(bào)書范文樣本
- 烏魯木齊供用熱合同范本
- 怎么填課題申報(bào)書
- 品牌專利持有合同范本
- 會展場館租賃合同范本
- 科學(xué)技術(shù)課題申報(bào)書
- 《電化學(xué)催化》課件
- 羊水栓塞應(yīng)急預(yù)案及流程
- 新課標(biāo)(水平三)體育與健康《籃球》大單元教學(xué)計(jì)劃及配套教案(18課時)
- 《設(shè)施節(jié)水灌溉技術(shù)》課件
- 2023年涼山州西昌市人民醫(yī)院招聘衛(wèi)生專業(yè)技術(shù)人員考試真題
- 《中國傳統(tǒng)文化儒家》課件
- 小學(xué)三年級每日英語單選題100道及答案解析
- 咨詢公司顧問崗位聘用協(xié)議
- 2024年糖尿病指南解讀
- 環(huán)衛(wèi)應(yīng)急預(yù)案8篇
- 《與顧客溝通的技巧》課件
評論
0/150
提交評論