Protocols & models · Offline reference

TCP vs UDP Comparison

Compare delivery semantics, message boundaries, headers and application responsibilities. Elapsed time depends on loss, congestion handling, packet size, handshakes and application behavior. Omitting TCP's mechanisms means another layer must supply any reliability the task needs.

Inputs

Result

Selection
All entries
Calculated or matching entries
PropertyTCPUDP
Application deliveryOrdered stream of bytes while the connection succeedsOne message per delivered datagram
Loss or reorderingSequence tracking, retransmission and reassemblyApplications can observe gaps, duplication or reordering
Message boundariesApplication framing is neededDatagram boundaries are preserved
Flow and congestion controlBuilt into TCP behaviorApplication or a protocol above UDP must provide suitable behavior
Base header20 bytes before options8 bytes
Timing trade-offMissing bytes can delay delivery of subsequent bytesA later datagram can be delivered independently
ExampleHTTP/1.1 can use TCPQUIC carries streams and reliability above UDP
In this guide11 sections

Introduction

Compare delivery semantics, message boundaries, headers and application responsibilities. Elapsed time depends on loss, congestion handling, packet size, handshakes and application behavior. Omitting TCP's mechanisms means another layer must supply any reliability the task needs.

Method and concepts

UDP adds source and destination ports, a length and a checksum to a message. It requires no transport handshake. Each delivered datagram retains its boundary. An application with a receive buffer too small for a message can encounter truncation according to its socket interface.

  1. Select an entry to isolate the relevant case.
  2. Read the associated evidence and compare it with your local configuration.

UDP diagram

  1. Telemetry sample · 120 B
  2. UDP datagram · 128 B
  3. IPv6 packet · 168 B
  4. Receiver reads one sample
A base IPv6 header adds 40 bytes outside the eight-byte UDP header. This example has no IPv6 extension headers.

Worked examples

Read the Application delivery entry

  1. Ordered stream of bytes while the connection succeeds
  2. One message per delivered datagram

UDP: Size a sample and interpret its arrival

  1. Encode 120 bytes of sample data, including an application sequence counter. The UDP length is 8 + 120 = 128 bytes.
  2. Add 40 IPv6 bytes. The IP packet is 168 bytes, well within a 1280-byte path budget under these assumptions.
  3. At the collector, samples 41 and 43 arrive before 42. Their application counters reveal the reordering. UDP assigns no delivery deadline or recovery policy.

Reference table

TCP vs UDP Comparison reference
PropertyTCPUDP
Application deliveryOrdered stream of bytes while the connection succeedsOne message per delivered datagram
Loss or reorderingSequence tracking, retransmission and reassemblyApplications can observe gaps, duplication or reordering
Message boundariesApplication framing is neededDatagram boundaries are preserved
Flow and congestion controlBuilt into TCP behaviorApplication or a protocol above UDP must provide suitable behavior
Base header20 bytes before options8 bytes
Timing trade-offMissing bytes can delay delivery of subsequent bytesA later datagram can be delivered independently
ExampleHTTP/1.1 can use TCPQUIC carries streams and reliability above UDP

Reading the result

An application’s configured maximum message size should account for every header within the path MTU. Losing one IP fragment prevents successful reassembly of the complete datagram. A smaller supported message size can avoid fragmentation.

Common mistakes

  • Subtracting just eight bytes from an IP MTU while forgetting the IP header.
  • Treating the absence of a transport handshake as evidence that the remote application is ready.

Frequently asked questions

Will UDP always finish a transfer sooner?

Elapsed time depends on loss, congestion handling, packet size, handshakes and application behavior. Omitting TCP's mechanisms means another layer must supply any reliability the task needs.

Can UDP carry a zero-byte message?

Yes. An ordinary UDP datagram with no application data has a length of eight bytes.

Is UDP always faster than TCP?

The workloads have different requirements. If the application needs retries and ordering, those mechanisms still consume time and capacity wherever they are implemented.

Does UDP guarantee delivery or ordering?

No. UDP sends datagrams without TCP's connection setup, retransmission, or ordered byte-stream guarantees. An application can add its own reliability if needed.

Why might an application use UDP?

It may need datagram boundaries, low setup overhead, multicast behavior, or custom loss handling. The application must decide whether and how to recover missing data.

Does a UDP checksum always exist in IPv4 and IPv6?

IPv6 requires a UDP checksum except for narrowly specified tunnel cases; IPv4 permits a zero checksum for UDP. Receivers and application requirements still matter.

Can UDP use a familiar service port?

Yes. Port numbers are interpreted together with transport protocol. TCP port 53 and UDP port 53 are distinct endpoints even though both are associated with DNS use.

Does UDP preserve one send as one receive?

UDP preserves datagram boundaries when a datagram is delivered, but delivery is not guaranteed. The application must handle missing, duplicated, late, or reordered datagrams as needed.

Is QUIC carried over UDP?

Yes. QUIC uses UDP datagrams as its substrate while implementing transport features and TLS-based security above UDP. That does not make plain UDP itself reliable or encrypted.

Should every UDP application ignore congestion?

No. Applications sending sustained traffic still need appropriate congestion behavior and rate control. UDP's minimal transport service does not remove that responsibility.

Can a UDP datagram be fragmented?

An IP packet carrying UDP can encounter fragmentation or path-MTU constraints. Applications that send large datagrams should consider the path size and loss cost of fragmentation.

What does the UDP length field include?

It counts the UDP header and UDP payload. The UDP header is eight bytes, and the enclosing IP packet has its own length accounting.

Why can a large UDP datagram be risky?

It can exceed the path MTU and be fragmented or dropped. Losing one IP fragment can make the whole UDP datagram unusable, so applications often keep datagrams small.

Why might DNS switch from UDP to TCP?

A resolver can retry over TCP when a UDP response is truncated or when TCP is otherwise required. Firewall rules that permit only UDP can therefore break some DNS operations.

Does UDP checksum detect every possible corruption?

It detects many transmission errors but is not cryptographic authentication and can have a finite undetected error probability. Secure applications need appropriate cryptographic integrity protection.

Does QUIC make UDP delivery reliable?

QUIC implements its own transport reliability, congestion behavior, and encryption above UDP. Those features belong to QUIC, not to the UDP service itself.

Further learning and references