User Datagram Protocol
Unlike TCP, the User Datagram Protocol (UDP) does not present data as a stream
of bytes, nor does it require that you establish a connection with another program
in order to exchange information. Data is exchanged in discrete units called
datagrams, which are similar to IP datagrams. In fact, the only features that
UDP offers over raw IP datagrams are port numbers and an optional checksum.
UDP is sometimes referred to as an unreliable protocol because when a program
sends a UDP datagram over the network, there is no way for it to know that it
actually arrived at it's destination. This means that the sender and receiver
must typically implement their own application protocol on top of UDP. Much
of the work that TCP does transparently (such as generating checksums, acknowledging
the receipt of packets, retransmitting lost packets and so on) must be performed
by the application itself.
With the limitations of UDP, you might wonder why it's used at all. UDP has
the advantage over TCP in two critical areas: speed and packet overhead. Because
TCP is a reliable protocol, it goes through great lengths to insure that data
arrives at it's destination intact, and as a result it exchanges a fairly high
number of packets over the network. UDP doesn't have this overhead, and is considerably
faster than TCP. In those situations where speed is paramount, or the number
of packets sent over the network must be kept to a minimum, UDP is the solution.