User Datagram Protocol
Introduction
The User Datagram Protocol (UDP) is one of the core members of the Internet protocol suite. With IP, and ICMP, it forms the basis of internet communications by enabling networked devices to send short messages, known as datagrams.
Overview
UDP uses a simple transmission model without implicit hand-shaking dialogues for providing reliability, ordering, or data integrity. Thus, UDP provides an unreliable service and datagrams may arrive out of order, appear duplicated, or go missing without notice. UDP assumes that error checking and correction is either not necessary or performed in the application, avoiding the overhead of such processing at the network interface level.
Technical Details
UDP is a minimal message-oriented transport layer protocol that is currently documented in IETF RFC 768.
In the Internet protocol suite, UDP provides a very simple interface between a network layer below (usually IP) and an application layer above. UDP provides no guarantees to the upper layer protocol for message delivery and the UDP layer retains no state of UDP messages once sent. For this reason, UDP sometimes is referred to as Unreliable Datagram Protocol.
UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients. Unlike TCP, UDP is suitable for purposes where error checking and correction are either not necessary or are performed in the application; UDP avoids the overhead of such processing in the protocol stack. Time-sensitive applications often use UDP because dropping packets is preferable to waiting for packets delayed due to retransmission, which may not be an option in a real-time system.
Header Structure
The UDP header consists of four fields of two bytes each:
1. Source port number, which is the number of the sender. 2. Destination port number, the port the datagram is addressed to. 3. Length, the length in bytes of the UDP header and the encapsulated data. The minimum length is 8 bytes, the maximum is 65,535. 4. Checksum, optional error checking for the header and data. If not used, it should be zero.
Usage
UDP is suitable for purposes where error checking and correction are either not necessary or are performed in the application; UDP avoids the overhead of such processing in the protocol stack. Time-sensitive applications often use UDP because dropping packets is preferable to waiting for packets delayed due to retransmission, which may not be an option in a real-time system.