Presentation is loading. Please wait.

Presentation is loading. Please wait.

Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User.

Similar presentations


Presentation on theme: "Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User."— Presentation transcript:

1 Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User Datagram Protocol (UDP) Nick McKeown Professor of Electrical Engineering and Computer Science, Stanford University

2 Winter 2008CS244a Handout #62 Outline  The Transport Layer  The TCP Protocol  TCP Characteristics  TCP Connection setup  TCP Segments  TCP Sequence Numbers  TCP Sliding Window  Timeouts and Retransmission  (Congestion Control and Avoidance)  The UDP Protocol

3 Winter 2008CS244a Handout #63 The Transport Layer  What is the transport layer for?  What characteristics might it have?  Reliable delivery  Flow control  …

4 Winter 2008CS244a Handout #64 Review of the transport layer NickDave Leland.Stanford.edu Athena.MIT.edu Network Layer Link Layer Application Layer Transport Layer O.S. HeaderDataHeaderData HD HD HD HDHD HD

5 Winter 2008CS244a Handout #65 Layering: The OSI Model Session Network Link Physical Application Presentation Transport Network Link Network Transport Session Presentation Application Network Link Physical Peer-layer communication layer-to-layer communication Router

6 Winter 2008CS244a Handout #66 Layering: Our FTP Example Network Link Transport Application Presentation Session Transport Network Link Physical The 7-layer OSI Model The 4-layer Internet model Application FTP ASCII/Binary IP TCP Ethernet

7 Winter 2008CS244a Handout #67 TCP Characteristics  TCP is connection-oriented.  3-way handshake used for connection setup.  TCP provides a stream-of-bytes service.  TCP is reliable:  Acknowledgements indicate delivery of data.  Checksums are used to detect corrupted data.  Sequence numbers detect missing, or mis-sequenced data.  Corrupted data is retransmitted after a timeout.  Mis-sequenced data is re-sequenced.  (Window-based) Flow control prevents over-run of receiver.  TCP uses congestion control to share network capacity among users. We’ll study this in the next lecture.

8 Winter 2008CS244a Handout #68 TCP is connection-oriented Connection Setup 3-way handshake (Active) Client (Passive) Server Syn Syn + Ack Ack Connection Close/Teardown 2 x 2-way handshake (Active) Client (Passive) Server Fin (Data +) Ack Fin Ack

9 Winter 2008CS244a Handout #69 TCP supports a “stream of bytes” service Byte 0Byte 1 Byte 2Byte 3 Byte 0Byte 1Byte 2Byte 3 Host A Host B Byte 80

10 Winter 2008CS244a Handout #610 …which is emulated using TCP “segments” Byte 0Byte 1 Byte 2Byte 3 Byte 0Byte 1Byte 2Byte 3 Host A Host B Byte 80 TCP Data Byte 80 Segment sent when: 1.Segment full (MSS bytes), 2.Not full, but times out, or 3.“Pushed” by application.

11 Winter 2008CS244a Handout #611 The TCP Segment Format IP Hdr IP Data TCP HdrTCP Data Src portDst port Sequence # Ack Sequence # HLEN 4 RSVD 6 URGACK PSH RSTSYNFIN Flags Window Size ChecksumUrg Pointer (TCP Options) TCP Data TCP Header and Data + IP Addresses Src/dst port numbers and IP addresses uniquely identify socket

12 Winter 2008CS244a Handout #612 Sequence Numbers Host A Host B TCP Data TCP HDR TCP HDR ISN (initial sequence number) Sequence number = 1 st byte Ack sequence number = next expected byte

13 Winter 2008CS244a Handout #613 Initial Sequence Numbers Connection Setup 3-way handshake (Active) Client (Passive) Server Syn +ISN A Syn + Ack +ISN B Ack

14 Winter 2008CS244a Handout #614 TCP Sliding Window  How much data can a TCP sender have outstanding in the network?  How much data should TCP retransmit when an error occurs? Just selectively repeat the missing data?  How does the TCP sender avoid over- running the receiver’s buffers?

15 Winter 2008CS244a Handout #615 TCP Sliding Window Window Size Outstanding Un-ack’d data Data OK to send Data not OK to send yet Data ACK’d  Window is meaningful to the sender.  Current window size is “advertised” by receiver (usually 4k – 8k Bytes when connection set-up).  TCP’s Retransmission policy is “Go Back N”.

16 Winter 2008CS244a Handout #616 TCP Sliding Window Host A Host B ACK Window Size Round-trip time (1) RTT > Window size ACK Window Size Round-trip time (2) RTT = Window size ACK Window Size ???

17 Winter 2008CS244a Handout #617 TCP: Retransmission and Timeouts Host A Host B ACK Round-trip time (RTT) ACK Retransmission TimeOut (RTO) Estimated RTT Data1Data2 Guard Band TCP uses an adaptive retransmission timeout value: Congestion Changes in Routing RTT changes frequently

18 Winter 2008CS244a Handout #618 TCP: Retransmission and Timeouts Picking the RTO is important:  Pick a values that’s too big and it will wait too long to retransmit a packet,  Pick a value too small, and it will unnecessarily retransmit packets. The original algorithm for picking RTO: 1. EstimatedRTT k =  EstimatedRTT k-1 + (1 -  ) SampleRTT 2. RTO = 2 * EstimatedRTT Characteristics of the original algorithm:  Variance is assumed to be fixed.  But in practice, variance increases as congestion increases. Determined empirically

19 Winter 2008CS244a Handout #619 TCP: Retransmission and Timeouts  There will be some (unknown) distribution of RTTs.  We are trying to estimate an RTO to minimize the probability of a false timeout. RTT Probability mean variance Load (Amount of traffic arriving to router) Average Queueing Delay Variance grows rapidly with load  Router queues grow when there is more traffic, until they become unstable.  As load grows, variance of delay grows rapidly.

20 Winter 2008CS244a Handout #620 TCP: Retransmission and Timeouts Newer Algorithm includes estimate of variance in RTT:  Difference = SampleRTT - EstimatedRTT  EstimatedRTT k = EstimatedRTT k-1 + (  *Difference)  Deviation = Deviation +  *( |Difference| - Deviation )  RTO =  * EstimatedRTT +  * Deviation   1   4 Same as before

21 Winter 2008CS244a Handout #621 TCP: Retransmission and Timeouts Karn’s Algorithm Retransmission Wrong RTT Sample Host AHost B Retransmission Wrong RTT Sample Host AHost B Problem: How can we estimate RTT when packets are retransmitted? Solution: On retransmission, don’t update estimated RTT (and double RTO).

22 Winter 2008CS244a Handout #622 User Datagram Protocol (UDP) Characteristics  UDP is a connectionless datagram service.  There is no connection establishment: packets may show up at any time.  UDP packets are self-contained.  UDP is unreliable:  No acknowledgements to indicate delivery of data.  Checksums cover the header, and only optionally cover the data.  Contains no mechanism to detect missing or mis-sequenced packets.  No mechanism for automatic retransmission.  No mechanism for flow control, and so can over-run the receiver.

23 Winter 2008CS244a Handout #623 User-Datagram Protocol (UDP) App A1A1 A2A2 B1B1 B2B2 UDP OS IP Like TCP, UDP uses port number to demultiplex packets

24 Winter 2008CS244a Handout #624 SRC port DST port checksumlength DATA User-Datagram Protocol (UDP) Packet format  Why do we have UDP?  It is used by applications that don’t need reliable delivery, or  Applications that have their own special needs, such as streaming of real-time audio/video. By default, only covers the header.


Download ppt "Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User."

Similar presentations


Ads by Google