Internetworking Technologies Transmission Control Protocol TCP TDC 365

  • Slides: 34
Download presentation
Internetworking Technologies Transmission Control Protocol (TCP) TDC 365 Spring 2001 John Kristoff - De.

Internetworking Technologies Transmission Control Protocol (TCP) TDC 365 Spring 2001 John Kristoff - De. Paul University 1

IP review � IP provides just enough 'connectedness' � Global addressing � Hop-by-hop �

IP review � IP provides just enough 'connectedness' � Global addressing � Hop-by-hop � IP routing over everything � Ethernet, � Lack ATM, X. 25, SONET, etc. of state in the network � Unreliable TDC 365 Spring 2001 packet (datagram) switching John Kristoff - De. Paul University 2

TCP key features � Sequencing � Byte-stream delivery � Connection-oriented � Reliability TDC 365

TCP key features � Sequencing � Byte-stream delivery � Connection-oriented � Reliability TDC 365 Spring 2001 John Kristoff - De. Paul University 3

TCP feature summary Provides a completely reliable (no data duplication or loss), connection-oriented, full-duplex

TCP feature summary Provides a completely reliable (no data duplication or loss), connection-oriented, full-duplex stream transport service that allows two application programs to form a connection, send data in either direction and then terminate the connection. TDC 365 Spring 2001 John Kristoff - De. Paul University 4

Apparent contradiction � IP offers best-effort (unreliable) delivery � TCP uses IP � TCP

Apparent contradiction � IP offers best-effort (unreliable) delivery � TCP uses IP � TCP provides completely reliable transfer � How is this possible? TDC 365 Spring 2001 John Kristoff - De. Paul University 5

Achieving reliability � Reliable connection startup � Reliable data transfer � Sender starts a

Achieving reliability � Reliable connection startup � Reliable data transfer � Sender starts a timer � Receiver sends ACK when data arrives � Sender retransmits if timer expires before ACK is returned � Reliable connection shutdown TDC 365 Spring 2001 John Kristoff - De. Paul University 6

Reliability illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 7

Reliability illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 7

How long to wait before retransmitting? � Time for ACK to return depends on:

How long to wait before retransmitting? � Time for ACK to return depends on: � Distance � Network � End traffic conditions system conditions � Packets � Traffic between sender/receiver can be lost, damaged or fragmented conditions can change rapidly TDC 365 Spring 2001 John Kristoff - De. Paul University 8

Solving the retransmission problem � Keep running average of round trip time (RTT) for

Solving the retransmission problem � Keep running average of round trip time (RTT) for each TCP connection � Current average (estimate) determines retransmission timer � How does each RTT affect the average? � This is known as adaptive retransmission � Key to TCP's success TDC 365 Spring 2001 John Kristoff - De. Paul University 9

Adaptive retranmission illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 10

Adaptive retranmission illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 10

Flow control " Match sending rate to receiver rate � TCP uses a sliding

Flow control " Match sending rate to receiver rate � TCP uses a sliding window � Receiver � Also advertises available buffer space known as the window � Sender can transmit a full window size before receiving an ACK TDC 365 Spring 2001 John Kristoff - De. Paul University 11

Window advertisement " Each ACK carries the current window size � Called � Can

Window advertisement " Each ACK carries the current window size � Called � Can " the window advertisement be zero (a closed window) Interpretation of window advertisement: � Receiver: I can accept X octets or less unless I tell you otherwise TDC 365 Spring 2001 John Kristoff - De. Paul University 12

Window advertisement illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 13

Window advertisement illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 13

Another view: the sliding window TDC 365 Spring 2001 John Kristoff - De. Paul

Another view: the sliding window TDC 365 Spring 2001 John Kristoff - De. Paul University 14

Byte stream sequencing � Each segment contains a sequence number � Sequencing � TCP

Byte stream sequencing � Each segment contains a sequence number � Sequencing � TCP � Is helps ensure in-order delivery sequence numbers are fixed at 32 bits the byte stream of limited size (232 bytes)? � Initial sequence numbers (ISN) are exchanged at connection startup � ACKs acknowledgement cumulative bytes TDC 365 Spring 2001 John Kristoff - De. Paul University 15

TCP segment format TDC 365 Spring 2001 John Kristoff - De. Paul University 16

TCP segment format TDC 365 Spring 2001 John Kristoff - De. Paul University 16

Application multiplexing � Separation � In of functionality from IP the beginning TCP and

Application multiplexing � Separation � In of functionality from IP the beginning TCP and IP were one � No unused bits to encode application process � Cannot use OS dependent quality � Process � Task � Job ID number name � Semantics TDC 365 Spring 2001 must work on all end systems John Kristoff - De. Paul University 17

Port numbers � Separation � In of functionality from IP the beginning TCP and

Port numbers � Separation � In of functionality from IP the beginning TCP and IP were one � No unused bits to encode application process � Cannot use OS dependent quality � Process � Task � Job ID number name � Semantics TDC 365 Spring 2001 must work on all end systems John Kristoff - De. Paul University 18

TCP ports � Each application assigned a unique integer � Server � Follows �

TCP ports � Each application assigned a unique integer � Server � Follows � Uses a standard (e. g. Well know ports) a well known port number � Usually uses lower port numbers � Client � Obtains unused port from protocol software � Usually uses high numbered ports TDC 365 Spring 2001 John Kristoff - De. Paul University 19

TCP connection startup � Uses a three message exchange � AKA 3 -way handshake

TCP connection startup � Uses a three message exchange � AKA 3 -way handshake � Necessary and sufficient for unambiguous and reliable startup � Sequence � Can number exchange is primary goal also exchange other parameters � e. g. maximum segment size TDC 365 Spring 2001 John Kristoff - De. Paul University 20

3 -way handshake illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University

3 -way handshake illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 21

TCP connection shutdown TDC 365 Spring 2001 John Kristoff - De. Paul University 22

TCP connection shutdown TDC 365 Spring 2001 John Kristoff - De. Paul University 22

Congestion � Flow control � Congestion control � Avoidance TDC 365 Spring 2001 John

Congestion � Flow control � Congestion control � Avoidance TDC 365 Spring 2001 John Kristoff - De. Paul University 23

Useful terms before proceding � Maximum segment size (MSS) � Window � Retransmission �

Useful terms before proceding � Maximum segment size (MSS) � Window � Retransmission � Timer � Delayed ACK � Duplicate TDC 365 Spring 2001 ACK John Kristoff - De. Paul University 24

Congestion window � Sender based flow control � Rather � Sender � This than

Congestion window � Sender based flow control � Rather � Sender � This than by a window advertisement uses min(cwnd, advertised window) is the transmission window � Infer network conditions and adjust � Use timers, ACKs and network feedback TDC 365 Spring 2001 John Kristoff - De. Paul University 25

TCP segment retransmission � TCP starts timer after sending a segment � If ACK

TCP segment retransmission � TCP starts timer after sending a segment � If ACK returns, reset timer � If not, retransmit and set (timer = timer x 2) � This � Can't � Timer is backoff retransmit forever, error may occur is the estimate of round trip time (RTT) � Current, TDC 365 Spring 2001 running average of RTT John Kristoff - De. Paul University 26

Round trip time (RTT) � TCP measures RTT � TCP uses estimated RTT to

Round trip time (RTT) � TCP measures RTT � TCP uses estimated RTT to calculate timers � If ACKs return quickly, timers are short � If loss occurs, recovery is quicker � The converse is also true � RTT too high = throughput suffers � RTT too low = unnecessary retransmits TDC 365 Spring 2001 John Kristoff - De. Paul University 27

TCP slow start � Initialize cwnd to 1 MSS � Increase cwnd by 1

TCP slow start � Initialize cwnd to 1 MSS � Increase cwnd by 1 MSS for every ACK � Not really that slow TDC 365 Spring 2001 John Kristoff - De. Paul University 28

TCP congestion avoidance � When timer expires (loss? ), slow down! � Set ssthresh

TCP congestion avoidance � When timer expires (loss? ), slow down! � Set ssthresh = (transmission window x ½) � Set cwnd = 1 � Transmit � Slow min(cwnd, transmission window) start until transmission window = sshtresh � Thereafter, TDC 365 Spring 2001 increase cwnd by 1/cwnd per ACK John Kristoff - De. Paul University 29

Congestion avoidance illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 30

Congestion avoidance illustrated TDC 365 Spring 2001 John Kristoff - De. Paul University 30

TCP fast retransmit � If 3 or more duplicate ACKs are received before timer

TCP fast retransmit � If 3 or more duplicate ACKs are received before timer has expired � Sender assumes loss � Assumes out of order packets had enough time to be reassembled � Retransmit � Enter without waiting for timer to expire TCP fast recovery TDC 365 Spring 2001 John Kristoff - De. Paul University 31

TCP fast recovery � Sender � Due � Loss � Go assumes data is

TCP fast recovery � Sender � Due � Loss � Go assumes data is still flowing to the reception of duplicate ACKs was probably a temporary event into congestion avoidance, not slow start � Just cut cwnd in half � Resume TDC 365 Spring 2001 additive increase (1/cwnd) per ACK John Kristoff - De. Paul University 32

Other mechanisms �Selective �Traffic acknowledgements (SACK) shaping �ACK pacing �AQM (FIFO and RED and

Other mechanisms �Selective �Traffic acknowledgements (SACK) shaping �ACK pacing �AQM (FIFO and RED and variants) �ECN, ICMP source quench, back pressure �Fair queueing �Class/uality TDC 365 Spring 2001 of service (Co. S/Qo. S) John Kristoff - De. Paul University 33

Congestion collapse �When network load increases and less actual work gets done due to

Congestion collapse �When network load increases and less actual work gets done due to packet drops �Fragmented �As packets are especially bad retransmissions increase, goodput drops TDC 365 Spring 2001 John Kristoff - De. Paul University 34