UDP

UDP (RFC 768) adds very little on top of IP:

UDP is said to be connectionless, meaning there is no handshake before data is sent.

Some applications are better suited for UDP for the following reasons:

Feature Details

Application-level control

  • Applications decide exactly how data is sent and handled
  • Useful for real-time systems (e.g., video, gaming)
  • UDP immediately passes segments to the network layer, without extra transport-layer processing
  • By contrast, TCP:
    • has a congestion-control mechanism
    • retransmits lost data until it is acknowledged

No connection establishment

  • UDP sends data without a handshake
  • this avoids startup delay
  • useful when low latency matters more than reliability

No connection state

  • UDP does not store connection information in the end systems
  • TCP, on the other hand, tracks things like:
    • send and receive buffers
    • congestion-control parameters
    • sequence and acknowledgment numbers

Small packet header overhead

  • UDP header: 8 bytes
  • TCP header: at least 20 bytes per segment

UDP itself is not reliable, but applications can build reliability on top of it:

UDP header

User Datagram Protocol (UDP)
Offsets
(starting positions)
Octet/Byte 0 1 2 3
Octet/Byte Bit 0-7 8-15 16-23 24-31
0 0 Source Port Destination Port
4 32 Length Checksum

The UDP header has 4 fields:

UDP checksum

The checksum checks whether the UDP segment was corrupted during transmission.

  1. UDP at the sender:

    • performs the sum of all the 16-bit words in the segment
    • if the sum is too large for 16 bits, the extra bits are added back into the result (wraparound carry)
    • performs the 1s complement of the result:
      • all the 0s to 1s
      • all the 1s to 0s
    • puts the result in the checksum field of the segment
  2. UDP at the receiver:

    • compute the one's complement sum of all 16-bit words, including the checksum
    • if no errors occurred, the sum will be 1111111111111111
    • example (simplified 8-bit illustration):

      data sum                   01010101
      checksum (bitwise NOT)   + 10101010
                               ----------
                                 11111111
      
    • if one of the bits is a 0, an error is detected

Why does UDP provide a checksum?

UDP includes a checksum because:

  1. lower link-layer protocols (e.g., Ethernet) may not provide error checking
  2. errors can be introduced when a segment is stored in a router's memory

Therefore, UDP provides end-to-end error detection at the transport-layer.

What UDP does when errors are found?

UDP only detects errors and does not correct them:

Previous Multiplexing and demultiplexing All ⏎ Next Reliable data transfer

A Kemar Joint