ReliableByte-Stream(TCP) Outline - - PDF document

reliable byte stream tcp
SMART_READER_LITE
LIVE PREVIEW

ReliableByte-Stream(TCP) Outline - - PDF document

ReliableByte-Stream(TCP) Outline ConnectionEstablishment/Termination SlidingWindowRevisited FlowControl AdaptiveTimeout Spring2002 CS461 1 End-to-EndProtocols Underlyingbest-effortnetwork


slide-1
SLIDE 1

1

Spring2002 CS461 1

ReliableByte-Stream(TCP)

Outline

ConnectionEstablishment/Termination SlidingWindowRevisited FlowControl AdaptiveTimeout

Spring2002 CS461 2

End-to-EndProtocols

  • Underlyingbest-effortnetwork

– dropmessages – re-ordersmessages – deliversduplicatecopiesofagivenmessage – limitsmessagestosomefinitesize – deliversmessagesafteranarbitrarilylongdelay

  • Commonend-to-endservices

– guaranteemessagedelivery – delivermessagesinthesameordertheyaresent – deliveratmostonecopyofeachmessage – supportarbitrarilylargemessages – supportsynchronization – allowthereceivertoflowcontrolthesender – supportmultipleapplicationprocessesoneachhost

Spring2002 CS461 3

SimpleDemultiplexor(UDP)

  • Unreliableandunordereddatagramservice
  • Addsmultiplexing
  • Noflowcontrol
  • Endpointsidentifiedbyports

– servershavewell-known ports – see/etc/services onUnix

  • Headerformat
  • Optionalchecksum

– psuedoheader+UDPheader+data

SrcPort DstPort Checksum Length Data 16 31

slide-2
SLIDE 2

2

Spring2002 CS461 4

TCPOverview

  • Connection-oriented
  • Byte-stream

– appwritesbytes – TCPsendssegments – appreadsbytes

Applicationprocess Write bytes TCP Sendbuffer Segment Segment Segment Transmitsegments Applicationprocess Read bytes TCP Receivebuffer … … …

  • Fullduplex
  • Flowcontrol:keepsender

fromoverrunningreceiver

  • Congestioncontrol:keep

senderfromoverrunning network

Spring2002 CS461 5

DataLinkVersusTransport

  • Potentiallyconnectsmanydifferenthosts

– needexplicitconnectionestablishmentandtermination

  • PotentiallydifferentRTT

– needadaptivetimeoutmechanism

  • Potentiallylongdelayinnetwork

– needtobepreparedforarrivalofveryoldpackets

  • Potentiallydifferentcapacityatdestination

– needtoaccommodatedifferentnodecapacity

  • Potentiallydifferentnetworkcapacity

– needtobepreparedfornetworkcongestion

Spring2002 CS461 6

SegmentFormat

Options(variable) Data Checksum SrcPort DstPort HdrLen Flags UrgPtr AdvertisedWindow SequenceNum Acknowledgment 4 10 16 31

slide-3
SLIDE 3

3

Spring2002 CS461 7

SegmentFormat(cont)

  • Eachconnectionidentifiedwith4-tuple:

– (SrcPort,SrcIPAddr,DsrPort,DstIPAddr)

  • Slidingwindow+flowcontrol

– acknowledgment,SequenceNum,AdvertisedWinow

  • Flags

– SYN,FIN,RESET,PUSH,URG,ACK

  • Checksum

– pseudoheader+TCPheader+data Sender Data (SequenceNum) Acknowledgment+ AdvertisedWindow Receiver

Spring2002 CS461 8

ConnectionEstablishmentand Termination

Activeparticipant (client) Passiveparticipant (server) SYN,SequenceNum=x S Y N

  • +
  • A

C K ,

  • S

e q u e n c e N u m

  • =
  • y

, ACK,Acknowledgment=y +1 A c k n

  • w

l e d g m e n t

  • =
  • x

+

  • 1

Spring2002 CS461 9

StateTransitionDiagram

CLOSED LISTEN SYN_RCVD SYN_SENT ESTABLISHED CLOSE_WAIT LAST_ACK CLOSING TIME_WAIT FIN_WAIT_2 FIN_WAIT_1 Passiveopen Close Send/SYN SYN/SYN+ACK SYN+ACK/ACK SYN/SYN+ACK ACK Close/FIN FIN/ACK Close/FIN FIN/ACK ACK+FIN/ACK Timeoutaftertwo segmentlifetimes FIN/ACK ACK ACK ACK Close/FIN Close CLOSED Activeopen/SYN

slide-4
SLIDE 4

4

Spring2002 CS461 10

SlidingWindowRevisited

  • Sendingside

– LastByteAcked <= LastByteSent – LastByteSent <= LastByteWritten – bufferbytesbetween LastByteAcked and LastByteWritten

Sendingapplication LastByteWritten TCP LastByteSent LastByteAcked Receivingapplication LastByteRead TCP LastByteRcvd NextByteExpected

  • Receivingside

– LastByteRead < NextByteExpected – NextByteExpected <= LastByteRcvd+1 – bufferbytesbetween NextByteRead and LastByteRcvd

Spring2002 CS461 11

FlowControl

  • Sendbuffersize:MaxSendBuffer
  • Receivebuffersize:MaxRcvBuffer
  • Receivingside

– LastByteRcvd - LastByteRead <=MaxRcvBuffer – AdvertisedWindow =MaxRcvBuffer - (NextByteExpected - NextByteRead)

  • Sendingside

– LastByteSent - LastByteAcked <=AdvertisedWindow – EffectiveWindow =AdvertisedWindow - (LastByteSent - LastByteAcked) – LastByteWritten - LastByteAcked <=MaxSendBuffer – blocksenderif(LastByteWritten - LastByteAcked)+y > MaxSenderBuffer

  • AlwayssendACKinresponsetoarrivingdatasegment
  • PersistwhenAdvertisedWindow =0

Spring2002 CS461 12

SillyWindowSyndrome

  • Howaggressivelydoessenderexploitopenwindow?
  • Receiver-sidesolutions

– afteradvertisingzerowindow,waitforspaceequaltoa maximumsegmentsize(MSS) – delayedacknowledgements

Sender Receiver

slide-5
SLIDE 5

5

Spring2002 CS461 13

Nagle’sAlgorithm

  • Howlongdoessenderdelaysendingdata?

– toolong:hurtsinteractiveapplications – tooshort:poornetworkutilization – strategies:timer-basedvsself-clocking

  • Whenapplicationgeneratesadditionaldata

– iffillsamaxsegment(andwindowopen):sendit – else

  • ifthereisunack’eddataintransit:bufferituntilACKarrives
  • else:sendit

Spring2002 CS461 14

ProtectionAgainstWrapAround

  • 32-bitSequenceNum

Bandwidth TimeUntilWrapAround T1(1.5Mbps) 6.4hours Ethernet(10Mbps) 57minutes T3(45Mbps) 13minutes FDDI(100Mbps) 6minutes STS-3(155Mbps) 4minutes STS-12(622Mbps) 55seconds STS-24(1.2Gbps) 28seconds

Spring2002 CS461 15

KeepingthePipeFull

  • 16-bitAdvertisedWindow

Bandwidth DelayxBandwidthProduct T1(1.5Mbps) 18KB Ethernet(10Mbps) 122KB T3(45Mbps) 549KB FDDI(100Mbps) 1.2MB STS-3(155Mbps) 1.8MB STS-12(622Mbps) 7.4MB STS-24(1.2 Gbps) 14.8MB

assuming100msRTT

slide-6
SLIDE 6

6

Spring2002 CS461 16

TCPExtensions

  • Implementedasheaderoptions
  • Storetimestampinoutgoingsegments
  • Extendsequencespacewith32-bittimestamp

(PAWS)

  • Shift(scale)advertisedwindow

Spring2002 CS461 17

AdaptiveRetransmission (OriginalAlgorithm)

  • MeasureSampleRTT foreachsegment/ACKpair
  • ComputeweightedaverageofRTT

– EstRTT =α x EstRTT +β x SampleRTT – where α + β =1 − α between0.8and0.9 − β between0.1and0.2

  • SettimeoutbasedonEstRTT

– TimeOut = 2 x EstRTT

Spring2002 CS461 18

Karn/PartridgeAlgorithm

  • DonotsampleRTTwhenretransmitting
  • Doubletimeoutaftereachretransmission

Sender Receiver O r i g i n a l

  • t

r a n s m i s s i

  • n

ACK SampleR TT R e t r a n s m i s s i

  • n

Sender Receiver O r i g i n a l

  • t

r a n s m i s s i

  • n

ACK SampleR TT R e t r a n s m i s s i

  • n
slide-7
SLIDE 7

7

Spring2002 CS461 19

Jacobson/KarelsAlgorithm

  • NewCalculationsforaverageRTT
  • Diff =SampleRTT - EstRTT
  • EstRTT =EstRTT +(δ

δ δ δ x Diff)

  • Dev=Dev+δ

δ δ δ(|Diff|- Dev)

– whereδ isafactorbetween0and1

  • Considervariancewhensettingtimeoutvalue
  • TimeOut =µ x EstRTT +φ x Dev

– whereµ =1andφ =4

  • Notes

– algorithmonlyasgoodasgranularityofclock(500msonUnix) – accuratetimeoutmechanismimportanttocongestioncontrol(later)