# UDP

![](https://3928478158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhjMjdRXwO33Lfo7uCpl6%2Fuploads%2Fgit-blob-ef9e21eb943e60ff1eb1af97dadde2e5982e9bf3%2Fudp.png?alt=media)

This ***User Datagram Protocol (UDP)*** is defined to make available a datagram mode of packet-switched computer communication in the environment of an interconnected set of computer networks.

This protocol provides a procedure for application programs to send messages to other programs with a minimum of protocol mechanism.

The protocol is transaction oriented, and delivery and duplicate protection are not guaranteed. Applications requiring ordered reliable delivery of streams of data should use the ***Transmission Control Protocol (TCP)***.

## UDP packet

![](https://3928478158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhjMjdRXwO33Lfo7uCpl6%2Fuploads%2Fgit-blob-d157b89700f5354ba7720ff1f733f17e1de4a1c1%2Fudp-packet.png?alt=media)

* ***Source Port*** (16 bits) The source port number
* ***Destination Port*** (16 bits) The destination port number
* ***Length*** (16 bits) The length in octets of this user datagram including this header and the data
* ***Checksum*** (16 bits) The checksum of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.

  The pseudo header, conceptually prefixed to the UDP header, contains the source address, the destination address, the protocol, and the UDP length. This information gives protection against misrouted data- grams. This checksum procedure is the same as is used in TCP.

  If the computed checksum is zero, it is transmitted as all ones (the equivalent in one's complement arith- metic). An all zero transmitted checksum value means that the transmitter generated no checksum (for debugging or for higher level protocols that don't care).

![Pseudo header](https://3928478158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhjMjdRXwO33Lfo7uCpl6%2Fuploads%2Fgit-blob-36de6801374f19bb243d86ea76fa82ea52e76b56%2Fudp-pseudo-header.png?alt=media)
