Introduction to TCP A first look at the sockets API for ‘connection-oriented’ client/server application programs.

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

CCNA – Network Fundamentals
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
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.
Transport Layer3-1 TCP. Transport Layer3-2 TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex data: m bi-directional data flow in same connection.
CSEE W4140 Networking Laboratory Lecture 6: TCP and UDP Jong Yul Kim
Data Communications and Computer Networks Chapter 3 CS 3830 Lecture 16 Omar Meqdadi Department of Computer Science and Software Engineering University.
UDP & TCP Where would we be without them!. UDP User Datagram Protocol.
Chapter 12 Transport protocols. Outline 12.1 introduction 12.2 TCP/IP protocol suite.
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.
Transmission Control Protocol (TCP) Basics
CP476 Internet Computing TCP/IP 1 Lecture 3. TCP / IP Objective: A in-step look at TCP/IP Purposes and operations Header specifications Implementations.
CS3505 The Internet and Info Hiway transport layer protocols : TCP/UDP.
Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.
BZUPAGES.COM 1 User Datagram Protocol - UDP RFC 768, Protocol 17 Provides unreliable, connectionless on top of IP Minimal overhead, high performance –No.
Transport Layer – TCP (Part1) Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
Chapter 7: Objectives Part 1
Chapter 7 – Transport Layer Protocols
EECC694 - Shaaban #1 lec #12 Spring Internet Transport Protocols Transmission Control Protocol (TCP):Transmission Control Protocol (TCP):
TELE202 Lecture 14 TCP/UDP (2) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (1) »Source: chapter 17 ¥This Lecture »TCP/UDP (2) »Source: chapter.
Copyright 1999, S.D. Personick. All Rights Reserved. Telecommunications Networking II Lecture 32 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
TCP© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department.
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.
CSCE 515: Computer Network Programming Chin-Tser Huang University of South Carolina.
TCP. Learning objectives Reliable Transport in TCP TCP flow and Congestion Control.
Chapter 4 OSI Transport Layer
Gursharan Singh Tatla Transport Layer 16-May
Microsoft Windows Server 2003 TCP/IP Protocols and Services Technical Reference Slide: 1 Lesson 12 Transmission Control Protocol (TCP) Basics.
TRANSPORT LAYER T.Najah Al-Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
1 Transport Layer Computer Networks. 2 Where are we?
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.
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.
TCP Lecture 13 November 13, TCP Background Transmission Control Protocol (TCP) TCP provides much of the functionality that IP lacks: reliable service.
University of the Western Cape Chapter 12: The Transport Layer.
ECE453 – Introduction to Computer Networks Lecture 14 – Transport Layer (I)
David Wetherall Professor of Computer Science & Engineering Introduction to Computer Networks Transport Layer Overview (§ )
Copyright 2002, S.D. Personick. All Rights Reserved.1 Telecommunications Networking II Topic 20 Transmission Control Protocol (TCP) Ref: Tanenbaum pp:
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 2 Applications and Layered Architectures Sockets.
Chapter 24 Transport Control Protocol (TCP) Layer 4 protocol Responsible for reliable end-to-end transmission Provides illusion of reliable network to.
© Jörg Liebeherr (modified by Malathi Veeraraghavan) 1 Overview Formats, Data Transfer, etc. Connection Management.
1 End-to-End Protocols UDP TCP –Connection Establishment/Termination –Sliding Window Revisited –Flow Control –Congestion Control –Adaptive Timeout.
11 CS716 Advanced Computer Networks By Dr. Amir Qayyum.
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.
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
Introduction to Networks
5. End-to-end protocols (part 1)
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 12 Transmission Control Protocol
PART 5 Transport Layer.
TCP - Part I Relates to Lab 5. First module on TCP which covers packet format, data transfer, and connection management.
Introduction to Computer Networks
Transport Layer 9/22/2019.
Presentation transcript:

Introduction to TCP A first look at the sockets API for ‘connection-oriented’ client/server application programs

Benefits of TCP Communication is ‘transparently reliable’ Data is delivered in the proper sequence An application programmer does not need to worry about issues such as: –Lost or delayed packets –Timeouts and retransmissions –Duplicated packets –Packets arriving out-of-sequence –Flow and congestion control

network layer transport layer application layer Overview T C P port P port Q ………… I P unreliable IP datagrams process A process B reliable TCP byte-stream connection

Transport-Layer’s duties Create the illusion of a reliable two-way point-to-point connection linking a client application with a server application –Manage the ‘error-control’ mechanism –Manage the ‘flow-control’ mechanism –Manage the connection’s ‘persistence’ –Manage the connection’s ‘shutdown’

Interaction overview socket() bind() listen() accept() read() write() close() socket() bind() connect() write() read() close() The ‘server’ application The ‘client’ application 3-way handshake data flow to server data flow to client 4-way handshake

What is a ‘connection’? An application’s socket is ‘connected’ if it has a defined pair of socket-addresses: –An IP-address and port-number for the ‘host’ –An IP-address and port-numbet for the ‘peer’ ‘hopper.usfca.edu’ port port USF’s web-server ‘hrn23501.usfca.edu’ port port 80 classroom workstation 2-way data stream

Layout of TCP header destination port address sequence number acknowledgment number Header Length options and padding source port address 32-bits window size urgent pointer FINFIN SYNSYN RSTRST PSHPSH ACKACK URGURG reserved checksum

Sequence number data (256 bytes) The sequence number field defines the number being assigned to the first byte of data contained in this segment. During connection setup, each party to the connection uses a random number generator to get the value it will assign to the first byte of data it will transmit, called its initial sequence number (ISN). Thereafter, the sequence number in each succeeding segment will equal the sequence number used in the prior segment plus the number of data bytes in that prior segment. By this scheme the receiver can arrange all the incoming data bytes in the proper order, even if some segments happen to arrive out-of-order. data (256 bytes) data (256 bytes) data (232 bytes) ISNISN + 256ISN + 512ISN segmented stream of 1000 bytes

Acknowledgment number This field holds the number of the byte that the source of this segment is expecting to receive next from its connection partner This field’s value is meaningful only when this segment’s ACK control flag bit is set sender receiver 9, 8, 7 6, 5  4, 3, 2, 1 ACK 5

TCP Header Length Like IP headers, the TCP Header’s length is expressed in multiples of 32-bits: it’s at least 5 (i.e., 20-bytes) if there aren’t any ‘TCP Options’ included in the TCP header The amount of DATA in a TCP packet can be calculated from the IP Header’s ‘Total Length’ field, minus the number of bytes that comprise these two headers (IP header + TCP header) IP headerTCP headerDATA Total Length (in bytes)

Control flags URGURG ACKACK PSHPSH RSTRST SYNSYN FINFIN Legend: FIN = Terminate the connection SYN = Synchronize sequence numbers RST = Reset the connection PSH = Push the data ACK = The value in the acknowledgement field is valid URG = The value in the urgent pointer field is valid

Establishing the connection server application (passive) client application (active) timeline SYN J SYN K, ACK J+1 ACK K+1 The 3-way Handshake

Exchanging data server application (passive) client application (active) timeline PSH+ACK ACK PSH+ACK A typical Request and Reply transaction

Connection shutdown server application (passive) client application (active) timeline ACK+FIN ACK The 4-way Handshake ACK+FIN

3-way handshake SYN ACK + SYN ACK

‘request-and-reply’ ACK+PSH ACK ACK+PSH ACK+FIN

4-way handshake ACK+FIN ACK ACK+FIN ACK

TCP Timers To achieve transparent reliability, the TCP subsystem maintains some internal timers One of these is the ‘Retransmission Timer’ If a packet is sent, but its ACK does not arrive before this timer expires, then the packet will be ‘retransmitted’ Of course, this could result in the receiver getting duplicate packets (if it’s a bit slow)

‘lost’ versus ‘late’ client application server application timeline ACK PSH+ACK Busy server might be ‘slow’ to acknowledge PSH+ACK retransmit timeout ACK arrives late same PSH arrives twice

‘piggyback’ To reduce traffic-flow when possible, TCP delays sending an immediate ACK for an arriving data-packet, in case the receiver might soon have some data of its own to send back – in which case the ACK can ‘piggyback’ on the outgoing data PSH This mechanism, of course, requires TCP to maintain a ‘Delayed ACK’ timer

Delayed ACK senario transport layer application layer T C P port P …… process A buffer for outgoing data buffer for incoming data writeread Retransmit timer Delayed ACK timer Keep Alive timer Window Probe timer to/from the IP layer

Window Size During the ‘connection setup’ handshake, each host communicates to its partner a ‘window size’ parameter, to let be known some information about its capacity for buffering packets It also conveys its ‘MSS’ parameter (as a ‘TCP header option’) to inform its partner of its buffers’ Maximum Segment Size

MSS versus MTU A diagram shows the distinction between the protocol’s MSS (Maximum Segment Size) and the interface’s MTU (Maximum Transmission Unit); no TCP packets will be sent with a segment-size that’s larger datalink header IP header TCP header packet DATA FCS MSS MTU

Main TCP option types The TCP Header contains an options list, occupying from 0 to 11 longword values Each option is identified by an 8-bit ‘type’: Type 0: End of the options list: data follows this Type 1: No option: used for alignment padding Type 2: Maximum Segment Size (MSS) Type 3: Window scaling option (WSOPT) Type 4: Selective Acknowledgments supported Type 5: Selective Acknowledgment (SACK) Type 8: Timestamp value and echo reply (TSOPT)

Option formats Option types 0 and 1 are single-bytes All other option types are at least 2-bytes, with the second byte containing the length type 2 length 4 MSS value type 3 length 3 WSOPT value 4 bytes2 bytes type 4 length 2 3 bytes type 8 length bytes timestamp value timestamp echo reply value

Looking at TCP options HLEN

‘Wrapped’ sequences The TCP header’s ‘Sequence Number’ is a 32-bit value, initially chosen at random It could happen that a large number gets selected as an Initial Sequence Number and that a large amount of data gets sent, thus causing the 32-bit field to ‘overflow’ So how does the receiver tell a ‘wrapped sequence’ from a ‘late-arriving’ segment?

Type 8: TSOPT The TCP timestamps have two purposes: –RTTM: Round-Trip Time Measurement –PAWS: Protect Against Wrapped Sequences TYPE (=8) Timestamp Value Timestamp Echo Reply LENGTH (=10) 16 bits

The SACK option It conveys extended ‘acknowledgment’ information from a receiver to a sender about ‘gaps’ in the received data-stream Type (=5)Length Left Edge of first Block Right Edge of first Block... Left Edge of n-th Block Right Edge of n-th Block 32-bits 2+n*8 bytes no gaps here

Demo programs We put ‘tcpserver.cpp’ and ‘tcpclient.cpp’ on our class website, so you can watch actual TCP packets being exchanged by using our ‘nicwatch’ application (or some other packet-sniffer, e.g., ‘wireshark’) We deliberately used loops which write to, or read from, sockets one-byte-at-a-time so that you can observe ‘TCP buffering’!