The TCP Protocol Stack

Similar documents
Chapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet

Lecture 2. Outline. Layering and Protocols. Network Architecture. Layering and Protocols. Layering and Protocols. Chapter 1 - Foundation

Concept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space that is provided.

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Lecture 17 Overview. Last Lecture. Wide Area Networking (2) This Lecture. Internet Protocol (1) Source: chapters 2.2, 2.3,18.4, 19.1, 9.

Review of Important Networking Concepts

EITF25 Internet Techniques and Applications L7: Internet. Stefan Höst

Need For Protocol Architecture

Need For Protocol Architecture

TCP/IP THE TCP/IP ARCHITECTURE

Interconnecting Networks with TCP/IP

Position of IP and other network-layer protocols in TCP/IP protocol suite

06/02/ Local & Metropolitan Area Networks 0. INTRODUCTION. 1. History and Future of TCP/IP ACOE322

Network Communication

Introduction to TCP/IP networking

TSIN02 - Internetworking

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

CS 428/528 Computer Networks Lecture 01. Yan Wang

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

OSI Transport Layer. objectives

The Internet Protocol (IP)

TSIN02 - Internetworking

EE 610 Part 2: Encapsulation and network utilities

EEC-484/584 Computer Networks

Data and Computer Communications. Chapter 2 Protocol Architecture, TCP/IP, and Internet-Based Applications

TCP/IP Networking Basics

TSIN02 - Internetworking

Interconnecting Networks with TCP/IP. 2000, Cisco Systems, Inc. 8-1

System Programming. Introduction to computer networks

Socket Programming for TCP and UDP

TSIN02 - Internetworking

Tutorial on Socket Programming

IP Address Assignment

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

Chapter 2 Network Models 2.1

ECE 4450:427/527 - Computer Networks Spring 2017

ECE4110 Internetwork Programming. Introduction and Overview

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

APPENDIX F THE TCP/IP PROTOCOL ARCHITECTURE

Introduction to Internetworking

Networking Fundamentals

The OSI Model. Open Systems Interconnection (OSI). Developed by the International Organization for Standardization (ISO).

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

Copyleft 2005, Binnur Kurt. Objectives

Internet Protocol (IP)

TCP /IP Fundamentals Mr. Cantu

IP Protocols. ALTTC/Oct

Lecture-4. TCP/IP-Overview:

ECPE / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

OSI Transport Layer. Network Fundamentals Chapter 4. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1

Internetwork Protocols

Communicating over the Network

Internet. Organization Addresses TCP/IP Protocol stack Forwarding. 1. Use of a globally unique address space based on Internet Addresses

Part VI. Appendixes. Appendix A OSI Model and Internet Protocols Appendix B About the CD

Single Network: applications, client and server hosts, switches, access links, trunk links, frames, path. Review of TCP/IP Internetworking

CS3600 SYSTEMS AND NETWORKS

Socket Programming TCP UDP

Agenda. Before we start: Assignment #1. Routing in a wide area network. Protocols more concepts. Internetworking. Congestion control

RMIT University. Data Communication and Net-Centric Computing COSC 1111/2061. Lecture 2. Internetworking IPv4, IPv6

Chapter 2 Network Models 2.1

ECPE / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Networking and Internetworking 1

CS 640: Introduction to Computer Networks. Today s Lecture. Page 1

Business Data Networks and Security 10th Edition by Panko Test Bank

EC441 Fall 2018 Introduction to Computer Networking Chapter4: Network Layer Data Plane

JAVA Network API. 2 - Connection-Oriented vs. Connectionless Communication

PROGRAMMING Kyriacou E. Frederick University Cyprus. Network communication examples

NT1210 Introduction to Networking. Unit 10

CSCD 330 Network Programming

Data & Computer Communication

Lesson 5 TCP/IP suite, TCP and UDP Protocols. Chapter-4 L05: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

Defining Networks with the OSI Model. Module 2

Ports under 1024 are often considered special, and usually require special OS privileges to use.

ET4254 Communications and Networking 1

Just enough TCP/IP. Protocol Overview. Connection Types in TCP/IP. Control Mechanisms. Borrowed from my ITS475/575 class the ITL

Chapter 7 Transport Layer. 7.0 Introduction 7.1 Transport Layer Protocols 7.2 TCP and UDP 7.3 Summary

Socket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory

Concept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space provided.

Lecture 8. Reminder: Homework 3, Programming Project 2 due on Thursday. Questions? Tuesday, September 20 CS 475 Networks - Lecture 8 1

DATA COMMUNICATION AND NETWORKS

L1/L2 NETWORK PROTOCOL TESTING

CSEN 503 Introduction to Communication Networks. Mervat AbuElkheir Hana Medhat Ayman Dayf. ** Slides are attributed to J. F.

4.0.1 CHAPTER INTRODUCTION

ARP, IP, TCP, UDP. CS 166: Introduction to Computer Systems Security 4/7/18 ARP, IP, TCP, UDP 1

ISO/OSI Model and Collision Domain NETWORK INFRASTRUCTURES NETKIT - LECTURE 1 MANUEL CAMPO, MARCO SPAZIANI

Applied Networks & Security

The Internet. 9.1 Introduction. The Internet is a global network that supports a variety of interpersonal and interactive multimedia applications.

OSI Layer OSI Name Units Implementation Description 7 Application Data PCs Network services such as file, print,

OSI Reference Model. Computer Networks lab ECOM Prepared By : Eng. Motaz Murtaja Eng. Ola Abd Elatief

ECE 650 Systems Programming & Engineering. Spring 2018

Operating Systems CS 571

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

CS475 Networks Lecture 8 Chapter 3 Internetworking. Ethernet or Wi-Fi).

CN1047 INTRODUCTION TO COMPUTER NETWORKING CHAPTER 6 OSI MODEL TRANSPORT LAYER

Lecture 11: Networks & Networking

Vorlesung Kommunikationsnetze

Outline. Inter-Process Communication. IPC across machines: Problems. CSCI 4061 Introduction to Operating Systems

Review of Important Networking Concepts. Recall the Example from last lecture

Transcription:

The TCP Protocol Stack Michael Brockway February 16, 2018

Introduction - Layered archtecture Networking software is desgined in a layered fashion The bottom layer is the services offered by the underlying hardware and their device drivers: Ethernet, Wifi, BlueTooth, Zigbee all employ electronics to get digital signals from one computing host to another. The next layer is software that employs the lower layer functionality to provide a higher (more abstract) level of service. There will be a sequence of layers each employing the services of the layer below.

Example application programs L 3 application programs process-to-process channels L 2 process 1 process 2 host-to-host connectivity L 1 host-to-host connectivity hardware L 0 hardware The host-to-host connectivity software employs the hardware and its device-drivers to send data to another host. The software driving a process uses this to exchange data with a peer process on another host. Application software uses process-to-process service software to exchange data with another app on another host.

Layered architecture Each layer implements one (or more) protocol. Each protocol defines a service interface: in later L i, defines operations provided by this protocol for layer L i+1 a peer-to-peer interface: defines the messages exchanged with a peer in layer L i. At the hardware level L 0 peer-to-peer communication is directly over a link; at a higher level L i, L i to L i communication is conceptual; in reality it happens by L i making use of services of L i 1 which uses services of L i 2 and so on down to L 0.

Example A application program sending data to a peer using request-reply protocol over host-to-host protocol. application program data RRP RRP;data HHP HHP;RRP;data hardware L 3 L 2 L 1 L 0 application program data RRP RRP;data HHP HHP;RRP;data hardware HHP;RRP;data

Example The application on host 1 sends a message to an application on host2. In practice this the application calls a function in service interface of the Request Reply Protocol software module. The dotted lines show virtual communication between peer entities. RRP attaches some control information in an RRP header to data so that its peer RRP will know what to do when the data is received by it. This combined message is sent to the local host-to-host protocol. HHP attaches HHP-specific header, and the entire message is sent to host 2 Each layer attaches a header (encapsulates the message) as the message goes down. At host 2, each layer removes its header, performs header specific processing and passes the message up.

The ISO seven layer open systems interconnection model L 1 L 2 L 3 L 4 L 5 L 6 L 7 Physical Layer: network hardware; mechanical and electrical connections. Data Link Layer: managed the transmission of data across the physical network. Framing, data transparency and error control. Network Layer: define how addresses are assigned and how data is forwarded from one network to another: routing Transport Layer: Provides reliable, transparent transfer of data between end points. End to end Error recovery and flow control Session Layer: Provides the control structure for communication between applications. Establishes, manages and terminates dialogues between application entities. Specifies security details. Presentation Layer: Provides independence to the application process from differences in data representation. Application Layer: Each protocol specifies how a particular application uses the network and how an application program on one computer makes a request and how the application on another machine responds.

ISO/OSI and TCP/IP The seven-layer model had this many layers to provide for compatibility between network teachnologies. In practice TCP is the standard network technology and protocol suit of the internet. It manages with four layers which correspond to the seven-layer model as follows - OSI Application Presentation Session Transport Network Data link Physical TCP/IP Application TCP, UDP,... IP Network layer of the internet appliction transport network link/physical

TCP/IP TCP/IP (Transmission Control Protocol / Internet Protocol) is the internets communications standard It is a complete suite of protocols and includes network, transport and application layers. It is used in many Unix systems, began in the Unix world; Unix is used widely throughout the Internet. TCP/IP applications (application-layer protocols) include FTP file transfer protocol: nowadays wrapped in a security layer; eg Filezilla Telnet for remote log-in to a server. Now in a security later; eg SSH DHS Domain Name Service. SNMP Simple Network Management Protocol. SNTP Simple Mail Transfer Protocol. HTTP Hypertext transfer protocol - used by web browsers.

TCP (Transport layer) Transmission Control Protocol. Reliable: TCP service takes responsibility for correct delivery of the data to peer; arranges for re-send if a data packet is lost or corrupt; connection-oriented (see below); fragments an incoming byte stream into messages for IP layer; reassembles received messages (passed up from IP layer) in correct order, to create an output stream; manages flow control. Connection-oriented Communication starts by establising a connection or virtual circuit to peer; Data sent either way between peers all follows the same route: goes via the connection; Connection is closed (virtual circuit destroyed) at end of conversation. This software construct is how TCP manages reliable tranport of data in correct order and without data duplication or loss.

UDP (Transport layer) User Datagram Protocol. A best effort service: data errors are detected but no responsibility re-sending. The application has to handle lost or corrupt data. connectionless; Data transimissions - UDP datagrams are separate from one another; each is individually addressed to recipient. no sequencing or flow-control. TCP or UDP? UDP is light-weight compared with TCP; it has much less work to do compared with TCP. Preferred in applications which require many short messages to be sent at high speed: VOIP (telephony), audio, video streaming,... TCP preferred where data exchanges are more heavy-weight : HTTP, WWW

Transport layer data TCP & UDP Segments TCP segment: 32 bits Source port Sequence number Acknowledgment Number Header length & Flags Checksum Options (0 or more) Data (optional with padding) Destination port Window size Urgent pointer UDP segment: 32 bits Source port UDP length Data (optional with padding) Destination port UDP checksum

Transport layer data Port numbers define the ends of logical connections. a message from a process on a host will go to a process on the destination host using the appropriate port number.

IP layer IP Internet Protocol: an unreliable connectionless best effort IP packet delivery service. A question for you to think about: the IP service interface supports both reliable TCP and emphbest-effort UDP. How does an unreliable or best-effort-only service sipport a reliable service? Addressing Routing ARP / RARP (Reverse) Address Resolution Protocol Maps IP addresses onto data link layer addresses such as Ethernet card addresses: eg 193.63.32.233 to (MAC address) 008002B39DD10 Its functions are defined as part of TCP/IP but its implementation is dependent on the network type. TCP/IP does not define what happens below the IP layer.

Transport layer data IP Datagram and TCP/IP Packet Format IP datagram format: 32 bits Version HLen Type of service Identification Time to live Protocol Source IP Address Destination IP address Options (0 or more) Data (optional with padding) Total length Fragment offset & flags Header checksum TCP/IP packet structure: LAN Header IP Header TCP/UDP Header Application Data LAN Trailer

32-bit IP Addresses 32 bit addresses specify sources and target hosts. normally represented in dotted decimal format, each block describing 8 bits: thus 193.63.32.233 is the sames as 0xC13F20E9 or in binary, 11000001 00111111 00100000 11101001 Each IP address has two components: the higher bits identify a local network; the lower bits an individual host or interface to a router, within a network. Hosts on the same network must have IP addresses with the same network part, but different host parts. Hosts with different network address parts might be connected by a router (eg, with two interfaces with network parts agreeing with the two hosts). Originally the network part was 8, 16, or 24 bits (class A, B or C); now using CIDR (classless interdomain routing) and VLSM (variable-length subnet masking) can be any size. eg 223.1.252.3 within the subnet 223.1.252.0/22 would need subnet mask 255.255.252.0, in binary, 11111111 11111111 11111100 00000000: 22 bits network part.

Domain names To avoid referring to individual numerical IP addresses the concepts of domain names and host names developed. Domain and host names are mapped to IP addresses. cougar.unn.ac.uk 193.63.32.233; no logical relationship between the parts of an IP address and its domain name. The mapping is done using Domain Name Resolution, normally with the help of a Domain Name Server. There are not enough 32-bit addresses! More than 2 32 (4 billion) addresses are needed. For many years the internet has coped by allowing addresses to be duplicated, with routers doing IP address translation to prevent address clashes outside of LANs. this makes DNS especially handy! IP v 6 specifies 64-bit addresses - clean resoltution of the problem but IP v 6 is very slow to be adopted by users.

Programming TCP connection The focus is on applications using transport layer services, especially TCP, UDP; useful for development of distributed applications. The basic software entity is a socket. role similar to a file-handle; First, the socket is connected to a remote host (compare with opening a file); then data is input/output through the socket; when complete, the socket is closed the connection is broken. Implemented in Java using package java.net, espectially class java.net.socket. C provides the socket class and a library of socket functions prototyped in <sys/socket.h>.

Programming TCP connections #include <sys/socket.h> int socket(...); creates a new socket int gethostname(char *name, int namelen); translates a host name to an ip address int bind(int s, struct sockaddr *name, int namelen); binds a socket to a specific address (and port) int connect(int s, struct sockaddr *addr, int *addrlen); used by client to request a socket connection to a remote address (and port) void listen (socket id s, int backlog ); causes server to start listening for requests for a connection int accept(int s, struct sockaddr *addr, int *addrlen); used by server to accept a connection request from a client int read(int d, char *buf, int nbytes); int write(int d, char *buf, int nb); d = socket id; reads from/writes to a socket int close(int d);

TCP server logic In general, the behaviour you have to program is dependent on the state of the system. There you tend to write such constructs as Fix the port number Create a socket for the server Start listening on the socket for requests to connect Repeat Wait for a request for a connection. Accept function returns id of a new socket which will manage t connection; also gets the name of the client host. Spin off a new thread to serve the client; Serving the client A subroutine running in a new thread Uses socket returned by Accept function Uses socket I/O functions to send data to / receive data from client according to protocol When finished, closes the socket.

TCP client logic In general, the behaviour you have to program is dependent on the state of the system. There you tend to write such constructs as Specify server name/addr, port num to which we wish to connect; Create a socket; Bind this socket to host name and port number; Request a connection to the server host / port; if (return value indicates connection successful) use socket I/O functions to send data to/receive data; Close the socket when finished. The port number is same at both ends: identifies the virtual circuit between the client and server.

Programming UDP Again use a socket but no connection is established. Instead, a version of the send function is used which incorporates a destination address parameter: int sendto(int sockid, char * msg, unsigned int msglen, int flags, struct sockaddr * destaddress, unsigned int addresslen)...and a version of the receive function is used which incorporates a source address parameter: int recvfrom(int sockid, char * msg, unsigned int msglen, int flags, struct sockaddr * sourceaddress, unsigned int * addresslen) The return value in each case is the number of bytes sent/received. Note is the use of pointers to provide in/out parameters: note the int * (rather than int) for the receive function s address length parameter.

Further reading RFC1122 Requirements for Internet Hosts Communication Layers https://en.wikipedia.org/wiki/internet protocol suite https://www.w3.org/people/frystyk/thesis/tcpip.html https://en.wikibooks.org/wiki/a-level Computing/AQA/ Computer Components, The Stored Program Concept and the Internet/ Structure of the Internet Requests for comment (RFCs): the following are easily found by internet search: RFC1123 Requirements for Internet Hosts Application and Support RFC768 User Datagram Protocol RFC793 TRANSMISSION CONTROL PROTOCOL