UDP

From bildr

Jump to: navigation, search

Contents

Overview

The UDP (User Datagram Protocol) is one of the core transport layer protocols of the Internet Protocol Suite, defined by RFC 768.

UDP can send datagrams (messages) to other hosts without requiring the various hand-shaking and setup methods used by many other transport protocols such as TCP. However, there is no guarantee messages will arrive, and likewise messages may be late or out of order. At the same time, UDP does not incur the overheads associated with the various hand-shaking methods. UDP is best suited for time-sensitive data where transfer speed is more important than data integrity. Also, due to forgoing the various error-checking protocols, UDP supports multicasting.


Technical Details

UDP is a minimalistic transport layer protocol, and offers no guarantee that a message will arrive, arrive on time, or arrive in order is exchange for speed. However, UDP does support checksums to verify data integrity and multiplexing over multiple ports.

Header

UDP heavers consist of 4, two-byte fields, two fo which are optional (Source Port Number and Checksum). This has been changed when using IPv6 where the checksum is not optional.

bits0-1516-31
0Source Port NumberDestination Port Number
32LengthChecksum
64Data


Source port number The Source Port Number identifies the sending port number. However, this field is optional, and does not necessarily contain the actual sending port, but is more often used to indicate the port a reply should be send to is desired.

Destination port number This field is required, and indentifies the reciever's port.

Length This field specifies the combined length of the entire datagram, including both the header and data. The minimum length is 8-bytes (the size of the header itself), with a maximum of 65535 bytes. However, IPv4 limits the size to 65,507 bytes.

Checksum The checksum is used to verify data integrity and considered optional except under IPv6. If no checksum is to be used, the checksum should consist of all zeros.

Checksum

As defined by RFC 768:


"Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header 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."

UDP uses different checksum methods for IPv4 and IPv6. These checksums are computed using "pseudo-headers" that contain some of the information from the IPv4/IPv6 headers.

IPv4

bits0 – 78 – 1516 – 2324 – 31
0Source address
32Destination address
64ZerosProtocolUDP length
96Source PortDestination Port
128LengthChecksum
160Data


IPv6

bits0 – 78 – 1516 – 2324 – 31
0Source address
32
64
96
128Destination address
160
192
224
256UDP length
288ZerosNext Header
320Source PortDestination Port
352LengthChecksum
384Data



Links

This page is an Article on bildr. Articles are pages that define or explain a concept, method, or generic item.

NOTE: All information contained within this article is pure opinion. Although this article is intended to help people, it may contain faulty or misleading information. This article is not to be considered professional opinion or advice, and is in no way a replacement for reading all safety/instructional documentation. Always remember to protect yourself when handling/using hazardous materials, as well as test new techniques before using them on projects/work intended to be handed in or used.

bildr and its contributers take NO responsibility for the information contained within.