User Datagram Protocol

Similar documents
Transport Layer Marcos Vieira

ECE4110 Internetwork Programming. Introduction and Overview

Networking Technologies and Applications

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

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

Introduction to TCP/IP networking

Computer Network Programming. The Transport Layer. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University

User Datagram Protocol (UDP):

QUIZ: Longest Matching Prefix

Sequence Number. Acknowledgment Number. Checksum. Urgent Pointer plus Sequence Number indicates end of some URGENT data in the packet

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

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

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

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

Mobile Transport Layer Lesson 02 TCP Data Stream and Data Delivery

Chapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control

CSC 634: Networks Programming

05 Transmission Control Protocol (TCP)

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

ECE 650 Systems Programming & Engineering. Spring 2018

CS457 Transport Protocols. CS 457 Fall 2014

TCP : Fundamentals of Computer Networks Bill Nace

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

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

TSIN02 - Internetworking

Information Network 1 TCP 1/2

CSE 461 The Transport Layer

Simulation of TCP Layer

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

ITS323: Introduction to Data Communications

Introduc)on to Computer Networks

Last Class. CSE 123b Communications Software. Today. Naming Processes/Services. Transmission Control Protocol (TCP) Picking Port Numbers.

TSIN02 - Internetworking

Kent State University

Applied Networks & Security

CSCI-1680 Transport Layer I Rodrigo Fonseca

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

CSCI-GA Operating Systems. Networking. Hubertus Franke

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

CSCI-1680 Transport Layer I Rodrigo Fonseca

OSI Transport Layer. objectives

TSIN02 - Internetworking

Stream Control Transmission Protocol

TSIN02 - Internetworking

Transmission Control Protocol (TCP)

Some slides courtesy David Wetherall. Communications Software. Lecture 4: Connections and Flow Control. CSE 123b. Spring 2003.

EEC-682/782 Computer Networks I

Introduction to Networks and the Internet

CSE/EE 461 Lecture 13 Connections and Fragmentation. TCP Connection Management

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

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

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

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

Unit 2.

The Transport Layer. Part 1

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

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

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

CSEP 561 Connections. David Wetherall

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

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

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

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

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

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

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

Transport Layer. Gursharan Singh Tatla. Upendra Sharma. 1

NT1210 Introduction to Networking. Unit 10

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

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

Introduction to Internet. Ass. Prof. J.Y. Tigli University of Nice Sophia Antipolis

Chapter 24. Transport-Layer Protocols

End-to-End Protocols. End-to-End Protocols

Transport Protocols & TCP TCP

UNIT IV -- TRANSPORT LAYER

CS4700/CS5700 Fundamentals of Computer Networks

CSE 461 Connections. David Wetherall

Lecture 3: The Transport Layer: UDP and TCP

ECE 435 Network Engineering Lecture 15

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

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

Chapter 5 End-to-End Protocols

TCP/IP Protocol Suite 1

Sequence Number. Acknowledgment Number. Data

Reliable Transport I: Concepts and TCP Protocol

What is TCP? Transport Layer Protocol

Unix Network Programming

CSC 401 Data and Computer Communications Networks

Reliable Byte-Stream (TCP)

Transport Layer: outline

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

CSEP 561 Connections. David Wetherall

TCP /IP Fundamentals Mr. Cantu

II. Principles of Computer Communications Network and Transport Layer

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

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

Multiple unconnected networks

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

TCP Overview. Connection-oriented Byte-stream

EE 610 Part 2: Encapsulation and network utilities

Transcription:

Topics Transport Layer TCP s three-way handshake TCP s connection termination sequence TCP s TIME_WAIT state TCP and UDP buffering by the socket layer 2

Introduction UDP is a simple, unreliable datagram protocol TCP is a sophisticated, reliable byte-stream protocol Understanding these protocols help you make better decisions when developing applications that utilize the transport layer Additionally, understanding services provided by these protocols enables you know what must be handled in the application 3

The Big Picture 4

User Datagram Protocol Simple, unreliable, connectionless, datagram service Application writes a message to the UDP socket, the message is encapsulated in an UDP packet, then further encapsulated in an IP datagram, and sent to its destination NO guarantee UDP will reach its destination or that the packet order will be preserved Extra functionality can be built into the application: acknowledgments, timeouts, retransmissions, etc. UDP differs from TCP in that it has a specified length. TCP is a byte-stream protocol with no record boundaries 5

Transmission Control Protocol TCP provides connections between clients and servers Typical communication: 1) TCP client establishes connection; 2) exchanges data; 3) terminates connection TCP provides reliability: -When TCP sends data it requires an acknowledgement (ACK) -If an ACK is not received, TCP retransmits the data and increases the timeout window -After several retransmissions TCP will give up 6

Transmission Control Protocol (Continued) TCP DOES NOT guarantee that the data will be received by the other endpoint That s impossible! It delivers data to the other endpoint if possible, and notifies the user if it is not possible (by giving up on retransmissions) Thus, TCP can t be described as a 100% reliable protocol; it provides reliable delivery of data or a reliable notification of failure 7

Transmission Control Protocol (Continued) TCP contains algorithms to dynamically estimate the round-trip-time (RTT) between a client and a server This tells TCP how long to wait for an ACK Which is greater - the RTT of a LAN or WAN? TCP continuously estimates the RTT of a given connection, because the RTT is affected by traffic variations TCP also sequences data by associating sequence numbers with ever byte it sends 8

Transmission Control Protocol (Continued) For Example: If an application writes 2,048 bytes to a TCP socket, causing TCP to send two segments: first with sequence number 1-1,024 and the second with sequence numbers 1,025 2,048 If the segment arrives out of order, the receiving TCP will reorder the segments based on sequence number before passing them up to the application layer Sequence numbers also protects against processing duplicate segments 9

Transmission Control Protocol (Continued) TCP provides a full-duplex connection with flow control TCP tells its peer exactly how many bytes of data it is willing to accept from the peer at any one time This is called the advertised window At any time, the window is the amount of room currently available in the receive buffer This guarantees that the sender can t overflow the receiver s buffer As data is received by the sender, the window size decreases, but as the receiving application reads data from the buffer, the window size increases A window size of 0 implies that that the receive buffer is full and waiting for the application to read data 10

TCP Connection Establishment: Three Way Handshake The minimum number of packets required for this exchange is three The acknowledgment number in an ACK is the next expected sequence number for the end sending the ACK 11

TCP Connection Establishment: Three Way Handshake Consider the following scenario when a TCP connection is established: Server must be prepared to accept connection usually done by calling socket, bind, and listen (this is called a passive open) Client issues an active open by calling connect. This causes the TCP client to send a synchronize segment (SYN) This tells the server the clients initial sequence number Normally contains no data, just and IP header, a TCP header, and possibly options The server must acknowledge (ACK) the client s SYN and the server must also send its own SYN (this is done in one segment) Contains the initial sequence number for the data that the server will send The Client must acknowledge the server s SYN 12

TCP Connection Establishment: Three Way Handshake - Ethereal 13

TCP Connection Termination 15

TCP Connection Termination Since a FIN and ACK are required in both directions, four segments are normally used Steps 2 and 3 may be combined Between steps 2 and 3 it is possible for data to flow from the end doing the passive close to the end doing the active close. This is called a halfclose The sending of each FIN occurs when a socket is closed 16

TCP Connection Termination - Ethereal 17

TCP State Transition Diagram 18

TCP State Transition Diagram (Continued) The operation of TCP with regard to connection establishment and connection termination can be specified with a state transition diagram Total of 11 different states Rules of TCP dictate the transitions from one state to another Example: An application performs an active open in the CLOSED state TCP sends a SYN and the new state is SYN_SENT. If TCP next receives a SYN with an ACK, it sends and ACK an the new state is ESTABLISHED. The two arrows leaving from the ESTABLISHED state deal with the termination of a connection If an application calls close before receiving a FIN (an active close), the transition is to the FIN_WAIT_1 state If an application receives a FIN while in the ESTABLISHED (a passive close), the transition is to the CLOSE_WAIT state 19

Watching The Packets 20

Watching The Packets Example: client announces am MSS of 536 and server announces MSS of 1460 it s okay for the MSS to be different in each direction A MSS of 1460 is common for IPv4 on Ethernet A connection is established and a request is sent to the server It is assumed that the request fits into a single TCP segment The server processes the request and sends a reply (again assuming that it fits in a single TCP segment) Notice that the acknowledgement of the request is sent with the server s reply this is called piggybacking Piggybacking normally takes place when the time it takes the server to process the request and generate the reply is less than 200ms Finally, the connection is closed with four segments notice that the client enters the TIME_WAIT state How would this diagram look if it were UDP? 21

TIME_WAIT State The duration that an endpoint remains in this state is twice the maximum segment lifetime (MSL), sometimes called 2MSL Every implementation of TCP must choose a value for the MSL Normally between 30 seconds and 2 minutes MSL is the maximum amount of time that any given IP datagram can live in a network This time is bounded because of the 8-bit hop limit in the IP header, the time-to-live (TTL) field A packet can get lost in the network as a result of routing anomalies: routers crashing If the packet gets lost, and is retransmitted due a timeout, and suddenly the packet is found and transmitted to the destination, the duplicate is called a lost duplicate or a wandering duplicate. TCP must handle these scenarios 22

TIME_WAIT State (Continued) Two reasons for the TIME_WAIT state: 1) To implement TCP s full-duplex connection termination reliably : To Illustrate this, let s assume that the final ACK was lost The server will resend the final FIN, so the client must maintain state information, allowing it to resend the final ACK If it did not maintain state, the client would respond with a reset, which would be interpreted by the server as an error In order to terminate both directions cleanly, TCP musts correctly handle the loss of any of the four connection termination sessions This example shows why the end that does the active close, is the end that goes into the TIME_WAIT state because it may have to retransmit the final ACK 23

TIME_WAIT State (Continued) Two reasons for the TIME_WAIT state: 2) To allow old duplicate segments to expire in the network To Illustrate this, let s assume we have a TCP connection between 12.106.32.245:1500 and 206.168.112.219:21. This connection is closed and some time later another connection is made using the exact same IP addresses and ports The later connection is called an incarnation of the previous connection TCP must prevent old duplicates from a connection from reappearing at some later time and being misinterpreted as belonging to a new incarnation of the same connection To do this TCP will not initiate a new incarnation of a connection if it is in the TIME_WAIT state This ensures that all duplicates from precious incarnations of the connection have expired in the network 24

Buffer Sizes and Limitations Certain limits affect the size of IP datagrams: The maximum size of an IPv4 datagram is 65,536 bytes due to its 16-but total length field Many networks have a maximum transmission unit (MTU) which can be dictated by hardware. For example, the Ethernet MTU is 1500 bytes. The minimum link MTU for IPv4 is 68 bytes. The smallest MTU in the path between two hosts is called the path MTU. Normally, the Ethernet MTU of 1500 bytes is the path MTU. When an IP datagram is to be sent out an interface, if the size of the datagram exceeds the link MTU, fragmentation is performed. Fragments are normally reassembled until they reach their final destination. If the don t fragment (DF) bit is set in the IPv4 header, it specifies that the data must not be fragmented. A router receives this packet and has a link with a smaller MTU sends an ICMP error back to sender. 31

Buffer Sizes and Limitations (Continued) TCP has a maximum segment size (MSS) that announced to the peer TCP the maximum amount of TCP data that the peer can send per segment The MSS is usually set to the interface MTU minus the fixed sizes of the IP ad TCP headers On Ethernet it s 1460 32

TCP Output Every TCP socket has a send buffer, and we can change the size of it using the SO_SNDBUF option When an application calls write, the kernel copies all the data to from the application buffer to the send buffer If there is insufficient room in the send buffer for all the application s data, the process is put to sleep 33

TCP Output (Continued) The kernel does not return from the write until every byte of the application data has been written into the send buffer TCP takes the data in the socket send buffer and sends it to the peer TCP. The peer TCP must acknowledge the data, and as the ACKs arrive from the peer, only then can our TCP discard the acknowledged data from the socket send buffer TCP sends the data in MSS-sized chunks or smaller, adding a TCP header to each segment 34

UDP Output With UDP the socket send buffer doesn t exist It has a socket send buffer size, but this is just an upper limit on the maximum-sized UDP datagram Since UDP is unreliable it does not need to keep a copy of the applications data in a buffer UDP packets are more likely to get fragmented than TCP 35

TCP Header Bit 0 4 10 15 31 ( 32 Bits) SOURCE PORT DESTINATION PORT 20 BYTES HEADER LENGTH UNUSED SEQUENCE NUMBER ACKNOWLEDGEMENT NUMBER U R G A C K FLAGS P S H R S T S Y N F I N WINDOW CHECKSUM URGENT POINTER OPTIONS + PADDING 38

TCP Header - Ethereal 39

TCP Header Details Source Port (16 bits) source TCP user Destination Port (16 bits) destination TCP user Sequence Number (32 bits) sequence number of the first data octet in this segment except when SYN flag is set. If SYN is set this field is the initial sequence number (ISN) Acknowledgement Number (32 bits) a piggybacked acknowledgement, contains the sequence number of the next data octet that the TCP entity expects to receive Header Length (4 bits) number of 32 bit words in the header Unused (6 bits) unused 40

TCP Header Details (Continued) Flags (6 bits) URG urgent pointer field significant. ACK - acknowledgement field significant. * PSH push function. RST reset the connection. SYN synchronize the sequence numbers. FIN - no more data from sender. Window (16 bits) flow control credit allocation contains the number of data octets beginning with the one indicated in the acknowledgement field that the receiver is willing to accept. Checksum (16 bits) an error detection calculated over header and data. Urgent Pointer (16 bits) points to the last BYTE in a sequence of urgent data. Options (variable) optional features. * Data Stream Push Note: Normally TCP decides when sufficient data has accumulated to form a segment for transmission. The user can require TCP to transmit all outstanding data up to and including that labeled with a push flag. 41

Figure 12.40 TCP Options TCP/IP Protocol Suite 90

TCP OPTIONS SINGLE BYTE: END OF OPTION 00000000 (Only one may be used and is only necessary if the very last byte of the last 32 bit word is not already the end of an option) NO OPERATION 00000001 (Used for Padding/aligning an option on a 16 bit or a 32 bit boundary) MULTIPLE BYTE: MAXIMUM SEGMENT SIZE: ID CODE LENGTH WINDOW SCALE FACTOR: 00000010 00000100 2 BYTE VALUE 00000011 00000011 1 BYTE VALUE TIMESTAMP (USED IN ROUND TRIP TIME CALCULATIONS): 42

Figure 12.41 End-of-option option TCP/IP Protocol Suite 91

TCP Options Each SYN can contain TCP options. Commonly used options include the following: MSS option TCP sending the SYN announces its maximum segment size. That is, the maximum amount of data that it is willing to accept in each TCP segment, on this connection. It s possible to set it using the TCP_MAXSEG socket option. Window Scale option The maximum TCP window size available is 65, 535, because of the corresponding field in the header occupies 16 bits. High-speed and high-delay links need a larger window size to maximize throughput. This options says that the window in the TCP header must be scaled. Up to 14 more bits can be used, scaling the window to about 1 GB Timestamp option - Used in high-speed connections to prevent possible data corruption caused by old, delayed, or duplicated segments. 14

Summary We discussed the transport layer in detail Specifics about the TCP s three-way handshake were covered Specifics about TCP s connection termination sequence were discussed We discussed the TCP s TIME_WAIT state We also covered the TCP and UDP buffering by the socket layer 43