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

Similar documents
TSIN02 - Internetworking

OSI Transport Layer. objectives

TSIN02 - Internetworking

TSIN02 - Internetworking

TSIN02 - Internetworking

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

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

User Datagram Protocol (UDP):

User Datagram Protocol

CS4700/CS5700 Fundamentals of Computer Networks

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

CS457 Transport Protocols. CS 457 Fall 2014

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

Lecture 3: The Transport Layer: UDP and TCP

Networking Technologies and Applications

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

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

The Transport Layer. Part 1

TCP /IP Fundamentals Mr. Cantu

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

4.0.1 CHAPTER INTRODUCTION

Chapter 5 End-to-End Protocols

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

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

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

CCNA 1 v3.11 Module 11 TCP/IP Transport and Application Layers

Transport Layer (TCP/UDP)

NT1210 Introduction to Networking. Unit 10

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

05 Transmission Control Protocol (TCP)

Connections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network

EEC-682/782 Computer Networks I

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

ETSF05/ETSF10 Internet Protocols Transport Layer Protocols

The Transport Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

Introduction to TCP/IP networking

Transport Layer Marcos Vieira

UDP, TCP, IP multicast

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

The Transport Layer: TCP & Reliable Data Transfer

Application. Transport. Network. Link. Physical

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

ITS323: Introduction to Data Communications

CSCI-GA Operating Systems. Networking. Hubertus Franke

9th Slide Set Computer Networks

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

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

Kent State University

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

Transport Over IP. CSCI 690 Michael Hutt New York Institute of Technology

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

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

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

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

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

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

Transport Protocols and TCP

ECE 650 Systems Programming & Engineering. Spring 2018

CS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP

CSCI-1680 Transport Layer I Rodrigo Fonseca

QUIZ: Longest Matching Prefix

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

CSE 461 Connections. David Wetherall

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

Announcements Computer Networking. Outline. Transport Protocols. Transport introduction. Error recovery & flow control. Mid-semester grades

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

Simulation of TCP Layer

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

CSCI-1680 Transport Layer I Rodrigo Fonseca

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

CSEP 561 Connections. David Wetherall

6. The Transport Layer and protocols

Unit 2.

CPSC156a: The Internet Co-Evolution of Technology and Society. Lecture 4: September 16, 2003 Internet Layers and the Web

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

NWEN 243. Networked Applications. Layer 4 TCP and UDP

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

Transport Layer Protocols. Internet Transport Layer. Agenda. TCP Fundamentals

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

Internet and Intranet Protocols and Applications

Introduction to Network. Topics

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

CSEP 561 Connections. David Wetherall

Lenuta Alboaie Computer Networks

UNIT IV TRANSPORT LAYER

CS UDP: User Datagram Protocol, Other Transports, Sockets. congestion worse);

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

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

ECE 333: Introduction to Communication Networks Fall 2001

Linux Networking: tcp. TCP context and interfaces

CMPE 80N: Introduction to Networking and the Internet

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

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

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

TCP/IP. Chapter 5: Transport Layer TCP/IP Protocols

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

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

TCP : Fundamentals of Computer Networks Bill Nace

Transcription:

ELEX 4550 : Wide Area Networks 2015 Winter Session UDP and TCP is lecture describes the two most common transport-layer protocols used by IP networks: the User Datagram Protocol (UDP) and the Transmission Control Protocol (TCP). A er this lecture you should be able to: predict the values of the following UDP and TCP header fields: source and destination port numbers, checksum, length, sequence number, acknowledgment, flags and window; predict the change of TCP state machine state as a result of a socket API call or receiving a frame with specific bits set; predict the maximum amount of data that will be sent in the next TCP segment based on the sequence numbers of queued data and the values in a received TCP header. Introduction So far we have studied some data link layer protocols such as PPP which are responsible for getting data from one end of a channel to the other, and the IP network layer protocol which is responsible for getting IP packets from one host to another. In this lecture we look briefly at two transport layer protocols that make it easier to write networking applications. e transport layer serves to connect client applications on one host to the desired server processes on another. In addition, some transport protocols provide other services such as reliable, in-sequence message delivery and congestion control that are not provided by IP. Applications that make use of transport layer services include clients such as web browsers or servers such as file servers. e two transport-layer protocols in common use are: UDP - sends a packet from a port on one machine to a port on another machine but, like IP, does not ensure delivery; relatively simple TCP - use a connection-oriented model that provides reliable byte pipe from a process on one machine to process on another; relatively complex Other abstractions, such as a reliable datagram protocol, would be possible but having only two transport protocols keeps things simple for implementers. Transport Layer Functions e most important features we might like to get from a transport protocol include: reliable delivery: sender receives an acknowledgment that the data was received sequencing: packets are guaranteed to arrive in the same order they were sent no duplication: data is not duplicated fragmentation: arbitrarily-long byte sequences can be broken down into smaller packets (called segments in TCP) and reassembled at the destination flow control: the receiver can be told (or can infer that it should) slow down the rate at which it sends data to a destination multiplexing: we can have multiple simultaneous connections between hosts, even to the same service In the same way that IP addresses are used to specify a particular host, a server can provide multiple types of services. Each such service needs an address or service access point (SAP). In TCP/IP SAPs are defined by an associated 16-bit numbered port. e Internet Assigned Numbers Authority (IANA) assigns port numbers to protocols (e.g. 80 for HTTP, 25 for SMTP,...). Each transport-layer IP connection is uniquely defined by the combination of 4 things: host and destination addresses and host and destination port numbers. Each different 4-tuple defines a different connection. is explains how, for example, multiple users on the same client can contact the same service on the same server. Exercise 1: Two users on the same client connect to the same web server. Which of the addresses and ports are the same? Which are different? lec15.tex 1

UDP e UDP (User Datagram Protocol),defined in RFC- 768, is a simple 1 protocol that provides little more that is provided by IP. UDP does not offer flow control, reliable delivery, un-duplicated or in-sequence delivery. Instead,these features must be provided by the application. is allows more flexibility at cost of additional complexity in the application. UDP Header e following diagram, from RFC-768, shows the UDP header: Examples of UDP-Based Applications A typical UDP-based application is the DNS. A single UDP packet containing the query is sent to a DNS server and a single UDP response is received with the response. e application must handle delayed, duplicated or lost frames. Another class of applications for UDP is interactive applications such as VoIP (voice over IP). Latency is very important for interactive applications sometimes more important than avoiding loss of data. e reliable-delivery and congestion control features of TCP can sometimes result in long delays. Interactive applications o en use UDP so they can implement their own error- and congestion-control algorithms. 0 7 8 15 16 23 24 31 Source Destination Port Port Length Checksum data octets... +----------------... User Datagram Header Format e header has four 16-bit words: source and destination ports, length, and a checksum. e main purpose of the header is to specify the destination SAP (port or service) that should handle the packet. For example, a DNS server listens on port 53 and a DHCP server on port 67. e source port is included so a client can listen for a UDP datagram sent as a response. e length is the number of bytes in the UDP datagram, including this UDP header. e checksum is the regular IP 16-bit one s complement checksum applied to the header, data and three 32-bit words from the IP header (the IP pseudoheader ) as shown below: 0 7 8 15 16 23 24 31 source address destination address zero protocol UDP length Exercise 2: What are the minimum and maximum values for the UDP length field? 1 e RFC is only 2 pages. TCP Transmission Control Protocol (TCP) is the most commonly-used transport-layer protocol. It is defined in RFC 793 2. Like UDP, TCP connections are established between ports that allow multiple simultaneous connections between hosts and also allow selection of the service that clients connect to. Unlike UDP, TCP supplies a reliable byte pipe even though the underlying network can delete, reorder and even duplicate packets. TCP is a full duplex protocol it provides reliable byte streams in both directions. A TCP connection has state that needs to be maintained for each connection (host/port addresses, sequence numbers, buffers, timers,...). is state, stored in a Transmission Control Block, needs to be initialized when the connection is set up and the memory used to store this state must be released when the connection is terminated. To deal with highly variable network delays and data rates, TCP uses a sliding window ARQ protocol to: control congestion - excessive traffic on links which results in buffer overflows, and implement flow control - to prevent traffic being generated faster than it can be processed at the destination host. It is important to understand that although the TCP frame format and the protocol state machine are 2 TCP is much more complex than UDP, RFC 793 is 85 pages. 2

defined in RFC 793, there is considerable variation in TCP implementations because: TCP allows for options to be negotiated at the start of the connection; hosts may implement different sets of options, and the algorithms used to, for example, decide how long to wait before transmitting or retransmitting a frame are implementation-dependent. TCP Header e following diagram, from RFC-793, shows the contents of the TCP header: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 Source Port Destination Port Sequence Number Acknowledgment Number Data U A P R S F Offset Reserved R C S S Y I Window G K H T N N Checksum Urgent Pointer Options Padding data e source and destination ports have the same meaning as in UDP. e TCP protocol treats the data as two continuous sequences of numbered bytes flowing in the two directions. ese sequences of bytes are divided into segments, each of which is transmitted in a separate IP frame. e Sequence Number is the number of the first byte of the segment carried in this frame. e Acknowledgment Number is the number of the last byte received in the other direction. e Window value can be interpreted to mean how many bytes of buffer space the receiver currently has available. e other host uses this to decide how much more data can be sent. Note that Sequence number refers to the data being transmitted in the same frame while Acknowledgment and Window refer to the data flowing in the opposite direction (from the other host). Sequence numbers are also incremented before the first byte (a er SYN) and a er the last byte (a er FIN) even though no extra data bytes are sent. is allows acknowledgement of the start and end of a connection. Note that sequence numbers do not normally begin with 0. e Sequence Number value transmitted with the SYN packet determines the starting value. Exercise 3: The most recently received TCP packet for a connection had an Acknowledgement Number value of 1000 and a Window value of 64. Assuming 1024 bytes are ready to be sent, what will be the value of Sequence Number in the next packet transmitted for that connection? What will be the length of the IP packet? e Data Offset the number of 32-bit words in the TCP header (including options). e 6 bits in the flag field are used to manage the TCP connection: the URG and ACK bits indicate that the values in the Urgent Pointer and Acknowledgment Number fields are valid. the SYN and FIN bits are used to start and terminate a connection. e PuSH bits can be used to indicate the end of a message defined by a higher-level protocol. e RST bit is used to indicate a loss of synchronization (e.g. Acknowledgment of data not sent) and causes the connection to be closed. e checksum is computed over the TCP header, an IP pseudo-header as with UDP, and the data. e URG bit and the Urgent pointer were meant to allow high-priority data to be sent ahead of lower-priority data within the same TCP connection. It is rarely used. TCP State Machine e ASCII diagram below, taken from RFC-793, describes the TCP state machine. e text in each block labels that state. e labels on the state transition path state the action or received flag bits that cause the transition (above the line) and the bits that are set in the frame that is sent in response (below the line). Other labels are x (send nothing), active/passive OPEN (client/server socket creation), create/delete TCB (allocate/release data structures for the connection) and a Timeout (2 120 seconds). Study of the diagram shows that setup and tear-down of a TCP connections requires a 3-way handshake { SYN, SYN+ACK, ACK } or { FIN, FIN+ACK, ACK }. e above is a quick summary of how connections 3

+---------+ ---------\ active OPEN CLOSED \ ----------- +---------+<---------\ \ create TCB ^ \ \ snd SYN passive OPEN CLOSE \ \ ------------ ---------- \ \ create TCB delete TCB \ \ V \ \ +---------+ CLOSE \ LISTEN ---------- +---------+ delete TCB rcv SYN SEND ----------- ------- V +---------+ snd SYN,ACK / \ snd SYN +---------+ <----------------- ------------------> SYN rcv SYN SYN RCVD <----------------------------------------------- SENT snd ACK ------------------ ------------------- +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ -------------- ----------- x snd ACK V V CLOSE +---------+ ------- ESTAB snd FIN +---------+ CLOSE rcv FIN V ------- ------- +---------+ snd FIN / \ snd ACK +---------+ FIN <----------------- ------------------> CLOSE WAIT-1 ------------------ WAIT +---------+ rcv FIN \ +---------+ rcv ACK of FIN ------- CLOSE -------------- snd ACK ------- V x V snd FIN V +---------+ +---------+ +---------+ FINWAIT-2 CLOSING LAST-ACK +---------+ +---------+ +---------+ rcv ACK of FIN rcv ACK of FIN rcv FIN -------------- Timeout=2MSL -------------- ------- x V ------------ x V \ snd ACK +---------+delete TCB +---------+ ------------------------> TIME WAIT ------------------> CLOSED +---------+ +---------+ TCP Connection State Diagram Figure 6. are set up and torn down. ere are many more details which we do not have time to cover in this course. Exercise 4: According to the TCP state transition diagram, what should happen if a host responds to an initial SYN frame by sending back a frame with only SYN set? Also note that connections can be closed in one direction only. Congestion Management In TCP When more data arrives at a router than can be sent out, the data will build up in queues. is is called congestion. If the queues get too long then packets will have to be dropped. ese frames then have to be retransmitted. is increases the load on the network which can then become unstable. Rather than using an explicit mechanism to monitor congestion, TCP checks for it indirectly by measuring packet loss and delay. Since each packet is routed independently, the network layer (IP) cannot determine packet delay or loss. On the other hand, TCP sees acknowledgments and so it can measure delays and detect lost frames and take appropriate measures to deal with congestion. e transport layer is thus made responsible for congestion management and flow control. One of the main purposes of TCP is to minimize the likelihood of dropped frames by reducing the rate at which frames are sent out when congestion is detected. e algorithms to do this are fairly complex and implementation-dependent. We will not cover them here. Exercise 5: How can a host reduce the rate at which data is sent to it on a TCP connection? Examples of TCP-Based Applications Most internet applications use TCP. is includes web browsers (the HTTP protocol, server on port 80), e-mail transfer (the SMTP protocol, port 25), secure shell login (the SSH protocol, port 22) and many others. Most of these protocols are text-based which simplifies writing and debugging the applications. For example, an an HTTP client first establishes a TCP connection and then sends a line starting with GET followed by the URL, the HTTP version and a CR character followed by headers. Here is an example of how we can emulate the behaviour of a web browser using the telnet utility from the command line: telnet www.bcit.ca 80 Trying 142.232.77.1... Connected to www.bcit.ca. Escape character is '^]'. GET http://www.bcit.ca/study/ HTTP/1.1 Host: www.bcit.ca e server responds with some headers, a blank line and the page contents in the HTML markup language. Many other Internet protocols work similarly. For example the SMTP protocol uses commands such as HELO, FROM, MAIL and DATA to transfer e-mail messages. The Socket API e socket library is commonly used to implement network client and server so ware that uses the TCP/IP protocol. An API (Application Programming Interface) is a set of functions that can be called 4

by a program to implement the networking parts of the program. Although you do not need to be able to write such applications, it is useful to know how the API is accessed and you should know which of these calls cause changes of state in the TCP state machine. e main functions are: socket() - allocates and initializes the required data structures (e.g. a TCB) bind() - sets the local address (port) (typically used only on the server side) listen() - enables incoming connections (on server) the passive open described above accept() - waits for incoming connections (on server) connect() - waits for outgoing connections (on client) the active open described above send() write()] - sends bytes over the connection receive()read() - reads bytes received over the connection close() - shuts down the connection and releases memory the close described above Other library functions are o en required. For example, the gethostbyname() function can be used by the application to convert a host name to an IP address. e method is implementation-dependent, but typically it s by querying the local host files and/or using the DNS protocols. 5