ECE 4110 – Internetwork Programming

Slides:



Advertisements
Similar presentations
CS144 Review Session 4 April 25, 2008 Ben Nham
Advertisements

TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Transmission Control Protocol (TCP)
Intermediate TCP/IP TCP Operation.
Guide to TCP/IP, Third Edition
1 TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
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.
Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.
1 Transport Layer - UDP & TCP Protocols "I cannot teach anybody anything, I can only make them think.” - Socrates.
1 TCP - Part II. 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information.
1 TCP CSE May TCP Services Flow control Connection establishment and termination Congestion control 2.
UNIT 07 Process – to – Process Delivery: UDP,TCP and SCTP
Transport Layer 3-1 Fast Retransmit r time-out period often relatively long: m long delay before resending lost packet r detect lost segments via duplicate.
TDC365 Spring 2001John Kristoff - DePaul University1 Internetworking Technologies Transmission Control Protocol (TCP)
Chapter 15 Transmission Control Protocol (TCP)
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
TDC375 Winter 03/04 John Kristoff - DePaul University 1 Network Protocols Transmission Control Protocol (TCP)
Department of Electronic Engineering City University of Hong Kong EE3900 Computer Networks Transport Protocols Slide 1 Transport Protocols.
1 K. Salah Module 6.1: TCP Flow and Congestion Control Connection establishment & Termination Flow Control Congestion Control QoS.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Ch 23 Ameera Almasoud Based on Data Communications and Networking, 4th Edition. by Behrouz A. Forouzan, McGraw-Hill Companies, Inc., 2007.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
Process-to-Process Delivery:
Process-to-Process Delivery:
1 Transport Layer Computer Networks. 2 Where are we?
Copyright © Lopamudra Roychoudhuri
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 2.5 Internetworking Chapter 25 (Transport Protocols, UDP and TCP, Protocol Port Numbers)
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
Chapter 12 Transmission Control Protocol (TCP)
1 TCP: Reliable Transport Service. 2 Transmission Control Protocol (TCP) Major transport protocol used in Internet Heavily used Completely reliable transfer.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 12 Transmission Control Protocol (TCP)
23.1 Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 12 Transmission Control Protocol (TCP). Outline  PROCESS-TO-PROCESS COMMUNICATION  TCP SERVICES  NUMBERING BYTES  FLOW CONTROL  SILLY WINDOW.
Copyright © Lopamudra Roychoudhuri
Networking Basics CCNA 1 Chapter 11.
TCP: Transmission Control Protocol Part II : Protocol Mechanisms Computer Network System Sirak Kaewjamnong Semester 1st, 2004.
1 CS 4396 Computer Networks Lab TCP – Part II. 2 Flow Control Congestion Control Retransmission Timeout TCP:
1 TCP Timeout And Retransmission Chapter 21 TCP sets a timeout when it sends data and if data is not acknowledged before timeout expires it retransmits.
Computer Networks23-1 PART 5 Transport Layer. Computer Networks23-2 Position of Transport Layer Responsible for the delivery of a message from one process.
1 TCP - Part II. 2 What is Flow/Congestion/Error Control ? Flow Control: Algorithms to prevent that the sender overruns the receiver with information.
NET 221D:COMPUTER NETWORKS FUNDAMENTALS Lecture : Transport Layer: Behrouz A. Forouzan” Data communications and Networking 1.
TCP Timeout and Retransmission
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 Chapter 12 Transmission Control Protocol (TCP)
1 Computer Communication & Networks Lecture 23 & 24 Transport Layer: UDP and TCP Waleed Ejaz
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Transmission Control Protocol (TCP) TCP Flow Control and Congestion Control CS 60008: Internet Architecture and Protocols Department of CSE, IIT Kharagpur.
Computer Networks 1000-Transport layer, TCP Gergely Windisch v spring.
1 TCP ProtocolsLayer name DNSApplication TCP, UDPTransport IPInternet (Network ) WiFi, Ethernet Link (Physical)
1 Transmission Control Protocol (TCP) RFC: Introduction The TCP is intended to provide a reliable process-to-process communication service in a.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
1 Chapter 24 Internetworking Part 4 (Transport Protocols, UDP and TCP, Protocol Port Numbers)
TCP/IP Protocol Suite 1 Chapter 12 Upon completion you will be able to: Transmission Control Protocol Be able to name and understand the services offered.
TCP - Part II.
Fast Retransmit For sliding windows flow control we waited for a timer to expire before beginning retransmission of a packet TCP uses an additional mechanism.
Chapter 15 Transmission Control Protocol (TCP)
Chapter 15 Transmission Control Protocol (TCP)
Process-to-Process Delivery, TCP and UDP protocols
TCP.
PART 5 Transport Layer Computer Networks.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 15 Transmission Control Protocol.
Transmission Control Protocol (TCP)
Chapter 15 Transmission Control Protocol (TCP)
CS4470 Computer Networking Protocols
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
TCP: Transmission Control Protocol Part II : Protocol Mechanisms
Presentation transcript:

ECE 4110 – Internetwork Programming Transmission Control Protocol: TCP

Transmission Control Protocol (TCP) Connection-oriented Provides Process-to-process communication (using ports) Byte stream delivery: Receiver cannot tell what size the individual writes (by the sender) were. Full-duplex service (each direction is handled separately) Flow control Reliable service. Uses ACKs. Takes care of: Lost packets Damaged packets Duplicate packets Out-of-sequence packets Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Process-to-Process Communication Port Numbers * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

ECE 4110 – Internetwork Programming Stream Delivery Data from the application layer is treated as a stream of bytes. Remember: In UDP, each packet is treated independently. TCP creates an imaginary tube to carry the stream. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Stream Delivery (cont’d) * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sending and Receiving Buffers TCP needs send and receive buffers. Flow Control: Sender and receiver may transmit/receive at different rates. Error Control: Sender may need to retransmit packets. Send and receive buffers need not be the same size. Use circular buffers. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sending and Receiving Buffers (cont’d) White: Empty Gray: Sent but not ACK’d Pink: Not sent yet White: Empty Pink: Received, but not delivered to the process yet. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Segments IP handles packets, not byte streams. So, TCP has to group bytes into segments. A header is also added to each segment for control purposes. Segments need not be the same size. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Segments (cont’d) * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Segments (cont’d) Numbering: TCP header has two fields to keep track of segments: segment number and acknowledgment number. Both fields refer to byte number, not segment number. Numbering is used for flow and error control. Numbering is independent in each direction. Numbering need not start from 0 (a random value between 0 and 232-1. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Segments (cont’d) Numbering (cont’d): SEQ# is the number of the first byte in the sequence. ACK# is the number of the next byte receiver expects to receive. ACK# is cumulative, i.e., all bytes from the start to ACK#-1 are received properly. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

TCP Segments: Example for Sequence Number Imagine a TCP connection is transferring a file of 6000 bytes. First byte is numbered 10010. What are the sequence numbers for each segment if data is sent in five segments with the first four segments carrying 1,000 bytes and the last segment carrying 2,000 bytes? Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

TCP Segments: Example for Sequence Number (Solution) Segment 1  10,010 (10,010 to 11,009) Segment 2  11,010 (11,010 to 12,009) Segment 3  12,010 (12,010 to 13,009) Segment 4  13,010 (13,010 to 14,009) Segment 5  14,010 (14,010 to 16,009) Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Flow Control in TCP Control the rate at which the sender transmits the data. Avoid overwhelming the destination or any node on the path. Extremes: One ACK for each byte Too slow Too much overhead (ACK larger than data) One ACK for all data Very fast May overwhelm some node(s) Whole stream must be retransmitted in case of error Use Sliding Window Protocol Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol Both hosts keep two windows (one for each direction). Window is the portion of buffer that can be transmitted without waiting for an ACK. Sender window size is controlled by the receiver. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Sender Buffer * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Receiver Window (RWND) N: Size of receiver buffer M: Number of occupied bytes N-M: Size of RWND * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Sender Buffer and Sender Window (SWND) Sizeof(SWND)  sizeof(RWND) * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Sliding the Sender Window * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Expanding the Sender Window Receiver tells sender to increase window size to 10. * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) Shrinking the Sender Window Receiver tells sender to decrease size to 6. * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Sliding Window Protocol (cont’d) The source does not have to send a full window’s worth of data. The size of the window can be increased or decreased by the destination. The destination can send an acknowledgment at any time. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Silly Window Syndrome Occurs when the sender and/or receiver creates/consumes data very slowly. The overhead due to header (TCP+IP=40 bytes) will be very high. Syndrome created by sender  Nagle’s algorithm Syndrome created by receiver  Clark’s solution or delayed acknowledgment Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Silly Window Syndrome (cont’d) Nagle’s Algorithm: Send the first piece of data, even if it is only 1 byte. After the first segment, accumulate data until either enough data is collected or receiving TCP sends ACK. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Silly Window Syndrome (cont’d) Clark’s Solution: Send ACK as soon as data arrives. Announce a window size of zero until: Available space in receiver buffer  maximum segment size, or Half of the receiver buffer is empty. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Silly Window Syndrome (cont’d) Delayed Acknowledgment: Received segment is not ACKed until there is decent amount of free space in receiver buffer. (ACK delayed typically for 200 ms.) Advantages: Avoids the syndrome Lower traffic volume (less ACKs) Disadvantage: The delay may cause retransmission. (Do not delay more than 500 ms.) Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Error Control: Corrupted Segment * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

Error Control: Lost Segment * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

Error Control: Lost ACK * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

ECE 4110 – Internetwork Programming TCP Timers Retransmission Timer: Waiting time for ACK. Used to control lost or discarded segments. Unique and dynamic for each connection. Retransmission time = 2 x RTT Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Timers Calculating RTT: Use timestamps, or Use the time between segment and ACK RTT= x previous RTT + (1- ) x current RTT If a packet is retransmitted and one ACK is received, does the ACK belong to the original segment or the retransmitted segment? Solution  Karn’s algorithm: Do not consider RTT for retransmitted segments. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Timers (cont’d) Persistence Timer: What if the ACK announcing a non-zero windows size (after a zero-window advertisement) is lost? Sending TCP starts persistence timer. If timer expires, a probe is sent to receiver TCP (repetitively). Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Timers (cont’d) Keepalive Timer: To prevent long idle connections due to crashes, etc. A probe is sent when timer expires. If multiple probes are not answered, connection is dropped. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming TCP Timers (cont’d) Time-waited Timer: To avoid multiple FIN segments. A closed connection is not immediately terminated. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Congestion Control TCP assumes that the cause of a lost segment is due to congestion in the network. If the cause of the lost segment is congestion, retransmission of the segment not only does not remove the cause, it aggravates it. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control (cont’d) Congestion can be realized by: Timeouts Duplicate ACKs In addition to the receiver, the network should also be able to determine the sender’s window size.  Congestion Window (CWND) SWND size = min (RWND size, CWND size) TCP uses two strategies against congestion: Slow Start and Additive Increase Multiplicative Decrease Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control: Slow Start and Additive Increase Initialize CWND size to Maximum Segment Size (MSS). For each segment ACKed, increase CWND size by MSS until CWND size reaches the Slow Start Threshold (SSTHRESH), half of allowable window size. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control: Slow Start and Additive Increase Slow Start (cont’d): Is this slow start? sizeof(CWND)=1  send 1 segment ACK received  sizeof(CWND)=2  send 2 segments 2 ACKs received  sizeof(CWND)=4  send 4 segments 4 ACKs received  sizeof(CWND)=8  send 8 segments This is not slow. This is exponential. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control: Slow Start and Additive Increase After reaching SSTHRESH, increase CWND size only by one MSS for each ACK, even if the ACK is for multiple segments. Continues until timeouts or CWND size reaches RWND size. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control: Multiplicative Decrease Activate congestion is detected. SSTHRESH = min (2xMSS, ½ x current window size) (CWND size or advertised window size) If congestion is detected by timeout CWND size = 1 x MSS SSTHRESH is reduced for each timeout (exponentially). Timeout causes going back to slow start. Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Control (cont’d) Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Congestion Avoidance (cont’d) Find the mistake in the figure * From TCP/IP Protocol Suite, B. A. Forouzan, Prentice Hall

ECE 4110 – Internetwork Programming TCP Header Format Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Control Field Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Options Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Connection Setup: Three-way Handshaking Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Connection Termination Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

State Transition Diagram

ECE 4110 – Internetwork Programming Client States Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

ECE 4110 – Internetwork Programming Server States Spring 2003 Tuna Tugcu ECE 4110 – Internetwork Programming

Connection Setup and Termination

Transfer 8192 bytes

Transfer 8192 bytes (alternative)

Sliding Window Example