Transport Protocols · Study deck
TCP vs UDP: How to Choose
A greenhouse temperature source sends a new reading every 5 s, while a nearby door controller accepts unlock requests.
Packet Pete is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: UDP can be reviewable if the record shows datagram identity, acceptable loss or replacement behavior, duplicate and stale-message handling, and the protection boundary when the path carries protected data.
- Explain: Application acknowledgements, sequence identifiers, freshness checks, and idempotency can make a UDP-based path reviewable, while poor stream framing or receiver-state handling can make a TCP-based path unsafe.
- Explain: If the application needs only the latest state, choose independent datagrams with explicit sample identity, age checks and suitable protection when the tested loss behaviour is acceptable.
- Compare TCP and UDP behavior for IoT flows
Major section
Start With the Failure Question
A separate message can be reliable when a higher layer adds identity, age, order, and reply rules.
- Recheck after either end changes.
- Repeating that command may cause harm.
- These flows should not inherit the same delivery choice.
- Transport is the part of a data path that moves information between applications.
Major section
Start With the Failure Question (continued)
Under the Hood examines connection state, duplicate action, receiver ownership, and the boundaries that simple labels can hide.
- It keeps order and works to replace missing pieces.
- Another style sends separate messages.
- It leaves more decisions to the application.
- Neither style makes the whole product safe by itself.
Major section
Start With the Failure Question (continued)
A managed stream can still carry a bad or repeated action.
- The receiver must prove the result that matters to the product.
- Real software adds security, retries, queues, and its own state.
- The better transport choice is the one whose behavior and remaining responsibilities match that failure story.
Major section
Overview: TCP and UDP Answer Different Evidence Questions
The TCP-versus-UDP choice becomes clearer when both candidates are judged against the same message need.
- The path connects protocol mechanics to application consequences instead of awarding a universal winner.
Major section
Practitioner: Build the Transport Decision Record
A reviewable TCP-versus-UDP decision is a compact record.
- It names the flow, the required behavior, the selected transport, the evidence, the open limit, the owner, and the trigger for retesting the choice.
- Finish with the chosen behavior, limits, owner, and retest trigger.
- The same UDP record should not be copied to an actuator command.
Major section
Practitioner: Build the Transport Decision Record (continued)
Failure it prevents.
- Worked Record: Replaceable Reading A sensor sends periodic status readings, and the collector displays the latest accepted value.
- UDP can be reviewable if the record shows datagram identity, acceptable loss or replacement behavior, duplicate and stale-message handling, and the protection boundary when the path carries protected data.
- The command has a different consequence, so it needs final receiver-state evidence and a separate retry or acknowledgement decision.
Major section
Decide Whether the Next Sample Replaces the Missing One
If the application needs only the latest state, choose independent datagrams with explicit sample identity, age checks and suitable protection when the tested loss behaviour is acceptable.
- That design still needs to reject a delayed old sample that arrives after the new one.
Major section
Decide Whether the Next Sample Replaces the Missing One (continued)
If a maintenance upload requires every byte in order, choose a managed stream when its connection and recovery costs fit the endpoint.
- A missing piece can then delay delivery of later stream bytes while transport works to restore order; the application still needs message framing.
- For a concrete framing example, two application records contain 12 bytes each, giving 24 bytes in total.
- If an unlock result is lost after execution, reconnecting a reliable stream does not tell the sender whether another attempt would repeat the action.
Major section
Summary
TCP and UDP should now be compared as different evidence boundaries for a named flow.
- The summary below closes the comparison without declaring a universal winner: the acceptable choice is the one whose observed behavior fits this receiver outcome.
- Application acknowledgements, sequence identifiers, freshness checks, and idempotency can make a UDP-based path reviewable, while poor stream framing or receiver-state handling can make a TCP-based path unsafe.
- Gateways can split one end-to-end claim into multiple segment records.
Major section
Summary (continued)
Security boundaries such as TLS and DTLS should be named separately from transport behavior.
- TCP and UDP should be compared from message evidence, not from protocol preference.
- TCP provides ordered byte-stream behavior within a connection, but application correctness still needs separate proof.
- Retest when message criticality, endpoint behavior, gateway ownership, retry policy, receiver rules, or security boundaries change.
Deck summary
Key takeaways
A separate message can be reliable when a higher layer adds identity, age, order, and reply rules.
- Under the Hood examines connection state, duplicate action, receiver ownership, and the boundaries that simple labels can hide.
- A managed stream can still carry a bad or repeated action.
- The TCP-versus-UDP choice becomes clearer when both candidates are judged against the same message need.
- A reviewable TCP-versus-UDP decision is a compact record.
Retrieval practice
Recall check 1 of 3

Packet Pete says: answer from memory, then check your reasoning.
Q1A team chooses UDP for an actuator command because the packet is small. What should the transport review require first?
Show answer
Answer: C TCP versus UDP selection should be tied to the message consequence, reliability owner, receiver behavior, security boundary, and retest condition.
Retrieval practice
Recall check 2 of 3

Packet Pete says: answer from memory, then check your reasoning.
Q2A TCP record proves a configuration file was delivered as an ordered byte stream. What still needs separate evidence before the configuration can be trusted?
Show answer
Answer: B TCP evidence supports stream delivery, while application correctness needs framing, completion, authorization, receiver-state, and recovery evidence.
Retrieval practice
Recall check 3 of 3

Packet Pete says: answer from memory, then check your reasoning.
Q3A gateway accepts a TCP command from a cloud service, then forwards a UDP datagram to a sleepy device. What is the safest review conclusion?
Show answer
Answer: D Gateway translation creates separate transport and receiver-evidence boundaries that must be reviewed independently.
Print reference
Answers
Answer key.
- C · TCP versus UDP selection should be tied to the message consequence, reliability owner, receiver behavior, security boundary, and retest condition.
- B · TCP evidence supports stream delivery, while application correctness needs framing, completion, authorization, receiver-state, and recovery evidence.
- D · Gateway translation creates separate transport and receiver-evidence boundaries that must be reviewed independently.