Skip to content

Cyber Security / Networking

UDP, TLS, And The Two Generals Paradox

UDP, TLS, And The Two Generals Paradox GENERAL A GENERAL B .-------. .-------. | A |--- PLAN ------>| B | '---+---' '---+---' | | |<------ ACK -----------| | | |--- ACK OF ACK --X | | ? | | | PROTECTED != GUARANTEED DELIVERY

Secure communication is not guaranteed coordination: transport, encryption, and the uncertainty behind a missing acknowledgment.

UDP and TLS answer different questions

“UDP versus TLS” sounds like a choice between two ways of sending data. The comparison actually crosses layers. UDP sends individual datagrams. TLS authenticates peers and protects communication against eavesdropping and tampering. One concerns transport behavior; the other concerns the trust and protection of a connection.

UDP does not guarantee delivery, ordering, or duplicate suppression. It does not encrypt application data or authenticate its sender. Its minimal transport machinery can be useful when fresh information matters more than a delayed retransmission, but congestion control and any required reliability must be supplied elsewhere. A UDP checksum is not cryptographic authentication. 1 2

Conventional TLS 1.3 expects a reliable, in-order byte stream, commonly supplied by TCP. TLS protects that stream; TCP performs transport acknowledgments, ordering, and retransmission. Correct certificate and hostname verification are essential to authenticating the intended server. Client authentication is optional in many deployments, and TLS does not itself decide which application records a client may access. 3

Secure communication can still use UDP

DTLS adapts TLS-style security to datagram communication. It handles handshake loss and reordering while preserving application datagram semantics. Securing a datagram does not turn it into a guaranteed-delivery application message. Its ordering and replay properties differ from stream TLS, so an application still needs to consider duplicate or stale actions. 4

QUIC runs over UDP but supplies its own transport mechanisms, including reliable streams and congestion control, and integrates the TLS 1.3 handshake for security. HTTP/3 uses QUIC. “UDP is insecure and TLS is reliable” is therefore misleading: security and reliability come from the complete protocol stack. 5 6

StackDelivery behaviorSecurity boundary
Bare UDPLoss, reordering, and duplicates are possibleNo built-in confidentiality or peer authentication
TLS over TCPReliable, ordered bytes while the connection remains viableAuthenticated, encrypted channel with correct peer verification
DTLS over UDPApplication datagrams retain unreliable delivery semanticsDatagram protection with DTLS-specific replay and ordering considerations
QUIC over UDPReliable streams; other delivery modes have separate specificationsIntegrated TLS handshake and QUIC packet protection

None guarantees that the receiving application saved a record or completed a business operation.

The Two Generals paradox

Two generals are separated by hostile territory. They succeed only if both attack together. A messenger can carry the proposed time, but may be captured. The first general wants an acknowledgment. The second sends one, then wants confirmation that the acknowledgment arrived. The first sends that confirmation, which may also be lost.

Every additional message moves uncertainty one step further. Under the classic assumptions—communication may fail unpredictably, and both parties require certainty of coordinated action—no finite exchange establishes the necessary common knowledge. Remove the last message from an allegedly successful finite protocol: its sender cannot distinguish delivery from loss, leaving the receiver's certainty unresolved. The problem is not weak encryption or one missing acknowledgment; it is the unreliable channel. 7

This differs from the Byzantine Generals problem, which considers agreement when participants can behave maliciously or inconsistently. Two Generals concerns uncertainty about delivery even when both participants are honest.

Why TLS does not resolve the paradox

Encryption prevents an observer from reading protected content; authentication helps establish who sent it. Neither forces a packet through a failed network or proves a remote process acted on its contents. TCP retransmission reduces ordinary loss, but a connection can still break. A timeout means a response was not observed in time—not that the request definitely failed.

A transport acknowledgment and an application receipt are different evidence. A successful socket write does not prove a database commit. Even an application acknowledgment can be lost after a successful commit, leaving the sender uncertain. Another acknowledgment does not eliminate the final uncertainty from a finite exchange.

Make uncertainty manageable

Consider a contact form. The server saves a message, but its response never reaches the browser. Blindly resubmitting may create duplicates; showing success before a confirmed save may claim work that never happened. A practical design makes the request identifiable and its result discoverable.

  • Give retries the same operation identifier. Recognize a repeated request rather than treating it as new work.
  • Commit before acknowledging. Return success after the required durable operation completes.
  • Provide an authorized status lookup. Let a reconnecting client check that operation without exposing someone else's records.
  • Bound retries and explain unresolved states. Backoff controls traffic; “confirmation unavailable” is more honest than an invented success or definitive failure.
  • Reject conflicting payloads. Reusing an identifier for different content must follow an explicit policy.

These patterns aim for an effectively-once application effect within a defined storage and retention model. They do not promise universally exactly-once delivery or defeat the impossibility result. These are design recommendations, not claims that every mechanism is implemented on this website.

Choose the boundary, then the protocol

For an ordinary website, HTTPS and correct peer verification protect communication; permissions, validated input, durable writes, and retry handling protect the operation. Real-time media may prefer secure datagrams; a transactional workflow needs clear receipts and reconciliation. Choose protocols for those needs rather than a false contest between UDP and TLS.

The Two Generals lesson is not that useful distributed systems are impossible. It is that they must operate honestly under uncertainty. Secure transport protects the conversation. Application design determines what the participants can safely conclude from it.

UDPTLSDistributed Systems

Comments (3)

Demo discussion
  • Jose Hamilton

    Jose@orangewolf240

    A TCP acknowledgment and a durable application receipt answer very different questions.

    • Encarnación Vargas

      Encarnación@tinyelephant116

      The lost-response example shows why retries need a stable operation identifier even over HTTPS.

    • Juri Krahl

      Juri@organicpanda406

      Separating DTLS from QUIC avoids treating all encrypted UDP traffic as the same delivery model.

      Elsewhere in the notebook