UDP Notes

Chapter 3 Roadmap

  • Transport-layer services
  • Multiplexing and demultiplexing
  • Connectionless transport: UDP
  • Principles of reliable data transfer
  • Connection-oriented transport: TCP
  • Principles of congestion control
  • TCP congestion control
  • Evolution of transport-layer functionality

UDP: User Datagram Protocol

  • "No frills," "bare bones" Internet transport protocol.
  • "Best effort" service; UDP segments may be:
    • Lost.
    • Delivered out of order to the application.
  • No connection establishment (which can add RTT delay).
  • Simple: no connection state at sender, receiver.
  • Small header size.
  • No congestion control.
  • UDP can blast away as fast as desired.
  • Can function in the face of congestion.

Why is there a UDP?

  • Connectionless:
    • No handshaking between UDP sender and receiver.
    • Each UDP segment is handled independently of others.

UDP Use Cases

  • Streaming multimedia applications (loss tolerant, rate sensitive).
  • DNS.
  • SNMP.
  • HTTP/3
  • If reliable transfer is needed over UDP (e.g., HTTP/3):
    • Add needed reliability at the application layer.
    • Add congestion control at the application layer.

UDP: RFC 768

Key Points from RFC 768:

  • UDP provides a datagram mode of packet-switched computer communication.
  • It assumes that the Internet Protocol (IP) is used as the underlying protocol.
  • It 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 Header Format

The UDP header format is as follows:

  • Source Port (16 bits)
  • Destination Port (16 bits)
  • Length (16 bits)
  • Checksum (16 bits)
  • Data octets (variable length)

UDP: Transport Layer Actions

UDP sender actions:

  • An application-layer message is passed.
  • Determines UDP segment header fields values.
  • Creates UDP segment, including UDP header (UDPh) and SNMP (Simple Network Management Protocol) message.
  • Passes segment to IP.

UDP receiver actions:

  • Receives segment from IP.
  • Checks UDP checksum header value.
  • Extracts application-layer message.
  • Demultiplexes message up to application via socket.

UDP Segment Format

The UDP segment format consists of the UDP header and application data (payload):

  • Source port # (16 bits)
  • Destination port # (16 bits)
  • Length (16 bits): length, in bytes of UDP segment, including header
  • Checksum (16 bits)
  • Application data (payload): data to/from application layer

UDP Checksum

  • Goal: detect errors (i.e., flipped bits) in transmitted segment
  • The checksum is calculated by the sender and included in the UDP header. The receiver recalculates the checksum and compares it to the received checksum. If they don't match, an error is detected.

UDP Checksum - Sender

  • Treat contents of UDP segment (including UDP header fields and IP addresses) as sequence of 16-bit integers.
  • Checksum: addition (one’s complement sum) of segment content.
  • Checksum value is put into UDP checksum field.

UDP Checksum - Receiver

  • Compute checksum of received segment
  • Check if computed checksum equals checksum field value:
    • Not equal - error detected
    • Equal - no error detected. But maybe errors nonetheless?

UDP Checksum Example

  • Add two 16-bit integers:
    11100110011001101110011001100110
    11010101010101011101010101010101
  • Sum:
    11101110111011001110111011101100
  • Checksum:
    00100010001000110010001000100011

Note

  • When adding numbers, a carryout from the most significant bit needs to be added to the result (wraparound).

Internet Checksum: Weak Protection

  • The Internet checksum provides weak protection against bit flips. It is possible for bit flips to occur such that the checksum remains unchanged, leading to undetected errors.
  • Example: Even though numbers have changed (bit flips), no change in checksum!

Summary: UDP

  • "No frills" protocol:
    • Segments may be lost, delivered out of order
    • Best effort service: "send and hope for the best"
  • UDP has its plusses:
    • No setup/handshaking needed (no RTT incurred)
    • Can function when network service is compromised
    • Helps with reliability (checksum)
  • Build additional functionality on top of UDP in application layer (e.g., HTTP/3)