Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 1 Transmission Control Protocol (TCP), Tahir Azim.

Slides:



Advertisements
Similar presentations
1 Computer Networks: A Systems Approach, 5e Larry L. Peterson and Bruce S. Davie Chapter 5 End-to-End Protocols Copyright © 2010, Elsevier Inc. All rights.
Advertisements

TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
CSCI 4550/8556 Computer Networks
Slide Set 13: TCP. In this set.... TCP Connection Termination TCP State Transition Diagram Flow Control How does TCP control its sliding window ?
CS 6401 Transport Control Protocol Outline TCP objectives revisited TCP basics New algorithms for RTO calculation.
Computer Networks Chapter 5: End-to-End Protocols
Fundamentals of Computer Networks ECE 478/578 Lecture #20: Transmission Control Protocol Instructor: Loukas Lazos Dept of Electrical and Computer Engineering.
1 Chapter 5 End-to-End Protocols Outline 5.1 UDP 5.2 TCP 5.3 Remote Procedure Call.
1 CS492B Project #2 TCP Tutorial # Jin Hyun Ju.
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Winter 2008CS244a Handout #61 CS244a: An Introduction to Computer Networks Handout 6: The Transport Layer, Transmission Control Protocol (TCP), and User.
1 CS 4396 Computer Networks Lab Transmission Control Protocol (TCP) Part I.
TCP: Transmission Control Protocol Overview Connection set-up and termination Interactive Bulk transfer Timers Improvements.
8. Transport Protocol and UDP 8.1 Transport protocol : End-to-end protocol –IP: Host to host packet delivery –Transport: Process to process communication.
Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
1 Outline  The Transport Layer  The TCP Protocol (RFC 793, 1122, 1323,...)  TCP Characteristics  TCP Connection setup  TCP Segments  TCP Sequence.
1 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
6-May-154/598N: Computer Networks End-to-End Protocols Underlying best-effort network –drop messages –re-orders messages –delivers duplicate copies of.
Chapter 7 – Transport Layer Protocols
CSE Computer Networks Prof. Aaron Striegel Department of Computer Science & Engineering University of Notre Dame Lecture 14 – February 23, 2010.
ECE 4450:427/527 - Computer Networks Spring 2015 Dr. Nghi Tran Department of Electrical & Computer Engineering Lecture 7.1: End-to-end Protocols Dr. Nghi.
TCP 4/15/2017.
Fundamentals of Computer Networks ECE 478/578 Lecture #21: TCP Window Mechanism Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University.
CSE 124 Networked Services Fall 2009 B. S. Manoj, Ph.D 10/20/20091CSE 124 Networked Services Fall 2009 Some.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Spring 2003CS 4611 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Transport Layer TCP and UDP IS250 Spring 2010
Spring 2002CS 4611 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
1 Transport Layer Computer Networks. 2 Where are we?
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
1 Introduction to Computer Networks University of ilam Dr. Mozafar Bag-Mohammadi Transport Layer.
1 TCP: Reliable Transport Service. 2 Transmission Control Protocol (TCP) Major transport protocol used in Internet Heavily used Completely reliable transfer.
Chapter 24 Transport Control Protocol (TCP) Layer 4 protocol Responsible for reliable end-to-end transmission Provides illusion of reliable network to.
1 CS 4396 Computer Networks Lab TCP – Part II. 2 Flow Control Congestion Control Retransmission Timeout TCP:
1 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
ECE 4110 – Internetwork Programming
© Jörg Liebeherr (modified by Malathi Veeraraghavan) 1 Overview Formats, Data Transfer, etc. Connection Management.
Transport Protocols.
Retransmission. Automatic Repeat reQuest (ARQ) 2 Time Packet ACK Timeout Automatic Repeat Request –Receiver sends acknowledgment (ACK) when it receives.
IP1 The Underlying Technologies. What is inside the Internet? Or What are the key underlying technologies that make it work so successfully? –Packet Switching.
1 Reliable Byte-Stream (TCP) Outline Connection Establishment/Termination Sliding Window Revisited Flow Control Adaptive Timeout.
Ilam University Dr. Mozafar Bag-Mohammadi 1 Transport Layer.
EE 122: Transport Protocols Kevin Lai October 16, 2002.
1 End-to-End Protocols UDP TCP –Connection Establishment/Termination –Sliding Window Revisited –Flow Control –Congestion Control –Adaptive Timeout.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Advanced Computer Networks
Transport Control Protocol
5. End-to-end protocols (part 1)
TCP.
TCP - Part I Karim El Defrawy
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
TCP Overview Connection-oriented Byte-stream Full duplex
Transport Control Protocol
Reliable Byte-Stream (TCP)
Ilam University Dr. Mozafar Bag-Mohammadi
Transmission Control Protocol (TCP) Part II Neil Tang 11/21/2008
State Transition Diagram
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
The University of Adelaide, School of Computer Science
Introduction to Computer Networks
Introduction to Computer Networks
Transport Layer 9/22/2019.
Presentation transcript:

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 1 Transmission Control Protocol (TCP), Tahir Azim

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 2 The Need for TCP  Network Layer (IP) provides a best-effort service  Need to build a reliable layer on top of IP  Possible problems sending messages from one host to another:  May be lost  May be reordered  May be delivered multiple times  May be delivered after a long delay  May be broken into smaller messages  May be corrupted

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 3 Need for TCP 2  Support services needed by the application  Multiple connections per host  Guaranteed delivery  Messages delivered in the order they were sent  Messages delivered at most once  No limit on message size  Messages not corrupted  Synchronization between sender and receiver  Flow control

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 4 Can this be done hop-by-hop instead of end-to-end?  Think of this like the postal service  One major problem: Nodes would not know what happened two or more hops ahead of them  Routing tables incorrect, packets dropped, machine crashed, link failed…  Only ends can be sure of receipt/non-receipt of a message  For others: read “End-to-end arguments for System Design”… Classic, must-read paper, could be on exam

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 5 TCP Usage Model  Connection setup  3-way handshake  Data transport  Sender writes data  TCP  Breaks data into segments Sends each segment over IP Retransmits, reorders and removes duplicates as necessary Receiver reads some data  Teardown  4 step exchange

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 6 TCP Characteristics  TCP is connection-oriented.  3-way handshake used for connection setup.  TCP provides a stream-of-bytes service.  TCP is full-duplex; data can flow in both directions simultaneously  TCP is reliable:  Acknowledgements indicate delivery of data.  Checksums are used to detect corrupted data.  Detects missing sequence numbers or mis-sequenced data.  Corrupted data is retransmitted after a timeout.  Out of order bytes of data are reordered.  (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 lectures.

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 7 TCP is connection-oriented Connection Setup 3-way handshake (Active) Client (Passive) Server Syn (ISN A ) Syn (ISN B ) + Ack (ISN A +1) Ack (ISN B +1) Connection Close/Teardown 2 x 2-way handshake (Active) Client (Passive) Server Fin (SN A ) (Data +) Ack (SN A +1) Fin (SN B ) Ack (SN B +1)

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 8 TCP supports a “stream of bytes” service Byte 0Byte 1 Byte 2Byte 3 Byte 0Byte 1Byte 2Byte 3 Host A Host B Byte 80

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 9 …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, default 352), 2.Not full, but times out, or 3.“Pushed” by application.

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 10 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

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 11 TCP Segment Header  16-bit source and destination ports  32-bit send and ACK sequence numbers  4-bit header length in 4-byte words  Minimum value of 5  Offset to first data byte  6 1-bit flags  URG: Segment contains urgent data  ACK: ACK sequence number is valid  PSH: Do not delay delivery of data  RST: Reset connection (reject or abn. termination)  SYN: Synchronize segment for setup  FIN: Final segment for teardown

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 12 TCP Segment header  16-bit advertised window  Space remaining in receive window  16-bit checksum  Uses IP checksum algorithm  Computed on header and data  16-bit urgent data pointer  If URG = 1  Index of last byte of urgent data in segment

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 13 TCP Options  Negotiate maximum segment size (MSS)  Each host suggests a value  Minimum of two values is chosen  Prevents IP fragmentation over first and last hops  Packet timestamp  Allows RTT calculation for retransmitted packets  Extends sequence number space for identification of stray packets  Negotiate advertised window granularity  Allows windows to be scaled to larger sizes  Good for routes with large bandwidth-delay products

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 14 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

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 15 TCP State Transition Diagram  Original ASCII art diagram in RFC 793

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 16 TCP State Descriptions CLOSEDDisconnected LISTENWaiting for incoming connection SYN_RCVDConnection request received SYN_SENTConnection request sent ESTABLISHEDConnection ready for data transport CLOSE_WAITConnection closed by peer LAST_ACKConnection closed by peer, closed locally, await ACK FIN_WAIT_1Connection closed locally FIN_WAIT_2Connection closed locally and ACK’d CLOSING Connection closed by both sides simultaneously TIME_WAIT Wait for network to discard related packets

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 17 TCP State Transition Diagram

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 18 TCP State Transition Diagram

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 19 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?

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 20 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”.

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 21 TCP Sliding Window Protocol – Sender Side  Variables:  LastByteAcked: The last byte acked by receiver  LastByteSent: The last byte sent by sender  LastByteWritten: The last byte written by application layer onto the transport layer  LastByteAcked <= LastByteSent  LastByteSent <= LastByteWritten  Buffer bytes between LastByteAcked and LastByteWritten

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 22 TCP Sliding Window Protocol – Receiver Side  Variables:  LastByteRcvd: The last byte received by receiver  NextByteExpected : The next byte still to be received from the sender  LastByteRead: The last byte passed to the application layer by the transport layer  LastByteRead < NextByteExpected  NextByteExpected <= LastByteRcvd + 1  Buffer bytes between LastByteRead and LastByteRcvd

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 23 TCP Flow Control  Receiving side  Receive buffer size = MaxRcvBuffer  LastByteRcvd - LastByteRead < = MaxRcvBuffer  AdvertisedWindow= MaxRcvBuffer - (NextByteExpected - LastByteRead) Shrinks as data arrives and Grows as the application consumes data  Sending side  Send buffer size = MaxSendBuffer  LastByteSent - LastByteAcked < = AdvertisedWindow  EffectiveWindow = AdvertisedWindow - (LastByteSent – LastByteAcked) EffectiveWindow > 0 to send data  LastByteWritten - LastByteAcked < = MaxSendBuffer  block sender if (LastByteWritten – LastByteAcked) > MaxSenderBuffer

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 24 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 ???

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 25 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

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 26 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

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 27 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.

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 28 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

Courtesy: Nick McKeown, Stanford Umar Kalim, NIIT Robin Kravets, UIUC 29 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).