CSCE 515: Computer Network Programming ------ TCP Details Wenyuan Xu Department of Computer Science and Engineering.

Slides:



Advertisements
Similar presentations
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Advertisements

Transmission Control Protocol (TCP)
Intermediate TCP/IP TCP Operation.
Fundamentals of Computer Networks ECE 478/578 Lecture #20: Transmission Control Protocol Instructor: Loukas Lazos Dept of Electrical and Computer Engineering.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
CS 471/571 Transport Layer 5 Slides from Kurose and Ross.
TCP & UDP - Protocol Details Yen-Cheng Chen
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.
5/6/2015© 2010 Raymond P. Jefferis IIILect Transport Layer.
TCP Tutorial Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
Chapter 7 – Transport Layer Protocols
Computer Networks 2 Lecture 2 TCP – I - Transport Protocols: TCP Segments, Flow control and Connection Setup.
Netprog: TCP Details1 TCP Details. Netprog: TCP Details2 TCP Lingo When a client requests a connection, it sends a “SYN” segment (a special TCP segment)
CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering.
Netprog: TCP Details1 TCP Details Introduction to Networking Yan Gao TA Jan 27, 2005 Recital 3.
Lecture 3 TCP/IP model CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
EEC-484/584 Computer Networks Lecture 15 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Netprog: TCP Details1 TCP Details Introduction to Networking John Otto TA Jan 31, 2007 Recital 4.
Netprog: TCP Details1 TCP Details Introduction to Networking.
CSE 461: Transport Layer Connections. Naming Processes/Services  Process here is an abstract term for your Web browser (HTTP), servers (SMTP),
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
Lecture 23: Network Primer 7/15/2003 CSCE 590 Summer 2003.
EEC-484/584 Computer Networks Lecture 13 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
1 ELEN 602 Lecture 15 More on IP TCP. 2 byte stream Send buffer segments Receive buffer byte stream Application ACKs Transmitter Receiver TCP Streams.
Transport Layer TCP and UDP IS250 Spring 2010
Gursharan Singh Tatla Transport Layer 16-May
Module A Panko and Panko Business Data Networks and Security, 9 th Edition © 2013 Pearson.
What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best.
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
6.1. Transport Control Protocol (TCP) It is the most widely used transport protocol in the world. Provides reliable end to end connection between two hosts.
1 Netprog 2002 TCP/IP TCP/IP Transmission Control Protocol / Internet Protocol Based on Notes by D. Hollinger.
Lecture 6 Overview. TCP: Transmission Control Protocol TCP is an alternative transport layer protocol supported by TCP/IP. TCP provides: – Connection-oriented.
TCP Transport Control Protocol Information management 2 Groep T Leuven – Information department 2/35 Introduction UDP provides the connection.
TCP : Transmission Control Protocol Computer Network System Sirak Kaewjamnong.
CS332, Ch. 26: TCP Victor Norman Calvin College 1.
David Wetherall Professor of Computer Science & Engineering Introduction to Computer Networks Transport Layer Overview (§ )
TCP1 Transmission Control Protocol (TCP). TCP2 Outline Transmission Control Protocol.
More on TCP Acknowledgements Sequence Number Field Initial Sequence Number Acknowledgement Number Field.
Networking Basics CCNA 1 Chapter 11.
Chapter 24 Transport Control Protocol (TCP) Layer 4 protocol Responsible for reliable end-to-end transmission Provides illusion of reliable network to.
EECS340 Recitation 2: Very helpful to your project Hongyu Gao 1.
© Jörg Liebeherr (modified by Malathi Veeraraghavan) 1 Overview Formats, Data Transfer, etc. Connection Management.
Hour 6 The Transport Layer 1. What You'll Learn in This Hour Connections oriented and connectionless protocols Ports and sockets TCP UDP 2.
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)
Two Transport Protocols Available Transmission Control Protocol (TCP) User Datagram Protocol (UDP) Provides unreliable transfer Requires minimal – Overhead.
3. END-TO-END PROTOCOLS (PART 1) Rocky K. C. Chang Department of Computing The Hong Kong Polytechnic University 22 March
Advanced Computer Networks
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.
Introduction to Networking Recital 4
5. End-to-end protocols (part 1)
Chapter 17 and 18: TCP is connection oriented
Process-to-Process Delivery, TCP and UDP protocols
Process-to-Process Delivery
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.
Chapter 2 Transport Layer Protocols TCP UDP SCTP
TCP Details.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Protocols: TCP Segments, Flow control and Connection Setup
Transport Layer 9/22/2019.
Presentation transcript:

CSCE 515: Computer Network Programming TCP Details Wenyuan Xu Department of Computer Science and Engineering University of South Carolina

CSCE515 – Computer Network Programming 2007 TCP TCP provides the end-to-end reliable connection that IP alone cannot support The TCP protocol  Frame format  Connection Creation  Flow control  Congestion control  Connection termination

CSCE515 – Computer Network Programming 2007 TCP Segment Format bytes destination port number urgent pointerTCP checksum option (if any) source port number window size sequence number acknowledgment number header length reserved URGURG ACKACK PSHPSH RSTRST SYNSYN FINFIN data (if any)

CSCE515 – Computer Network Programming 2007 More... Every TCP segment includes a Sequence Number that refers to the first byte of data included in the segment. Every TCP segment includes a Request Number (Acknowledgement Number) that indicates the byte number of the next data that is expected to be received.  All bytes up through this number have already been received.

CSCE515 – Computer Network Programming 2007 And more... MSS: Maximum segment size (A TCP option) Window: Every ACK includes a Window field that tells the sender how many bytes it can send before the receiver will have to toss it away (due to fixed buffer size).

CSCE515 – Computer Network Programming 2007 And more… There are a bunch of control flags: URG: urgent data included. ACK: this segment is (among other things) an acknowledgement. RST: error - abort the session. SYN: Used to establish connection; synchronize Sequence Numbers (setup) FIN: polite connection termination.

CSCE515 – Computer Network Programming 2007 TCP Lingo When a client requests a connection, it sends a “SYN” segment (a special TCP segment) to the server port. SYN stands for synchronize. The SYN message includes the client’s ISN. ISN is Initial Sequence Number.

CSCE515 – Computer Network Programming 2007 ClientServer SYN ISN=X SYN ISN=X 1 SYN ISN=Y ACK=X+1 SYN ISN=Y ACK=X+1 2 ACK=Y+1 3 time TCP Connection Establishment – Three-way handshake “I want to talk, and I’m starting with byte number X+1”. “OK, I’m here and I’ll talk. My first byte will be called number Y+1, and I know your first byte will be number X+1” “Got it - you start at byte number Y+1”.

CSCE515 – Computer Network Programming 2007 TCP Connection Creation A server accepts a connection.  Must be looking for new connections! A client requests a connection.  Must know where the server is!

CSCE515 – Computer Network Programming 2007 Client Starts A client starts by sending a SYN segment with the following information:  Client’s ISN (generated pseudo-randomly)  Maximum Receive Window for client.  Optionally (but usually) MSS (largest datagram accepted).  No payload! (Only TCP headers)

CSCE515 – Computer Network Programming 2007 Sever Response When a waiting server sees a new connection request, the server sends back a SYN segment with:  Server’s ISN (generated pseudo-randomly)  Request Number is Client ISN+1  Maximum Receive Window for server.  Optionally (but usually) MSS  No payload! (Only TCP headers)

CSCE515 – Computer Network Programming 2007 Finally When the Server’s SYN is received, the client sends back an ACK with:  Request Number is Server’s ISN+1

CSCE515 – Computer Network Programming 2007 Why 3-Way? Why is the third message necessary? HINTS:  TCP is a reliable service.  IP delivers each TCP segment.  IP is not reliable.

CSCE515 – Computer Network Programming 2007 TCP Data and ACK Once the connection is established, data can be sent. Each data segment includes a sequence number identifying the first byte in the segment. Each ACK segment includes a request number indicating what data has been received. (bytes instead of packets)

CSCE515 – Computer Network Programming 2007 Important Information in TCP/IP packet headers Send NSEQ Recv ACKWIN Number of bytes in packet (N) ACK bit set Sequence number of next expected byte (ACK) Sequence number of first data byte in packet (SEQ) Window size at the receiver (WIN) Contained in IP headerContained in TCP header

CSCE515 – Computer Network Programming 2007 Buffering The TCP layer doesn’t know when the application will ask for any received data. Both the client and server allocate buffers to hold incoming and outgoing data (TCP does this)  incoming data -> it’s ready when application asks for it.  outgoing data-> it can be retransmitted should error occurs Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment).

CSCE515 – Computer Network Programming 2007 Send Buffers The application gives the TCP layer some data to send. The data is put in a send buffer, where it stays until the data is ACK’d.  it has to stay, as it might need to be sent again! The TCP layer won’t accept data from the application unless (or until) there is buffer space.

CSCE515 – Computer Network Programming 2007 Recv Buffers The received data is put in the recv buffer, where it stays until the application reads data The Recv Buffer won’t accept data from network unless (or until) there is buffer space, and the sequence number is within its sliding windows. The recv buffer can store out of order data as long as there is buffer space and the sequence number is within its sliding windows

CSCE515 – Computer Network Programming 2007 ACKs A receiver doesn’t have to ACK every segment (it can ACK many segments with a single ACK segment). Each ACK can also contain outgoing data (piggybacking). If a sender doesn’t get an ACK after some time limit (MSL) it resends the data.

CSCE515 – Computer Network Programming 2007 TCP Flow Control Sender Application does a 2K write Application reads 2k Sender is blocked 2K SEQ=0 empty receiver 0 4K recv’s buffer 2K ACK = 2048 WIN = 2048 Application does a 3K write 2K SEQ=2048 Full ACK = 4096 WIN = 0ACK = 4096 WIN = k SEQ=4096 Sender may send up to 2k 2K1K2K

CSCE515 – Computer Network Programming 2007 TCP Segment Order Most TCP implementations will accept out-of- order segments (if there is room in the buffer). Once the missing segments arrive, a single ACK can be sent for the whole thing. Remember: IP delivers TCP segments, and IP in not reliable - IP datagrams can be lost or arrive out of order.

CSCE515 – Computer Network Programming 2007 Termination The TCP layer can send a RST segment that terminates a connection if something is wrong. Usually the application tells TCP to terminate the connection politely with a FIN segment.

CSCE515 – Computer Network Programming 2007 FIN Either end of the connection can initiate termination. A FIN is sent, which means the application is done sending data. The FIN is ACK’d. The other end must now send a FIN. That FIN must be ACK’d.

CSCE515 – Computer Network Programming 2007 App1 App2 FIN SN=X FIN SN=X 1 ACK=X+1 2 ACK=Y+1 4 FIN SN=Y FIN SN=Y 3... “I have no more data for you” “ OK, I understand you are done sending.” Release connection “OK - Now I’m also done sending data”. “Over and Out, Goodbye” Release connection TCP Termination Release connection

CSCE515 – Computer Network Programming 2007 App1 App2 FIN SN=X FIN SN=X 1 ACK=X+1 2 ACK=Y+1 4 FIN SN=Y FIN SN=Y 3... “I have no more data for you” FIN_WAIT_1 “ OK, I understand you are done sending.” CLOSE_WAIT “OK - Now I’m also done sending data”. LAST_ACK “Over and Out, Goodbye” TIME_WAIT TCP Termination FIN_WAIT_2 CLOSED

CSCE515 – Computer Network Programming 2007 TCP TIME_WAIT Once a TCP connection has been terminated (the last ACK sent) there is some unfinished business:  What if the ACK is lost? The last FIN will be resent and it must be ACK’d.  What if there are lost or duplicated segments that finally reach the destination after a long delay? TCP hangs out for a while to handle these situations.

CSCE515 – Computer Network Programming 2007 Test Questions Why is a 3-way handshake necessary? Who sends the first FIN - the server or the client? Once the connection is established, what is the difference between the operation of the server’s TCP layer and the client’s TCP layer? What happens if a bad guy can guess ISNs?