Chapter 54. User Datagram Protocol (UDP)

The User Datagram Protocol (UDP) is a connectionless host. UDP hosts service that operates at the Transport layer of the OSI model. UDP relies on the upper layer protocol for both error correction and reliable service. The protocol is transaction oriented and delivery and duplicate protection are not guaranteed. The major uses of this protocol are DNS and TFTP.

UDP has a small header and for all intents and purposes it adds Port addressing to the IP header. The IP header routes datagrams to the correct host on the network. UDP routes the datagram to the correct application.

UDP Header

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1516 17 18 19 20 21 22 2324 25 26 27 28 29 30 31
Source Port (16 bits)Destination Port (16 bits)  
Length (16 bits)Checksum (16 bits)  
Data   

Source Port

The Source Port is a 16 bit number that Indicates the upper level service (that the source is transmitting). Appendix I is a complete listing of well-known ports. UDP allows port numbers to be in the range from 0 to 65,535. The Source Port is optional, and if not used, a field of 0s is inserted.Clients will have a unique port number assigned to them by the server. Typically, the number will be above 8,000.

Destination Port

The Destination Port is a 16 bit number: it indicates the upper level service that the source wishes to communicate with at the destination.

Length

The Length field is 16 bits long, indicates the length of the UDP datagram, and has a maximum value of 65, 535 bytes (and a minimum value of 8 bytes).

Checksum

The Checksum field is 16 bits long: it calculates a checksum that is based on the UDP header, the Data field, and what is called the UDP Pseudo header. The UDP Pseudo header consists of the Source IP Address, Destination IP Address, Zero, IP Protocol field and UDP Length. For UDP, the IP Protocol field value is 17.

Data

The data field contains the IP header and data. The Data field may be padded with zero octets at the end (if necessary) to make a multiple of two octets.

If this section was helpful, why not donate to further development?

Donate $1.25.

Donate $2.50.

Donate $5.00.