flâneur

The Internet: The UDP protocol

thevalleyofcode.com · 435 words · saved by 1 readers

This implies that it’s faster, each packet sent is more lightweight, as it does not contain all the information needed in TCP, and it does have a lighter handshake process. The drawback is that UDP is not as reliable as TCP. In TCP, if a packet gets lost, the protocol is able to handle it and the packet is re-sent. In UDP, this is not built-in into the protocol, and must be handled at a higher level (built on top of it). There is no built-in check to control if a packet was received, and if it is received correctly. UDP was defined in RFC 768 in 1980. Some of the most notable application protocols that rely on the UDP layer are DNS and DHCP, and more importantly is the base layer of HTTP/3, the next version of HTTP. The UDP protocol uses ports to allow communication between processes, like with TCP.

TCP gives applications a reliable, ordered byte stream between two endpoints. It detects loss, retransmits data, puts bytes back in order, and controls how quickly data is sent. You write bytes in, the other side reads the same bytes out, and TCP handles everything that can go wrong in between. UDP sends independent datagrams. It preserves message boundaries. One send is one message. But it does not itself guarantee delivery, ordering, duplicate removal, or congestion response. What you get is an address, a port, and a fire-and-forget message. Feel the difference with nc You can…

related reading