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

Similar documents
CS 356: Computer Network Architectures. Lecture 17: End-to-end Protocols and Lab 3 Chapter 5.1, 5.2. Xiaowei Yang

Networking Technologies and Applications

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

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

User Datagram Protocol

TSIN02 - Internetworking

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

TCP: Transmission Control Protocol RFC 793,1122,1223. Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC

TCP : Fundamentals of Computer Networks Bill Nace

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

TSIN02 - Internetworking

CSCD 330 Network Programming

TSIN02 - Internetworking

TSIN02 - Internetworking

05 Transmission Control Protocol (TCP)

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

Transmission Control Protocol (TCP)

Information Network 1 TCP 1/2

EEC-484/584 Computer Networks. Lecture 16. Wenbing Zhao

Fall 2012: FCM 708 Bridge Foundation I

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

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

EEC-682/782 Computer Networks I

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

User Datagram Protocol (UDP):

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

OSI Transport Layer. objectives

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

Introduction to TCP/IP networking

Simulation of TCP Layer

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

ITS323: Introduction to Data Communications

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

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

TCP/IP Protocol Suite 1

Transport Layer: outline

Sequence Number. Acknowledgment Number. Data

Transport Layer Marcos Vieira

QUIZ: Longest Matching Prefix

Linux Networking: tcp. TCP context and interfaces

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

TCP /IP Fundamentals Mr. Cantu

CS 356: Introduction to Computer Networks. Lecture 16: Transmission Control Protocol (TCP) Chap. 5.2, 6.3. Xiaowei Yang

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

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

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

Computer Networks. Transmission Control Protocol. Jianping Pan Spring /3/17 CSC361 1

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

Unit 2.

CS419: Computer Networks. Lecture 10, Part 2: Apr 11, 2005 Transport: TCP mechanics (RFCs: 793, 1122, 1323, 2018, 2581)

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

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

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

The Transport Layer: TCP & Reliable Data Transfer

Introduction to Networking. Operating Systems In Depth XXVII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CSCE 463/612 Networks and Distributed Processing Spring 2017

Transport Layer: Outline

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

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

Introduction to Networks and the Internet

ECE 650 Systems Programming & Engineering. Spring 2018

CSCI-GA Operating Systems. Networking. Hubertus Franke

Transport Protocols. ISO Defined Types of Network Service: rate and acceptable rate of signaled failures.

CCNA R&S: Introduction to Networks. Chapter 7: The Transport Layer

Chapter 24. Transport-Layer Protocols

ECE 435 Network Engineering Lecture 9

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

Transport Layer. -UDP (User Datagram Protocol) -TCP (Transport Control Protocol)

Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1

Stream Control Transmission Protocol

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

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

Congestion / Flow Control in TCP

Lecture 3: The Transport Layer: UDP and TCP

What is TCP? Transport Layer Protocol

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

6. The Transport Layer and protocols

Chapter 5 End-to-End Protocols

ECE4110 Internetwork Programming. Introduction and Overview

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

The Transport Layer. Part 1

Topics. TCP sliding window protocol TCP PUSH flag TCP slow start Bulk data throughput

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

ECE 435 Network Engineering Lecture 15

Transport Protocols & TCP TCP

UNIT V. Computer Networks [10MCA32] 1

Programming Assignment 3: Transmission Control Protocol

Chapter 7. The Transport Layer

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

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

ECE 435 Network Engineering Lecture 9

Transport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol

UNIT IV -- TRANSPORT LAYER

TCP TCP/IP: TCP. TCP segment. TCP segment. TCP encapsulation. TCP encapsulation 1/25/2012. Network Security Lecture 6

Module : ServerIron ADX Packet Capture

Internet Transport Protocols UDP and TCP

Guide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16

NWEN 243. Networked Applications. Layer 4 TCP and UDP

RSC Part III: Transport Layer 3. TCP

Two approaches to Flow Control. Cranking up to speed. Sliding windows in action

Transcription:

Overview Formats, Data Transfer, etc. Connection Management (modified by Malathi Veeraraghavan) 1 Overview TCP = Transmission Control Protocol Connection-oriented protocol Provides a reliable unicast end-to-end byte stream over an unreliable internetwork. Byte Stream Byte Stream TCP TCP IP Internetwork (modified by Malathi Veeraraghavan) 2 1

Connection-Oriented Before any data transfer, TCP establishes a connection: One TCP entity is waiting for a connection ( server ) The other TCP entity ( client ) contacts the server The actual procedure for setting up connections is more complex. Each connection is full duplex CLIENT Request a connection Accept a connection SERVER waiting for connection request Data Transer Disconnect (modified by Malathi Veeraraghavan) 3 Reliable Byte stream is broken up into chunks which are called segments Receiver sends acknowledgements (ACKs) for segments TCP maintains a timer. If an ACK is not received in time, the segment is retransmitted Detecting errors: TCP has checksums for header and data. Segments with invalid checksums are discarded Each segment that is transmitted has a sequence number (modified by Malathi Veeraraghavan) 4 2

Byte Stream Service To the lower layers, TCP handles data in blocks, the segments. To the higher layers TCP handles data as a sequence of bytes and does not identify boundaries between bytes So: Higher layers do not know about the beginning and end of segments! Application 1. write 100 bytes 2. write 20 bytes Application 1. read 40 bytes 2. read 40 bytes 3. read 40 bytes TCP queue of bytes to be transmitted Segments TCP queue of bytes that have been received (modified by Malathi Veeraraghavan) 5 TCP Format TCP segments have a 20 byte header with >= 0 bytes of data. IP header TCP header TCP data 20 bytes 20 bytes 0 15 16 31 Source Port Number Destination Port Number 4 bits 6 bits reserved header length Sequence number (32 bits) Acknowledgement number (32 bits) 0 Flags TCP checksum Options (if any) DATA (optional) window size urgent pointer 20 bytes (modified by Malathi Veeraraghavan) 6 3

TCP header fields - Port Numbers Port Number: A port number identifies the endpoint of a connection. A pair <IP address, port number> identifies one endpoint of a connection. Two pairs <client IP address, client port number> and <server IP address, server port number> identify a TCP connection. Applications Applications Ports: 23 80 104 TCP 7 80 16 Ports: TCP IP IP (modified by Malathi Veeraraghavan) 7 TCP header fields - Sequence Number Sequence Number (SeqNo): Sequence number is 32 bits long. So the range of SeqNo is 0 <= SeqNo <= 2 32-1? 4.3 Gbyte Each sequence number identifies the byte in the stream of data from the sending TCP to the receiving TCP that the first byte of data in this segment represents. Initial Sequence Number (ISN) of a connection is set during connection establishment 1 500 501 1000 1001 1500 Segment 1 (Seq. No. 1) Segment 2 (Seq. No. 501) Segment 3 (Seq. No. 1001) (modified by Malathi Veeraraghavan) 8 4

TCP header fields - Ack. No. Acknowledgement Number (AckNo): Acknowledgements are piggybacked, I.e a segment from A -> B can contain an acknowledgement for a data sent in the B -> A direction Q: Why is piggybacking good? The AckNo contains the next SeqNo that a host wants to receive Example: The acknowledgement for a 1500-byte segment with the sequence number 0 is AckNo=1500 A host uses the AckNo field to send acknowledgements. (If a host sends an AckNo in a segment it sets the ACK flag ) (modified by Malathi Veeraraghavan) 9 TCP header fields - Ack. No. Contd. Acknowledge Number (cont d) TCP uses the sliding window flow protocol (see EL536) to regulate the flow of traffic from sender to receiver TCP uses the following variation of sliding window: Example: no NACKs (Negative ACKnowledgement) only cumulative ACKs Assume: Sender sends two segments with 1..1500 and 1501..3000, but receiver only gets the second segment. In this case, the receiver cannot acknowledge the second packet. It can only send AckNo=1 (modified by Malathi Veeraraghavan) 10 5

TCP header fields - Header Length Header Length ( 4bits): Length of header in 32-bit words Note that TCP header has variable length (with minimum 20 bytes) (modified by Malathi Veeraraghavan) 11 TCP header fields - Flags Flag bits: URG: Urgent pointer is valid If the bit is set, the following bytes contain an urgent message in the range: SeqNo <= urgent message <= SeqNo+urgent pointer ACK: Acknowledgement Number is valid PSH: PUSH Flag Notification from sender to the receiver that the receiver should pass all data that it has to the application as soon as possible. Normally set by sender when the sender s buffer is empty (so TCP does not wait expecting more data) (modified by Malathi Veeraraghavan) 12 6

TCP header fields - Flags Contd. Flag bits: RST: Reset the connection The flag causes the receiver to reset the connection Receiver of a RST terminates the connection and indicates higher layer application about the reset SYN: Synchronize sequence numbers Sent in the first packet when initiating a connection FIN: Sender is finished with sending Used for closing a connection Both sides of a connection must send a FIN (modified by Malathi Veeraraghavan) 13 TCP header fields Window Size: Each side of the connection advertises the window size Window size is the maximum number of bytes that a receiver can accept. Maximum window size is 2 16-1= 65535 bytes TCP Checksum: TCP checksum covers both TCP header and TCP data Urgent Pointer: Only valid if URG flag is set (modified by Malathi Veeraraghavan) 14 7

TCP header fields - Options Options: End of Options kind=0 NOP (no operation) kind=1 Maximum Segment Size kind=2 len=4 maximum segment size 2 bytes Window Scale Factor kind=3 len=3 shift count Timestamp kind=8 len=10 timestamp value timestamp echo reply 4 bytes 4 bytes (modified by Malathi Veeraraghavan) 15 TCP header fields Options: NOP is used to pad TCP header to multiples of 4 bytes Maximum Segment Size Window Scale Options» Increases the TCP window size» 1-byte shift count (R) is between 0 and 14» The 16-bit advertised window is left-shifted R bits» Maximum window size = 65535 2 14 bytes» This option can only be used in the SYN segment (first segment) during connection establishment time Timestamp Option» Can be used for roundtrip measurements (modified by Malathi Veeraraghavan) 16 8

Connection Management in TCP Opening a TCP Connection Closing a TCP Connection Special Scenarios State Diagram (modified by Malathi Veeraraghavan) 17 TCP Connection Establishment TCP uses a three-way handshake to open a connection: (1) ACTIVE OPEN: Client sends a segment with SYN bit set port number of client, port number of server initial sequence number (ISN) of client (2) PASSIVE OPEN: Server responds with a segment with SYN bit set initial sequence number of server ACK for ISN of client (3) Client acknowledges by sending a segment with: ACK ISN of server (modified by Malathi Veeraraghavan) 18 9

Three-Way Handshake aida.poly.edu mng.poly.edu SYN (SeqNo = x) SYN (SeqNo = y, AckNo = x + 1 ) ack (y + 1 ) (modified by Malathi Veeraraghavan) 19 A Closer Look with tcpdump aida issues a "telnet mng" aida.poly.edu mng.poly.edu 1 aida.poly.edu.1121 > mng.poly.edu.telnet: S 1031880193:1031880193(0) win 16384 <mss 1460,nop,wscale 0,nop,nop,timestamp> 2 mng.poly.edu.telnet > aida.poly.edu.1121: S 172488586:172488586(0) ack 1031880194 win 8760 <mss 1460> 3 aida.poly.edu.1121 > mng.poly.edu.telnet:. ack 172488587 win 17520 4 aida.poly.edu.1121 > mng.poly.edu.telnet: P 1031880194:1031880218(24) ack 172488587 win 17520 5 mng.poly.edu.telnet > aida.poly.edu.1121: P 172488587:172488590(3) ack 1031880218 win 8736 6 aida.poly.edu.1121 > mng.poly.edu.telnet: P 1031880218:1031880221(3) ack 172488590 win 17520 (modified by Malathi Veeraraghavan) 20 10

Three-Way Handshake aida.poly.edu mng.poly.edu S 1031880193:1031880193(0) win 16384 <mss 1460,...> S 172488586:172488586(0) ack 1031880194 win 8760 <mss 1460> ack 172488587 win 17520 (modified by Malathi Veeraraghavan) 21 SYN sequence number Note that the data segment following the three-way handshake will start with the sequence number following that of the SYN segment (modified by Malathi Veeraraghavan) 22 11

TCP Connection Termination Each end of the data flow must be shut down independently ( half-close ) If one end is done it sends a FIN segment. This means that no more data will be sent Four steps involved: (1) X sends a FIN to Y (active close) (2) Y ACKs the FIN, (at this time: Y can still send data to X) (3) and Y sends a FIN to X (passive close) (4) X ACKs the FIN. (modified by Malathi Veeraraghavan) 23 Connection termination with tcpdump aida.poly.edu mng.poly.edu 1 mng.poly.edu.telnet > aida.poly.edu.1121: F 172488734:172488734(0) ack 1031880221 win 8733 2 aida.poly.edu.1121 > mng.poly.edu.telnet:. ack 172488735 win 17484 3 aida.poly.edu.1121 > mng.poly.edu.telnet: F 1031880221:1031880221(0) ack 172488735 win 17520 4 mng.poly.edu.telnet > aida.poly.edu.1121:. ack 1031880222 win 8733 (modified by Malathi Veeraraghavan) 24 12

. ack 172488735 win 17484 TCP Connection Termination aida.poly.edu F 172488734:172488734(0) ack 1031880221 win 8733 mng.poly.edu F 1031880221:1031880221(0) ack 172488735 win 17520. ack 1031880222 win 8733 (modified by Malathi Veeraraghavan) 25 13