The User Datagram Protocol

UDP provides a service for applications to exchange messages. Unlike TCP, UDP is connectionless and provides no reliability, no windowing, and no reordering of the received data. However, UDP provides some functions of TCP, such as data transfer, segmentation, and multiplexing using port numbers, and it does so with fewer bytes of overhead and with less processing required.

UDP multiplexes using port numbers in an identical fashion to TCP. The only difference in UDP (compared to TCP) sockets is that, instead of designating TCP as the transport protocol, the transport protocol is UDP. An application could open identical port numbers on the same host but use TCP in one case and UDP in the other—that is not typical, but it certainly is allowed. If a particular service supports both TCP and UDP transport, it uses the same value for the TCP and UDP port numbers, as shown in the assigned numbers RFC (currently RFC 1700—see www.isi.edu/in-notes/rfc1700.txt).

UDP data transfer differs from TCP data transfer in that no reordering or recovery is accomplished. Applications that use UDP are tolerant of the lost data, or they have some application mechanism to recover lost data. For example, DNS requests use UDP because the user will retry an operation if the DNS resolution fails. The Network File System (NFS), a remote file system application, performs recovery with application layer code, so UDP features are acceptable to NFS.

Table 6-6 contrasts typical transport layer functions as performed (or not performed) by UDP or TCP.

Table 6-6 TCP and UDP Functional Comparison

Function

Description (TCP)

Description (UDP)

Ordered data transfer

This involves a continuous stream of ordered data.

Does not reorder received data.

Multiplexing using ports

Receiving hosts decide the correct application for which the data is destined, based on the port number.

Same as TCP.

Reliable transfer

Acknowledgment of data uses the Sequence and Acknowledgment fields in the TCP header.

This is not a feature of UDP.

Flow control

This process is used to protect buffer space and routing devices.

This is not a feature of UDP.

Connections

This process is used to initialize port numbers and other TCP header fields.

UDP is connectionless.

Figure 6-10 shows TCP and UDP header formats. Note the existence of both Source Port and Destination Port fields in the TCP and UDP headers, but the absence of Sequence Number and Acknowledgment Number fields in the UDP header. UDP does not need these fields because it makes no attempt to number the data for acknowledgments or resequencing.

Figure 6-10 TCP and UDP Headers

Figure 6-10 TCP and UDP Headers

Source Port

Dest. Port

Sequence Number

Ack. Number

Offset

Reserved

Flags

Window Size

Checksum

Urgent

Options

PAD

TCP Header 2 2 2 2

Source

Dest.

Length

Checksum

Port

Port

UDP Header

* Unless Specified, Lengths Shown Are the Numbers of Bytes

UDP gains some advantages over TCP by not using the Sequence and Acknowledgment fields. The most obvious advantage of UDP over TCP is that there are fewer bytes of overhead. Not as obvious is the fact that UDP does not require waiting on acknowledgments or holding the data in memory until it is acknowledged. This means that UDP applications are not artificially slowed by the acknowledgment process, and memory is freed more quickly.

Was this article helpful?

0 0

Post a comment