Transmission Control Protocol (TCP)

Similar documents
Transmission Control Protocol (TCP)

32 bits. source port # dest port # sequence number acknowledgement number not used. checksum. Options (variable length)

TCP. 1 Administrivia. Tom Kelliher, CS 325. Apr. 2, Announcements. Assignment. Read From Last Time

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 9

Transport Layer: outline

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

10 minutes survey (anonymous)

Computer Networking Introduction

Chapter 3 Transport Layer

Lecture 08: The Transport Layer (Part 2) The Transport Layer Protocol (TCP) Dr. Anis Koubaa

COMP 431 Internet Services & Protocols. Transport Layer Protocols & Services Outline. The Transport Layer Reliable data delivery & flow control in TCP

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

Chapter 3 Transport Layer

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

CSCD 330 Network Programming

TCP : Fundamentals of Computer Networks Bill Nace

CS450 Introduc0on to Networking Lecture 14 TCP. Phu Phung Feb 13, 2015

RSC Part III: Transport Layer 3. TCP

CSC 401 Data and Computer Communications Networks

Chapter III: Transport Layer

Chapter 3 Transport Layer

User Datagram Protocol

Transport Layer: Outline

Suprakash Datta. Office: CSEB 3043 Phone: ext Course page:

Transport Layer. Application / Transport Interface. Transport Layer Services. Transport Layer Connections

CSE 4213: Computer Networks II

CSCE 463/612 Networks and Distributed Processing Spring 2017

Correcting mistakes. TCP: Overview RFCs: 793, 1122, 1323, 2018, TCP seq. # s and ACKs. GBN in action. TCP segment structure

Transport layer. UDP: User Datagram Protocol [RFC 768] Review principles: Instantiation in the Internet UDP TCP

Transport layer. Review principles: Instantiation in the Internet UDP TCP. Reliable data transfer Flow control Congestion control

TCP (Part 2) Session 10 INST 346 Technologies, Infrastructure and Architecture

Transport Protocols. Raj Jain. Washington University in St. Louis

Lecture 3: The Transport Layer: UDP and TCP

TCP. TCP: Overview. TCP Segment Structure. Maximum Segment Size (MSS) Computer Networks 10/19/2009. CSC 257/457 - Fall

05 Transmission Control Protocol (TCP)

Transport Layer Marcos Vieira

TCP and Congestion Control (Day 1) Yoshifumi Nishida Sony Computer Science Labs, Inc. Today's Lecture

CSC 4900 Computer Networks: TCP

Fall 2012: FCM 708 Bridge Foundation I

CS Lecture 1 Review of Basic Protocols

CS118 Discussion 1A, Week 4. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

Networking Technologies and Applications

TCP/IP Protocol Suite 1

The Transport Layer: TCP & Reliable Data Transfer

Chapter 3- parte B outline

Sequence Number. Acknowledgment Number. Data

ITS323: Introduction to Data Communications

TCP Service Model. Today s Lecture. TCP Support for Reliable Delivery. EE 122:TCP, Connection Setup, Reliability

Congestion / Flow Control in TCP

Chapter 3 Transport Layer

ECE 650 Systems Programming & Engineering. Spring 2018

TCP = Transmission Control Protocol Connection-oriented protocol Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.

TSIN02 - Internetworking

Lecture 8. TCP/IP Transport Layer (2)

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2. Goals for Todayʼs Lecture. Role of Transport Layer

Outline. TCP: Overview RFCs: 793, 1122, 1323, 2018, steam: r Development of reliable protocol r Sliding window protocols

ICS 451: Today's plan. Sliding Window Reliable Transmission Acknowledgements Windows and Bandwidth-Delay Product Retransmission Timers Connections

Transport Protocols & TCP TCP

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

Introduction to Networks and the Internet

TSIN02 - Internetworking

TSIN02 - Internetworking

Chapter 3 outline. 3.5 Connection-oriented transport: TCP. 3.6 Principles of congestion control 3.7 TCP congestion control

Connection-oriented (virtual circuit) Reliable Transfer Buffered Transfer Unstructured Stream Full Duplex Point-to-point Connection End-to-end service

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

7. TCP 최양희서울대학교컴퓨터공학부

Chapter 3 Transport Layer

TSIN02 - Internetworking

CS457 Transport Protocols. CS 457 Fall 2014

Introduction to TCP/IP networking

Mobile Transport Layer Lesson 10 Timeout Freezing, Selective Retransmission, Transaction Oriented TCP and Explicit Notification Methods

User Datagram Protocol (UDP):

Computer Communication Networks Midterm Review

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

Outline. TCP: Overview RFCs: 793, 1122, 1323, 2018, Development of reliable protocol Sliding window protocols

IS370 Data Communications and Computer Networks. Chapter 5 : Transport Layer

Kent State University

Multiple unconnected networks

Internet and Intranet Protocols and Applications

6.1 Internet Transport Layer Architecture 6.2 UDP (User Datagram Protocol) 6.3 TCP (Transmission Control Protocol) 6. Transport Layer 6-1

CS 716: Introduction to communication networks th class; 7 th Oct Instructor: Sridhar Iyer IIT Bombay

I TCP 1/2. Internet TA: Connection-oriented (virtual circuit) Connectionless (datagram) (flow control) (congestion control) TCP Connection-oriented

Transport Protocols and TCP

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Chapter 3 outline. TDTS06 Computer networks. Principles of Reliable data transfer. Reliable data transfer: getting started

Transport Layer TCP / UDP

CS321: Computer Networks Error and Flow Control in TCP

Lecture 5. Transport Layer. Transport Layer 1-1

Transport Protocols and TCP: Review

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4021: Networks Discussion. Chapter 5 - Part 2

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 25, 2018

Mobile Transport Layer Lesson 02 TCP Data Stream and Data Delivery

Information Network 1 TCP 1/2

CS 43: Computer Networks. 18: Transmission Control Protocol October 12-29, 2018

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

Computer Networks. Wenzhong Li. Nanjing University

Network Technology 1 5th - Transport Protocol. Mario Lombardo -

23-3 TCP. Topics discussed in this section: TCP Services TCP Features Segment A TCP Connection Flow Control Error Control 23.22

Transcription:

Transmission Control Protocol (TCP) Antonio Carzaniga Faculty of Informatics University of Lugano May 3, 2005

Outline Intro to TCP Sequence numbers and acknowledgment numbers Timeouts and RTT estimation Reliable data transfer in TCP Connection management

Transmission Control Protocol The Internet s primary transport protocol defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and RFC 2581

Transmission Control Protocol The Internet s primary transport protocol defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and RFC 2581 Connection-oriented service endpoints must handshake to establish a connection

Transmission Control Protocol The Internet s primary transport protocol defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and RFC 2581 Connection-oriented service endpoints must handshake to establish a connection Full-duplex service both endpoints can both send and receiver, at the same time

Preliminary Definitions

Preliminary Definitions TCP segment: envelope for TCP data all TCP data is sent within TCP segments a TCP segment is then sent within an IP packet

Preliminary Definitions TCP segment: envelope for TCP data all TCP data is sent within TCP segments a TCP segment is then sent within an IP packet Maximum segment size (MSS): maximum amount of application data transmitted in a single segment typically related to the MTU of the connection, to avoid network-level fragmentation (we ll talk about all of this later)

Preliminary Definitions TCP segment: envelope for TCP data all TCP data is sent within TCP segments a TCP segment is then sent within an IP packet Maximum segment size (MSS): maximum amount of application data transmitted in a single segment typically related to the MTU of the connection, to avoid network-level fragmentation (we ll talk about all of this later) Maximum transmission unit (MTU): largest link-layer frame available to the sender host path MTU: largest link-layer frame that can be sent on all links from the sender host to the receiver host

TCP Segment Format 0 31 source port destination port sequence number acknowledgment number hdrlen unused U A P R S F receive window Internet checksum urgent data pointer options field data

TCP Header Fields

TCP Header Fields Source and destination ports: (16-bit each) application identifiers

TCP Header Fields Source and destination ports: (16-bit each) application identifiers Sequence number: (32-bit) used to implement reliable data transfer Acknowledgment number: (32-bit) used to implement reliable data transfer

TCP Header Fields Source and destination ports: (16-bit each) application identifiers Sequence number: (32-bit) used to implement reliable data transfer Acknowledgment number: (32-bit) used to implement reliable data transfer Receive window: (16-bit) size of the window on the receiver end

TCP Header Fields Source and destination ports: (16-bit each) application identifiers Sequence number: (32-bit) used to implement reliable data transfer Acknowledgment number: (32-bit) used to implement reliable data transfer Receive window: (16-bit) size of the window on the receiver end Header length: (4-bit) size of the TCP header in 32-bit words

TCP Header Fields Source and destination ports: (16-bit each) application identifiers Sequence number: (32-bit) used to implement reliable data transfer Acknowledgment number: (32-bit) used to implement reliable data transfer Receive window: (16-bit) size of the window on the receiver end Header length: (4-bit) size of the TCP header in 32-bit words Optional and variable-length options field: may be used to negotiate protocol parameters

TCP Header Fields

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown RST flag: (1-bit) used during connection setup and shutdown

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown RST flag: (1-bit) used during connection setup and shutdown FIN flag: (1-bit) used during connection shutdown

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown RST flag: (1-bit) used during connection setup and shutdown FIN flag: (1-bit) used during connection shutdown PSH flag: (1-bit) push flag, used to solicit the receiver to pass the data to the application immediately

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown RST flag: (1-bit) used during connection setup and shutdown FIN flag: (1-bit) used during connection shutdown PSH flag: (1-bit) push flag, used to solicit the receiver to pass the data to the application immediately URG flag: (1-bit) urgent flag, used to inform the receiver that the sender has marked some data as urgent. The location of this urgent data is marked by the urgent data pointer field

TCP Header Fields ACK flag: (1-bit) signals that the value contained in the acknowledgment number represents a valid acknowledgment SYN flag: (1-bit) used during connection setup and shutdown RST flag: (1-bit) used during connection setup and shutdown FIN flag: (1-bit) used during connection shutdown PSH flag: (1-bit) push flag, used to solicit the receiver to pass the data to the application immediately URG flag: (1-bit) urgent flag, used to inform the receiver that the sender has marked some data as urgent. The location of this urgent data is marked by the urgent data pointer field Checksum: (16-bit) used to detect transmission errors

Sequence Numbers

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g.,

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb MSS=1024b

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb MSS=1024b

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb MSS=1024b 1...... 1024 1025... 2048 2049... 3072 3073... 4096

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb MSS=1024b 1...... 1024 1025... 2048 2049... 3072 3073... 4096 a TCP segment

Sequence Numbers Sequence numbers are associated with bytes in the data stream not with segments, as we have used them before A sequence number in a TCP segment indicates the sequence number of the first byte carried by that segment. E.g., application data stream 4Kb MSS=1024b 1...... 1024 1025... 2048 2049... 3072 3073... 4096 a TCP segment 2049

Acknowledgment Numbers

Acknowledgment Numbers An acknowledgment numbers represents to the first sequence number not yet seen by the receiver TCP acknowledgments are cumulative

Acknowledgment Numbers An acknowledgment numbers represents to the first sequence number not yet seen by the receiver TCP acknowledgments are cumulative A B

Acknowledgment Numbers An acknowledgment numbers represents to the first sequence number not yet seen by the receiver TCP acknowledgments are cumulative A B [Seq# = 1200,...], size(data) = 1000

Acknowledgment Numbers An acknowledgment numbers represents to the first sequence number not yet seen by the receiver TCP acknowledgments are cumulative A B [Seq# = 1200,...], size(data) = 1000 [Seq# = 2200,...], size(data) = 500

Acknowledgment Numbers An acknowledgment numbers represents to the first sequence number not yet seen by the receiver TCP acknowledgments are cumulative A B [Seq# = 1200,...], size(data) = 1000 [Seq# = 2200,...], size(data) = 500 [Seq# =..., Ack# = 2700]

Sequence Numbers and ACK Numbers

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application:

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B [Seq# = 100, Data = C ]

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B [Seq# = 100, Data = C ] [Ack# = 101, Seq# = 200, Data = C ]

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B [Seq# = 100, Data = C ] [Ack# = 101, Seq# = 200, Data = C ] [Seq# = 101, Ack# = 201, Data = i ]

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B [Seq# = 100, Data = C ] [Ack# = 101, Seq# = 200, Data = C ] [Seq# = 101, Ack# = 201, Data = i ] [Seq# = 201, Ack# = 102, Data = i ]

Sequence Numbers and ACK Numbers Notice that a TCP connection consists of is a full-duplex link. Therefore, there are two streams two different sequence numbers E.g., consider a simple Echo application: A B [Seq# = 100, Data = C ] [Ack# = 101, Seq# = 200, Data = C ] [Seq# = 101, Ack# = 201, Data = i ] [Seq# = 201, Ack# = 102, Data = i ] Acknowledgments are piggybacked on data segments

Round-Trip Time Estimation TCP provides reliable data transfer using a timer to detect lost segments One implementation issue is how long to wait for acknowledgments

Round-Trip Time Estimation TCP provides reliable data transfer using a timer to detect lost segments One implementation issue is how long to wait for acknowledgments Retransmission timeouts should be as close as possible to the round-trip time RTT = 2L

Round-Trip Time Estimation TCP provides reliable data transfer using a timer to detect lost segments One implementation issue is how long to wait for acknowledgments Retransmission timeouts should be as close as possible to the round-trip time RTT = 2L So, TCP controls its timeout by continuously estimating the current RTT

RTT Estimation

RTT Estimation RTT is measured using ACKs Only for packets transmitted once A single sample S at any given time Exponential weighted moving average (EWMA) RTT = (1 α)rtt + αs

RTT Estimation RTT is measured using ACKs Only for packets transmitted once A single sample S at any given time Exponential weighted moving average (EWMA) RTT = (1 α)rtt + αs TCP also measures the variability of RTT DevRTT = (1 β)devrtt + β RTT S

Timeout Value

Timeout Value The timeout interval T must be larger than the RTT so as to avoid unnecessary retransmission However, T should not be too far from RTT so as to detect (and retransmit) lost segments as quickly as possible

Timeout Value The timeout interval T must be larger than the RTT so as to avoid unnecessary retransmission However, T should not be too far from RTT so as to detect (and retransmit) lost segments as quickly as possible TCP sets its timeouts using the estimated RTT (RTT ) and the variability estimate DevRTT: T = RTT + 4DevRTT

Reliable Data Transfer in TCP A simplified TCP sender r send(data) if (timer not running) start timer() u send([data,next seq num]) next seq num next seq num + length(data)

Reliable Data Transfer in TCP A simplified TCP sender r send(data) if (timer not running) start timer() u send([data,next seq num]) next seq num next seq num + length(data) timeout u send(pending segment with smallest sequence number) start timer()

Reliable Data Transfer in TCP A simplified TCP sender r send(data) if (timer not running) start timer() u send([data,next seq num]) next seq num next seq num + length(data) timeout u send(pending segment with smallest sequence number) start timer() u recv([ack,y]) if (y > base) base y if ( pending segments) start timer()

Acknowledgment Generation

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above)

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above) Cumulative ACK: immediately send cumulative ACK (for both segments)

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above) Cumulative ACK: immediately send cumulative ACK (for both segments) Arrival of out of order segment with higher-than-expected sequence number (gap detected)

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above) Cumulative ACK: immediately send cumulative ACK (for both segments) Arrival of out of order segment with higher-than-expected sequence number (gap detected) Duplicate ACK: immediately send duplicate ACK

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above) Cumulative ACK: immediately send cumulative ACK (for both segments) Arrival of out of order segment with higher-than-expected sequence number (gap detected) Duplicate ACK: immediately send duplicate ACK Arrival of segment that (partially or completely) fills a gap in the received data

Acknowledgment Generation Arrival of in-order segment with expected sequence number; all data up to expected sequence number already acknowledged Delayed ACK: wait 500ms for another in-order segment. If that doesn t happen, send ACK Arrival of in-order segment with expected sequence number. One other in-order segment waiting for ACK (see above) Cumulative ACK: immediately send cumulative ACK (for both segments) Arrival of out of order segment with higher-than-expected sequence number (gap detected) Duplicate ACK: immediately send duplicate ACK Arrival of segment that (partially or completely) fills a gap in the received data Immediate ACK: immediately send ACK if the packet start at the lower end of the gap

Connection Setup

Connection Setup Three-way handshake

Connection Setup Three-way handshake client server

Connection Setup Three-way handshake client server [SYN, Seq# = cli init seq]

Connection Setup Three-way handshake client server [SYN, Seq# = cli init seq] [SYN, ACK, Ack# = cli init seq + 1, Seq# = srv init seq]

Connection Setup Three-way handshake client server [SYN, Seq# = cli init seq] [SYN, ACK, Ack# = cli init seq + 1, Seq# = srv init seq] [ACK, Seq# = cli init seq + 1, Ack# = srv init seq + 1]

Connection Shutdown This is it. Okay, Bye now. Bye.

Connection Shutdown This is it. Okay, Bye now. Bye. client server

Connection Shutdown This is it. Okay, Bye now. Bye. client server [FIN]

Connection Shutdown This is it. Okay, Bye now. Bye. client server [FIN] [ACK ]

Connection Shutdown This is it. Okay, Bye now. Bye. client server [FIN] [ACK ] [FIN]

Connection Shutdown This is it. Okay, Bye now. Bye. client server [FIN] [ACK ] [FIN] [ACK ]