tcpip-chapter p通信与信息工程学院网络工程系_第1页
tcpip-chapter p通信与信息工程学院网络工程系_第2页
tcpip-chapter p通信与信息工程学院网络工程系_第3页
tcpip-chapter p通信与信息工程学院网络工程系_第4页
tcpip-chapter p通信与信息工程学院网络工程系_第5页
免费预览已结束,剩余111页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

TCP/IP协议原理网络工程系通信与信息:

wPhone:

61830521

(O)Chapter

10

TCPOverviewTCP

servicesWindow

based

control

ProtocolFlow

controlErrorcontrolTCPtimersCongestion

controlSegmentConnectionTCPoperationTCPpackage⚫TCP/IP

Protocol

Suite2020/11/232Introduction应用的需求:reliability传输大量的数据,要求可靠的通信服务自身的可靠性机制弱底层网络和IP网络是不可靠、无连接投递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)分组传输服务面向连接的通信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使用两个端点地址(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,传输控制协议ApplicationLayerTCPUDP⚫TCP/IP

Protocol

Suite2020/11/236TransportLayerProcess-to-process

Communication端口、端点概念与方式与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(流交付服务)Full-duplex

service(全双工服务)Connection-oriented

serviceReliable

service⚫TCP/IP

Protocol

Suite2020/11/239理解:Stream

Delivery与UDP交付区别:进程把预先定义好边界的一组报文(用户数据报)发送给UDPUDP对这些报文中的每一个添加首部,传递给

IP传输UDP和IP都无法识别这些数据报之间是否存在任何关系——独立处理每一个数据报⚫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

→进程间使用自己认为适宜的任何大小的数据片进行发送或接收(最小1字节)发送进程 接收进程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要为进程构建”tube”——“可靠传输”流量控制发送进程与接收进程产生和消耗数据的速率不一致差错控制2u13TCP

segmentsTCP是如何发送“字节流”的?按报文段(segment)传输——Why?报文段:若干字节构成IP是按分组(Package)处理的(而非字节流),1个segment就封装在1个Package上述过程对于接收进程是透明的字节流按照报文段传输的

:接收方TCP收到报文段可能失序、损伤、重复,或者丢失!TCP

ServicesStream

delivery

service(流交付服务)Full-duplex

service(全双工服务)Connection-oriented

serviceReliable

service⚫TCP/IP

Protocol

Suite2020/11/2314TCP

Services:Full-Duplex

Service全双工:数据可以在同一时间双向流动每一个TCP都有发送缓存和接收缓存DataACKPiggybacking捎带D

an

flow

inboth

direction

atthe

same

time⚫TCP/IP

Protocol

Suite2020/11/2315TCP

ServicesStream

delivery

service(流交付服务)Full-duplex

service(全双工服务)Connection-oriented

serviceReliable

service⚫TCP/IP

Protocol

Suite2020/11/2316TCP

Services:Connection-OrientedService建立连接,使用连接,拆除连接建立的是虚连接(virtualconnection),而非物理连接(physical

connection)封装成IP分组的TCP报文段可能走不同的路径到达目的地接收到的TCP报文段可能:乱序、丢失、损坏、重复而TCP需要向上层按顺序交付数据IP网络⚫TCP/IP

Protocol

Suite2020/11/2317TCP

ServicesStream

delivery

service(流交付服务)Full-duplex

service(全双工服务)Connection-oriented

serviceReliable

service⚫TCP/IP

Protocol

Suite2020/11/2318TCP

Services:Reliable

ServiceReliabilitySequential,

without

error,

and

without

anypart

lostorduplicated如何实现可靠传输?——ARQ(AutomaticRepeat

reQuest)基本思路:接收方:must

continuously

return

acknowledgments(ACK)for

successfully

received

data发送方:每一个发送的数据都需要接收方的确认(ACK)发送每一个数据都需要缓存,并启动定时器,超时重传⚫TCP/IP

Protocol

Suite2020/11/2319Chapter

10

TCPOverviewTCP

servicesWindow

based

control

ProtocolFlow

controlErrorcontrolTCPtimersCongestion

controlSegmentConnectionTCPoperationTCPpackage⚫TCP/IP

Protocol

Suite2020/11/2320Window

based control

Protocol——基本协议技术序号(Sequence

number)确认(Acknowledgment)超时重传机制窗口滑动(sliding)扩展(expanding)缩回(shrinking)关闭(closing)⚫TCP/IP

Protocol

Suite2020/11/2321TCPNumbering

Bytes(给字节

)To

number

all

data

bytes

transmittedin

aconnection

→字节号,而不是给每个报文段分配Numbering

is

independentin

each

directionThe

numbering

starts

randomly,

NOT

from

0选取范围:0

~

232-1某个TCP连接上的某个报文段的序号(sequence

number)=报文段中第一个数据字节的字节号TCPSendingSending

bufferReceiving

bufferReceivingDatestreamSegmentData⚫TCP/IP

Protocol

Suite2020/11/2322练习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报文段的序号报文段的序号=

报文段中第一个数据字节的字节号,那么如果报文段不携带数据,那么这个报文段是否需要

?如何

?原则:需要确认的报文,才需要序号⚫TCP/IP

Protocol

Suite2020/11/2324Window

based control

Protocol——基本协议技术序号(Sequence

number)确认(Acknowledgment)超时重传机制窗口滑动(sliding)扩展(expanding)缩回(shrinking)关闭(closing)⚫TCP/IP

Protocol

Suite2020/11/2325Acknowledgment

(确认,ACK)Acknowledgment

number(确认号):对已经收到的字节表示确认Positive

ACK(肯定确认)The

number

of

the

next

data

byte

apartyexpects

to

receiveCumulative

ACK(累计确认)例如

TCP报文段中的确认号是:1234,意味着:已经收到了字节号=1234的以前的所有字节希望收到了下一个TCP报文段的序号=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报文的顺序关系数据流的位置,更便于流的复原需较大的序号空间(32bit,232→4Gbyte)序号不连续,n1<n2<n3…X+L⚫TCP/IP

Protocol

Suite2020/11/2327Window

based control

Protocol——基本协议技术序号(Sequence

number)确认(Acknowledgment)超时重传机制窗口滑动(sliding)扩展(expanding)缩回(shrinking)关闭(closing)⚫TCP/IP

Protocol

Suite2020/11/2328超时重传机制发送方每发送一个报文段(Segment),就启动一个定时器,如果在定时内,没有收到对该报文段的确认(ACK),重传该报文段发送方必须缓存已经发送但未收到确认的报文段发方在定时内没有收到确认(ACK),该报文段损坏或者该报文段丢失或者ACK丢失⚫TCP/IP

Protocol

Suite2020/11/2329Window

based control

Protocol——基本协议技术序号(Sequence

number)确认(Acknowledgment)超时重传机制窗口滑动(sliding)扩展(expanding)缩回(shrinking)关闭(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窗口:缓存中一组字节号(或者报文序号)的集合——窗口覆盖了缓存中的一部分单元窗口有左、右两沿,均可向右滑动落在发送窗口(sending

window)字节号可能存在两部分数据:发方已发送但还未收到确认的字节号(或者报文号)集合发方可以立即发送的字节号(或者报文号)集合发送窗口大小Ws= 连续发送的最大字节数落在接收窗口(receiving

window

)的字节号:收方希望接收的字节号(或者报文号)集合接收窗口大小Wr=允许 接收的最大字节数(即接收缓存大小)字节号不在发送窗口的数据不能发送字节号不在接收窗口的数据不能接收通过设置窗滑动窗口:发送窗口与接收窗口口大小控制发送数据量发送窗口与接收窗口接收窗口,rwnd=12020/133发送窗口24发送窗口——滑动且大小变化!发送窗口大小=min(rwnd,

cwnd)rwnd:接收窗口cwnd:拥塞窗口滑动(sliding)——TCP允许随时改变滑动窗口的大小!扩展(expanding):右沿右移允许发送 的字节缩回(shrinking):右沿左移回退N协议关闭/合拢(closing):左沿右移某些字节已被确认,移出窗口2020/11/23TCP/IP

ProtocolSuite35TCP中的滑动窗口既实现高效的可靠传输,又提供了流量控制高效可靠传输:发方在等待确认之前,可以发送多个分组流量控制:端到端:接收方控制发送窗口的大小→控制发送速率拥塞控制:路由器超载→拥塞→TCP减小发送窗口→控制发送速率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采用的流控方法:控制发送窗口的大小发送方根据接收方反馈的信息控制发送窗口的操作关键:发送窗口大小(WS)🡨

接收方 窗口(advertisementwindow)的大小(rwnd)rwnd:接收方允许发送方连续发送的数据量,也就等于接收方空闲缓存的大小⚫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

(缓存乱序到达的报文段,向上层提供顺序数据)接收方

窗口的大小(rwnd)=Wr

已占用的缓存字节数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(发送窗口的扩展)The

receiving

process

consumes

datafaster

than it

receives→

rwnd

🡩→将rwnd通知发送方(反馈)→发送方扩展Ws

(Ws

rwnd)0Sender02

3

45Receiver

Wr=10rwnd=48ACK6,rwnd=801Ws==84⚫TCP/IP

Protocol

Suite2020/11/2342Shrinking

the

sender

window(发送窗口的缩小)0Sender02

3

45The

receiving

process

consumes

data

slowerthan

it

receives→

rwnd

🡫→将rwnd通知发送方(反馈)→发送方收缩为Ws

rwndReceiver

Wr=10rwnd=34ACK7,rwnd=301Ws==346⚫TCP/IP

Protocol

Suite2020/11/2343Closing

thesenderwindow(发送窗口的关闭)The

receiver

buffer

is

totally

full→

rwnd=0→将rwnd通知发送方(反馈)→发送方关闭窗口(窗口左边=右边),停止数据的发送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发送方SWS解决方案发送方SWS:原因:发送进程数据产生缓慢现象:发端TCP逐个字节地发送TCP报文段解决思路:避免TCP逐个字节发送发送方延迟发送,收集应用程序的发送数据, 合理的数据量关键问题:延迟时间如何确定延迟长:通信延迟增加延迟短:产生短的TCP报文段延迟策略:Nagle’s

algorithm发送方TCP发送第一块从应用进程收到的数据发送方等待ACK,并且累积数据,发送方发送条件:数据累积到可以封装成最大长度的报文段或者收到上一报文段的ACK⚫TCP/IP

Protocol

Suite2020/11/2347接收方SWS解决方案接收方SWS:原因:接收进程数据消耗缓慢现象:发端TCP逐个字节地发送TCP报文段解决思路:Clark解决方案:目前接收窗口大小)接收方收到报文段就进行确认(如果空闲缓存空间:小于1个报文段最大长度或者小于缓存空间的1/2接收方

:目前接收窗口=0延迟确认:发送方延迟发送ACK,直到有足够空闲缓存空间⚫TCP/IP

Protocol

Suite2020/11/2348Chapter

10

TCPOverviewTCP

servicesWindow

based

control

ProtocolFlow

controlErrorcontrolTCPtimersCongestion

controlSegmentConnectionTCPoperationTCPpackage⚫TCP/IP

Protocol

Suite2020/11/2349Error

Control目标:接收应用程序从TCP收到的数据流是按序的、无差错的、无丢失、无重复的差错控制分两步:Detecting

and

correctingCorrupted

segmentsLost

segmentsOut-of-order

segmentsDuplicatedsegmentsTCP中实现差错控制的三种工具Checksum:用来检查受损报文Acknowledgment:

positive

and

cumulativeTime-out:

retransmissionHow

to

detect

?How

to

correct?⚫TCP/IP

Protocol

Suite2020/11/2350确认ACK报文段不消耗序号,也不被确认什么时候产生ACK报文段(规则1)捎带确认:发送数据报文段时——减少ACK报文段(规则2)推迟确认:接收端无数据发送,按序收到数据,且前一个报文段已确认——减少ACK报文段立即确认:(规则3)接收端无数据发送,按序收到数据,且前一个报文段未确认——避免不必要的重传(规则4)当收到失序报文段——快速重传(规则5)当丢失的报文段到达(规则6)重复报文段到达——解决ACK丢失⚫TCP/IP

Protocol

Suite2020/11/2351确认类型累计确认(ACK)表示希望收到的下一个字节的序号并对该字节以前的所有字节的累计确认选择确认(SACK)报告失序,重复的报文段⚫TCP/IP

Protocol

Suite2020/11/2352重传差错控制的 :重传报文段当报文段受损、丢失时,就需要重传什么时候重传?重传超时(RTO)定时器超时发送端连续收到3个重复的ACK重传超时定时器超时发送方就认为:对应报文段受损或者丢失收到3个重复的ACK发送方就认为:某个报文丢失,且收方收到大量乱序报文快速重传⚫TCP/IP

Protocol

Suite2020/11/2353Normal

operation⚫TCP/IP

Protocol

Suite2020/11/2354Corrupted

Segment(报文段受损)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(重复报文段)CauseWhen

the

acknowledgment

does

not

arrive

beforethetime-out重复报文段解决方案:the

destination

TCP

(接收方TCP)检测出重复报文段Sequence

numberSimply

discard

the

packetReceiver124524924假设,TCP报文长为400ByteSeg(524A)

CK(1324)⚫TCP/IP

Protocol

Suite582020/11/23Out-of-Order

Segment(失序报文段)CauseTCP

uses

the

services

of

IP,

an

unreliable,connectionless

network

layer

service解决方案:the

destination

TCP

(接收方TCP)检测出失序的报文段: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:网络中,路由器接收过多的分组,超过其处理能力时,发生拥塞

分组被丢弃Some

packets

could

be

dropped

by

the

router→

no

ack

is

sent

from

the

destination→TCP发送端会重传超时定时器会超时→

the

sender

retransmits

the

lost

packetTo

create

more

congestion

and

more

drop→

more

retransmission

and

more

congestionFinally,

the

whole

system

collapses结论:拥塞引起的重传,会使情况更糟⚫TCP/IP

Protocol

Suite2020/11/2363Capacity(网络容量):网络能处理的分组数Throughput(吞吐率):单位时间内通过网络的分组数Packet

delay,

ThroughputVS.networkload⚫TCP/IP

Protocol

Suite2020/11/2364Router

queues⚫TCP/IP

Protocol

Suite2020/11/2365Congestion

Control端点(主机)上的TCP是无法准确知道网络因何原因或者在何处发生拥塞拥塞对于端点而言,表现为:TCP传输延迟增加,导致超时重传TCP应该在网络出现拥塞时,必须减慢发送速率(或停止传输)→

拥塞控制问题:TCP如何发现网络的拥塞呢?TCP

assumes(关键假设)The

causeof

a

lost

segment

is

dueto

congestion

in

thenetwork问题:发现拥塞如何处理?——控制发送速率In

flowcontrol,发送窗口由接收方直接控制Sender

window

=

Receiver

window网络中拥塞,发送窗口还要取决于网络的拥塞情况⚫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(反映了网络的拥塞状况)——拥塞控制⚫TCP/IP

Protocol

Suite2020/11/2367小结:TCP中的几个窗口接收方

窗口(

rwnd

):接收方通过反馈告诉发送方的允许传输的数据量(单位:可以是字节,也可以是报文段)拥塞窗口(

cwnd

):发送方为了进行拥塞控制而限制自己传输的数据量实际发送窗口的大小=Min

{rwnd,cwnd}哪个窗口值小,那种控制就起作用拥塞窗口如何确定——拥塞策略⚫TCP/IP

Protocol

Suite2020/11/2368Congestion

ControlAlgorithmsSlow

start(慢启动)

congestion

avoidance(拥塞避免)以及拥塞检测慢启动:指数增大拥塞避免:加法增大拥塞检测:乘法减小Fast

retransmit/Fast

recovery(快速重传和快速恢复)To

detect

and

repairloss

based

on ing

duplicate

ACKsTCP

assumes3

or

more

duplicate

ACKs

a

segment

has

beenlost参考文献Van

Jacobson,Congestion

Avoidance

and

Control,

M88RFC2001,TCP

Slow

Start,

Congestion

Avoidance,

Fast

Retransmit,and

Fast

Recovery

AlgorithmsRFC

2581,TCP

Congestion

ControlWilliam

Stallings,高速网络与互联网络——性能与服务质量(第二版),第12章TCP通信量控制,电子工业

,2003⚫TCP/IP

Protocol

Suite2020/11/2369Slow

start(慢启动)建立一条新的TCP连接以后,执行慢启动:初始状态cwnd=1(1个最大报文段MSS)发送

允许发送1个TCP报文段(因为发送窗口=1)等待ACK每收到1个ACK,发送窗口向右滑动1个报文段的长度cwnd+1

→发送方连续发送2个报文段0直到发送窗口大小(Ws)=ssthresh(慢启动阈值)慢启动过程实际上是发送TCP在TCP连接建立初期试探网络的拥塞状况,以避免因一次发送过多的报文段而引起网络的拥塞sender0ACK1

ACK2

ACK3注:慢启动实际并不慢,每过1个RTT,cwnd就翻倍,呈2的指数增长⚫TCP/IP

Protocol

Suite2020/11/2370Congestion

avoidance(拥塞避免)在慢启动阶段,拥塞窗口以指数形式增长,要避免发生拥塞,当拥塞窗口达到某个值后,必须减慢拥塞窗口的增长规律当发送窗口大小=ssthresh时,发送方进入拥塞避免阶段在这个阶段中,只有当窗口中所有报确认后,拥塞窗口+1实质上:每收到1个ACK,cwnd=cwnd+1/cwnd当RTT较大时,可以认为是每隔一个RTT,拥塞窗口cwnd+1→加性增加(Addictive

Increase)拥塞避免直到出现重传超时定时器超时,即发生拥塞⚫TCP/IP

Protocol

Suite2020/11/2371Congestion

avoidance⚫TCP/IP

Protocol

Suite2020/11/2372拥塞检测推测拥塞:超时重传ssthresh(慢启动阈值)设置为当前cwnd(拥塞窗口)的一半即ssthresh

[cwnd

/2]cwnd(拥塞窗口)=1重新执行慢启动0sender0cwnd=

16

ssthresh=

83⚫TCP/IP

Protocol

Suite2020/11/2373快速重传和快速恢复如果不是超时,而是连续收到3个ACK,处理方式是:ssthresh(慢启动阈值)设置为当前cwnd(拥塞窗口)的一半cwnd=当前阈值开始拥塞避免阶段为什么这样做?连续收到3个ACK,说明1个报文段可能丢失了,但后面的几个报文段又安全到达⚫TCP/IP

Protocol

Suite2020/11/2374TCP拥塞策略小结⚫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功能:处理重传超时发送方可以重传报文段→某些报文段在传输过程中可能丢失或者被丢弃(

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关键问题:重传超时(RTO)时间如何确定?⚫TCP/IP

Protocol

Suite2020/11/2379重传超时时间RTT

(Round-Trip

Time):报文段传输的往返时延从发送一个报文到收到这个报文的时间重传超时时间取值一般是基于RTT的例如(一种简单算法):Retransmission

timer=2

x

RTTInternet的上的RTT不同TCP连接具有各自不同的路径长度,时延差异大同一个TCP连接,发送方从发送报文段到收到确认的时间随网络的拥塞状况而改变分组经过路由器,路由器产生的时延取决于通信量结论:分组的传输时延无法预先确定→重传超时时间无法事先 ,是动态变化的⚫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报文段和它的确认并非1-1对应某个TCP报文段的RTT是该报文段到达终点并被确认所需的时间,虽然这个确认可能包含对其它报文段的确认平滑RTTS——Internet中测量的RTTM起伏大,需要平滑——

平均初始:没有数值第一次测量后:RTTS=RTTM其它任何测量后:RTTS

=

(

1-

α)

x

RTTS

+

αx

RTTM,

α

=1/8⚫TCP/IP

Protocol

Suite2020/11/2382RTT偏差(RTTD)初始:没有数值第一次测量后:

RTTD

=

RTTM

/

2其它任何测量后:RTTD

=

(

1-β)

x

RTTD

+β|RTTS-RTTM|Β一般取值为1/4⚫TCP/IP

Protocol

Suite2020/11/2383重传超时RTO的计算初值:初始值其它任何次测量后:RTO =

RTTS

+

4×RTTDRTT偏差(RTTD)⚫TCP/IP

Protocol

Suite2020/11/2384Karn’s

algorithm解决的问题:发送方无法准确判断在启动重传后收到ACK所确认的报文段(原始?重

传?)不对重传的报文段更新RTT但需要采用时延补偿技术(针对重传)——指数退避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指数退避原则:每产生一次重传,RTO数值就加倍2020/11/23TCP/IP

Protocol

Suite87Persistence

Timer(持久定时器)功能:To

deal

with

the

loss

of

non-zero

window

size非零窗口值advertisement当发送方窗口关闭后,直到收方发送一个确认来如果该确认丢失,双方将陷入死锁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

(发送探测报文段)探测报文段有序号,但不需要确认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确认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差错控制以字节为单位流控同UDP标识应用进程Initial

sequence

number⚫TCP/IP

Protocol

Suite2020/11/2391初始序号(ISN)在建立连接时,通信双方的TCP各自随机产生初始序号例:假设站点A的TCP向站点B发起建立连接,其ISN=2367,意味着:A的第1个TCP报文段的序号为2367第1个TCP报文段用于建立连接,数据长度=0A的第2个TCP报文段的序号为2368第2个TCP报文段用于建立连接,数据长度=0A的第3个TCP报文段的序号为2368,第3个TCP报文段携带数据,长度≠0问题:假设第3个TCP报文段数据长度=1000,那么A的第4个TCP报文段的序号是多少?2368+1000=3368TCP中,建立连接阶段的控制报文段有序号,但数据部分为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校验和2020/11/23TCP/IP

ProtocolSuite95紧急指针与紧急(带外)数据紧急数据:不需要接收进程按序紧急指针:只有当控制域中的URG置位时,才有效指向带外数据的最后一个字节带外数据(out-of-band

data,urgent

data)发送端TCP立即创建报文段带外数据位于数据域的首部接收端TCP:不在数据流中排队,直接递交上层提供快速传递数据的功能UR

GTCPHeaderTCP

Data带外(紧急)数据2020/11/23TCP/IP

ProtocolSuite96Option(

)选项Option单字节Single-byte多字节Multiple-byte无操作No

operation最大报文段长度Max

segmentsize选项结束End

of

option窗口比例因子Window

scale

factor时间戳TimestampRFC

1323Chapter

10

TCPOverviewTCP

servicesWindow

based

control

ProtocolFlow

controlErrorcontrolTCPtimersCongestion

controlSegmentConnectionTCPoperationTCPpackage⚫TCP/IP

Protocol

Suite2020/11/2397ConnectionConnection连接由1对端点标识:

{(IP1,port1),

(IP2,port2)}连接数量受机器内存容量限制一个机器上某个TCP端 可被多个连接共享面向连接的传输包括以下几个操作:连接建立连接拆除连接复位TCPTCPServerClient

2App3 App2TCPApp1Client

1App2App1 App

3⚫TCP/IP

Protocol

Suite2020/11/23982020/11/23TCP/IP

Protocol

Suite99连接建立(Connection

Establishment)Active

open(主动打开)发起建立连接,ClientPassive

open( 打开)接受连接,Server

打开方一般先于主动打开方启动,但不发起连接建立过程,而是在某个端口上等待主动方的连接请求——服务器TCP连接的任意一方都可以主动打开连接3-way

HandshakingClient

ServerWaits

for

apassive

openRequests

forAn

active

open包含初始序号(同步序号),不包括确认号,也没定义窗口对第一次握手进行确认,同时定义

窗口确认第二次握手,定义

窗口;可以在第三个报文段中发送数据D an

be

sent

wi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论