TCP, UDP, ports, and sockets

Send a UDP datagram

Understand one UDP message, its ports and checksum, and the responsibilities left to the application.

8 minute lesson

~~~

A UDP datagram contains source and destination ports, a length, a checksum, and application data. One send produces one datagram, and a receive returns one complete datagram when the buffer is large enough.

UDP has no handshake. A sender can transmit without first proving that the destination application exists. An ICMP error may come back, or there may be no response at all.

DNS often uses UDP for ordinary queries. Real-time applications also use UDP when late data can be less useful than missing data. These applications define any needed retries, ordering, and rate control themselves.

“UDP is faster” is too simple. It offers fewer built-in services; whether that helps depends on the protocol designed above it and the network conditions.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →