You are here:About>Computing & Technology>Wireless / Networking
About.comWireless / Networking

UDP - User Datagram Protocol - UDP and IP Tutorial

The User Datagram Protocol (UDP) supports network applications that need to transport data between computers. Applications that use UDP include client/server programs like video conferencing systems. Although UDP has been in use for many years -- and overshadowed by more glamorous alternatives -- it remains an interesting and viable technology.

UDP -- like its cousin the Transmission Control Protocol (TCP) -- sits directly on top of the base Internet Protocol (IP). Recalling the Open Systems Interconnection (OSI) model of networking, UDP (and TCP) are transport layer protocols as shown below.

The transport layer in the OSI reference model
UDP in the OSI Reference Model

In general, UDP implements a fairly "lightweight" layer above the Internet Protocol. UDP's main purpose is to abstract network traffic in the form of datagrams. A datagram comprises one single "unit" of binary data; the first eight (8) bytes of a datagram contain the header information and the remaining bytes contain the data itself.

UDP Headers

The UDP header consists of four (4) fields of two bytes each:

  • source port number
  • destination port number
  • datagram size
  • checksum

UDP port numbers allow different applications to maintain their own "channels" for data; both UDP and TCP use this mechanism to support multiple applications sending and receiving data concurrently. The sending application (that could be a client or a server) sends UDP datagrams through the source port, and the recipient of the packet accepts this datagram through the destination port. Some applications use static port numbers that are reserved for or registered to the application. Other applications use dynamic (unregistered) port numbers. Because the UDP port headers are two bytes long, valid port numbers range from 0 to 65535; by convention, values above 49151 represent dynamic ports.

The UDP datagram size is a simple count of the number of bytes contained in the header and data sections . Because the header length is a fixed size, this field essentially refers to the length of the variable-sized data portion (sometimes called the payload). The maximum size of a datagram varies depending on the operating environment. With a two-byte size field, the theoretical maximum size is 65535 bytes. However, some implementations of UDP restrict the datagram to a smaller number -- sometimes as low as 8192 bytes.

UDP checksums work as a safety feature. The checksum value represents an encoding of the datagram data that is calculated first by the sender and later by the receiver. Should an individual datagram be tampered with (due to a hacker) or get corrupted during transmission (due to line noise, for example), the calculations of the sender and receiver will not match, and the UDP protocol will detect this error. The algorithm is not fool-proof, but it is effective in many cases. In UDP, checksumming is optional -- turning it off squeezes a little extra performance from the system -- as opposed to TCP where checksums are mandatory.

Next page > IP Tutorial: User Datagram Protocol > Page 1, 2

Subscribe to the Newsletter
Name
Email

From Bradley Mitchell,
Your Guide to Wireless / Networking.
FREE Newsletter. Sign Up Now!
Newsletters & RSSEmail to a friendSubmit to Digg
 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.