Reliable Byte Stream TCP Outline Connection Establishment Termination Sliding Window Revisited Flow Control Adaptive Timeout 1 End to End Protocols Underlying best effort network drop messages re orders messages delivers duplicate copies of a given message limits messages to some finite size delivers messages after an arbitrarily long delay Common end to end services guarantee message delivery deliver messages in the same order they are sent deliver at most one copy of each message support arbitrarily large messages support synchronization allow the receiver to flow control the sender support multiple application processes on each host 2 TCP Overview Full duplex Flow control keep sender from overrunning receiver Congestion control keep sender from overrunning network Connection oriented Byte stream app writes bytes TCP sends segments app reads bytes Application process Application process Write bytes TCP Send buffer Segment Read bytes TCP Receive buffer Segment Segment Transmit segments 3 Data Link Versus Transport Potentially connects many different hosts need explicit connection establishment and termination Potentially different RTT need adaptive timeout mechanism Potentially long delay in network need to be prepared for arrival of very old packets Potentially different capacity at destination need to accommodate different node capacity Potentially different network capacity need to be prepared for network congestion 4 Segment Format 0 10 4 16 31 SrcPort DstPort SequenceNum Acknowledgment HdrLen 0 Flags AdvertisedWindow Checksum UrgPtr Options variable Data 5 Segment Format cont Each connection identified with 4 tuple SrcPort SrcIPAddr DsrPort DstIPAddr Sliding window flow control acknowledgment SequenceNum AdvertisedWinow Data SequenceNum Sender Flags Receiver Acknowledgment SYN FIN RESET PUSH URG ACK AdvertisedWindow Checksum pseudo header TCP header data 6 Connection Establishment and Termination Active participant client Passive participant server SYN Sequ enc eNum x y m u nceN e u q 1 e x S t K en m g d owle n k c A A SYN C ACK Ackno wledg ment y 1 7 State Transition Diagram CLOSED Active open SYN Passive open Close Close LISTEN SYN RCVD SYN SYN ACK Send SYN SYN SYN ACK ACK Close FIN SYN ACK ACK ESTABLISHED Close FIN FIN ACK FIN WAIT 1 ACK FIN WAIT 2 SYN SENT CLOSE WAIT AC FIN ACK K FI N AC K FIN ACK Close FIN CLOSING ACK Timeout after two segment lifetimes TIME WAIT LAST ACK ACK CLOSED 8 Sliding Window Revisited Sending application Receiving application TCP LastByteWritten LastByteAcked LastByteSent Sending side LastByteAcked LastByteSent LastByteSent LastByteWritten buffer bytes between LastByteAcked and LastByteWritten TCP LastByteRead NextByteExpected LastByteRcvd Receiving side LastByteRead NextByteExpected NextByteExpected LastByteRcvd 1 buffer bytes between NextByteRead and LastByteRcvd 9 Flow Control Send buffer size MaxSendBuffer Receive buffer size MaxRcvBuffer Receiving side LastByteRcvd LastByteRead MaxRcvBuffer AdvertisedWindow MaxRcvBuffer LastByteRcvd NextByteRead Sending side LastByteSent LastByteAcked AdvertisedWindow EffectiveWindow AdvertisedWindow LastByteSent LastByteAcked LastByteWritten LastByteAcked MaxSendBuffer block sender if LastByteWritten LastByteAcked y MaxSenderBuffer Always send ACK in response to arriving data segment Persist when AdvertisedWindow 0 10 Protection Against Wrap Around 32 bit SequenceNum Bandwidth T1 1 5 Mbps Ethernet 10 Mbps T3 45 Mbps FDDI 100 Mbps STS 3 155 Mbps STS 12 622 Mbps STS 24 1 2 Gbps Time Until Wrap Around 6 4 hours 57 minutes 13 minutes 6 minutes 4 minutes 55 seconds 28 seconds 11 Keeping the Pipe Full 16 bit AdvertisedWindow Bandwidth T1 1 5 Mbps Ethernet 10 Mbps T3 45 Mbps FDDI 100 Mbps STS 3 155 Mbps STS 12 622 Mbps STS 24 1 2 Gbps Delay x Bandwidth Product 18KB 122KB 549KB 1 2MB 1 8MB 7 4MB 14 8MB 12 TCP Extensions Implemented as header options Store timestamp in outgoing segments Extend sequence space with 32 bit timestamp PAWS Shift scale advertised window 13 Adaptive Retransmission Original Algorithm Measure SampleRTT for each segment ACK pair Compute weighted average of RTT EstRTT x EstimatedRTT x SampleRTT where 1 between 0 8 and 0 9 between 0 1 and 0 2 Set timeout based on EstRTT TimeOut 2 x EstRTT 14 Karn Partridge Algorithm Receiver SampleR TT Orig in Retr al tra n ans m s m is issio ACK n Sender Orig in s ion SampleR TT Sender Receiver al t ra ns m is s io ACK Retr ans m n issio n Do not sample RTT when retransmitting Double timeout after each retransmission 15 Jacobson Karels Algorithm New Calculations for average RTT Diff sampleRTT EstRTT EstRTT EstRTT 8 x Diff Dev Dev 8 Diff Dev where 8 is a factor between 0 and 1 Consider variance when setting timeout value TimeOut x EstRTT x Dev where 1 and 4 Notes algorithm only as good as granularity of clock 500ms on Unix accurate timeout mechanism important to congestion control later 16
View Full Document