UDP only puts a small header with four fields in front of the payload: source port, destination port, length and checksum. There is no connection, no acknowledgement and no retransmission. If a datagram is lost, only the program notices.
TCP
UDP
Connection
handshake, teardown
none
Reliable
acknowledgement, retransmission
no
Order
guaranteed
not guaranteed
Header
at least 20 bytes
8 bytes
Use
web, mail, SSH
DNS, DHCP, RIP, VXLAN, voice and video
The UDP header
Only 8 bytes: source port, destination port, length and checksum.
UDPDatagram · RFC 768
0481216202428
Source port16 bits521
Destination port16 bits521
Length16 bits32
Checksum16 bits0xfafd
Datavariable24 Byte
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
Field
Length
Example value
Meaning
Source port
16 bits (2 bytes)
521
Port of the sending program (may be 0 if no reply is expected).
Destination port
16 bits (2 bytes)
521
Port of the service: 53 DNS, 67/68 DHCP, 520 RIP, 521 RIPng, 4789 VXLAN.
Length
16 bits (2 bytes)
32
Header and data in bytes, at least 8.
Checksum
16 bits (2 bytes)
0xfafd
Checksum with pseudo header; may be 0 (none) with IPv4, mandatory with IPv6.
Data
variable
24 Byte
The application message, e.g. a DNS query.
Values: Real frame from the demo “RIPng for IPv6” (no. 1, 90 bytes), exactly as the packet list in leyoNET shows it.
When UDP fits
For a short question with a short answer, a handshake would cost more than the message itself: DNS simply asks again if no answer comes. DHCP even works before the device has an address. For voice and video a late packet is worthless anyway.
Port
Service
53
DNS
67 / 68
DHCP (server / client)
520
RIP
4789
VXLAN
See an example
DNS with forwarding
School DNS with the zone schule.example (A, CNAME, MX, TXT, NS, PTR) that forwards unknown names to the provider's DNS.
PC 1 resolves an alias through two CNAMEs, looks up the mail server (MX) and opens a page at the provider: the school DNS forwards the question and answers “non-authoritative”.
TCPReliable connections between programs: ports, three-way handshake, sequence and acknowledgement numbers, retransmission and teardown.
DNSTranslating names into addresses: zones, records (A, AAAA, CNAME, MX, PTR …), forwarding, cache and nslookup.
DHCPHanding out addresses automatically: discover, offer, request, ack, lease time, fixed assignments and DHCP relay across routers.
Structure of frames and packetsHow Ethernet frames, IPv4 and IPv6 packets, TCP segments and UDP datagrams nest inside each other, field by field according to the standards, with real bytes from leyoNET.