Overview of the UDP protocol

This post gives a brief overview of the UDP protocol, including the properties of UDP, its theory of operation and the structure of UDP headers, pseudo headers and UDP encapsulations.

UDP is a  popular transport layer protocol used primarily when applications require just the application mulltiplexing and demultiplexing features of the transport layer, without requiring powerful features like reliability, flow control and congestion control.

UDP Properties:

  • Is a light-weight connection-less protocol that runs on top of IP
  • Provides an end-to-end, process to process communication mechanism for peer applications to communicate
  • Provides basic application layer process multiplexing and de-multiplexing services through UDP source port and destination port number fields, as shown in the diagram below
Application Process De-Multiplexing by UDP
Application Process De-Multiplexing by UDP
  • Supports a checksum feature for error detection purposes but this feature can optionally be disabled.
  • Does not have the concept of peer acknowledgment and hence unreliable
  • Does not support flow control and congestion control. Applications using UDP have to take care of flow/congestion control
  • Is best suited for applications that require fast data transfer but can tolerate slight loss of data
  • Is the preferred transport layer protocol for IP multicasting and real-time audio, video, multimedia applications, where fast delivery is more important than reliability
  • Is also used by simple client-server based application layer protocols where a quick response is required from a server, for a client request, without the overhead of connection establishment procedures (E.g. DNS, SNMP etc.)
  • Popular application layer protocols like SNMP, DNS, TFTP, RTP use UDP as the transport protocol

Basic Theory of Operation of UDP

UDP is just a simple extension to IP datagram service, where it provides application multiplexing and checksum computation of application data on the sending end and application  de-multiplexing and checksum verification on the receiving end.  It is a connection-less service, with no support for reliability, flow control and network congestion control.

UDP Encapsulation and Decapsulation

UDP Encapsulation and Decapsulations done at end computers
UDP Encapsulation and Decapsulations done at end computers

To achieve this, at the sending computer end, the UDP stack  encapsulates each piece of application data with a UDP header consisting of source and destination port numbers, apart from adding a checksum.

The UDP receiving process at the peer receiving end does the reverse operations. It first verifies the checksum to make sure that the UDP datagram came through the network uncorrupted and then uses the destination port number field to de-multiplex and hand over the application data to the appropriate application layer process.

UDP does not segment the incoming application data into streams of bytes. Hence, it is the responsibility of the application to segment the data as message blocks before handing it over to UDP layer.

Also the UDP layer at the receiving end drops erroneous UDP datagrams detected through checksum verification and it also drops UDP datagrams if there is no additional UDP buffers for storing it. In such cases, it does not inform the sender of dropped frames. Also there is no concept of UDP datagram numbering or acknowledgement. It is up to the application layer to take care of all these problems.

 

UDP Header and UDP Pseudo Header

The UDP header is a simple one consisting of just 8 bytes and includes only 4 fields. They are the source port number, destination port number, a length field specifying the length of the whole UDP datagram including the UDP Header and a Checksum field for error detection purposes, as given in the diagram below:

UDP Header
UDP Datagram (8 byte UDP Header + Application Data)

UDP Pseudo Header

UDP uses the whole UDP datagram and some fields from the IP header (termed as pseudo header) for computing the checksum, as shown in the diagram given below.

The UDP pseudo header
The UDP pseudo header

The reason for including the pseudo header is to verify that the UDP datagram is delivered to the right destination computer, as sometimes the IP header may get corrupted and the UDP datagram may arrive intact at the wrong destination.  The fields of the Pseudo header include the source and destination IP address of the IP packet that carries the UDP datagram, the IP protocol type field (UDP with a value of 0x11) and the total length of the UDP datagram.

Different types of node to node communications used in Computer Networks

This post gives an overview of the different types of node to node communication used in Computer Networking. Specifically it describes Unicasting, Multicasting, Broadcasting and Anycasting.

Basically, there are four types of node to node communication used in Computer Networking. They are Unicasting, Multicasting, Broadcasting and Anycasting.

Unicasting :

When a source node sends a packet or frame destined to exactly one machine node, then it is termed as Unicast communication. This is basically point to point communication. Unicasting can be done at the physical layer (point to point links) or at the data link layer or at the network layer. Most of the standard application layer protocols are from a source node to a single destination node. Examples include HTTP, FTP, SMTP etc.

Multicasting:

When a source node sends a packet or frame to a group address, destined only to a set of nodes that are part of a specific group, then it is termed as multicast communication. The group is termed as a multicast group. Multicasting is a form of point to multi-point communication, where communication is from a source node to multiple end nodes, but not to all end nodes of a network. It is communication from a source node confined to all the members of a specific group. Multicasting can be done at both data link and network layers. Multicasting is used for real-time applications like Voice over IP, audio/video conferencing, video or audio broadcasting to specific groups, Video On Demand (VOD) etc.

Broadcasting:

When a source node sends a packet or frame destined to all  nodes in a network, then it is termed as broadcast communication. Broadcasting is point to multi-point communication. Due to the increased amount of network traffic created by broadcasting, it is normally used only within a network, when it is essential to address all nodes of a network. Broadcasting can be done at the physical (bus lines),  data link and network layers. Examples of broadcasting include routing protocol update packets, DHCP address negotiation packets, Layer 2 flooded frames, spanning tree protocol frames etc.

 

Anycasting :

When a source node sends a packet or frame to a special destination IP address known as Anycast IP address,  then it is termed as Anycast communication. Anycasting has been introduced only in IPV6 and is not present in IPV4. It is a form of point to point communication, where a source node tries to reach any one instance of a server machine. Normally, for load balancing and redundancy purposes, there could be multiple instances of the same server machine, running at different points in the network (e.g. HTTP or DHCP or DNS servers). In such cases, all instances of the server machine are given the same Anycast IP address. Source nodes trying to contact the server would send IP packets to the common Anycast IP address. The network would then route the IP packet to that instance of the server machine that is closest to the source node. Anycasting is normally used only at the network layer, that too only if IPV6 is the network layer protocol under use.