UDP (User Datagram Protocol)
What is UDP?
UDP (User Datagram Protocol) is an alternative communications protocol to Transmission Control Protocol (TCP) used primarily for establishing low-latency and loss-tolerating connections between applications on the internet.
It uses a simple connectionless communication model with a minimum of protocol mechanism. UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram.
It is widely used for fire-and-forget protocols where packets are sent but their arrival or ordering is not guaranteed.
How UDP is different from TCP?
Both UDP and TCP run on top of the Internet Protocol (IP) and are sometimes referred to as UDP/IP or TCP/IP. But there are important differences between the two.
- Where UDP enables
process-to-process
communication, TCP supportshost-to-host
communication. TCP sends individual packets and is considered a reliable transport medium; UDP sends messages, called datagrams, and is considered a best-effort mode of communications. - In addition, where TCP provides error and flow control, no such mechanisms are supported in UDP. UDP is considered a connectionless protocol because it doesn't require a virtual circuit to be established before any data transfer occurs.
Advantages of using UDP over TCP?
UDP just sends the packets, which means that it has much lower bandwidth overhead and latency. However with UDP, packets may take different paths between sender and receiver and, as a result, some packets may be lost or received out of order.