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.

transport-comparisonprotocol-selectionreliability-evidence
Packet Pete, the module guide, in a scene from this chapter.
iotclass.org

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
iotclass.org

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.
iotclass.org

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.
iotclass.org

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.
iotclass.org

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.
TCP and UDP answer different questions: TCP adds connections, ordering, and congestion control, while UDP stays a lightweight, connectionless datagram.
TCP and UDP answer different questions: TCP adds connections, ordering, and congestion control, while UDP stays a lightweight, connectionless datagram.
iotclass.org

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.

Key terms

Once the candidate behavior
Once the candidate behavior is understood, the decision needs a record that exposes what each side proved and left open.

Why it matters

Failure it prevents.

The decision record keeps the selected transport tied to message behavior, evidence, limits, owner, and retest trigger.
The decision record keeps the selected transport tied to message behavior, evidence, limits, owner, and retest trigger.
iotclass.org

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.
iotclass.org

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.

Key terms

If an unlock result
If an unlock result is lost after execution, reconnecting a reliable stream does not tell the sender whether another attempt would repeat the action.

Numbers to remember

12 bytestwo application records contain 12 bytes each
24 bytestwo application records contain 12 bytes each, giving 24 bytes in total.
TCP and UDP answer different questions: TCP adds connections, ordering, and congestion control, while UDP stays a lightweight, connectionless datagram.
TCP and UDP answer different questions: TCP adds connections, ordering, and congestion control, while UDP stays a lightweight, connectionless datagram.
iotclass.org

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.
iotclass.org

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.
iotclass.org

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.
iotclass.org

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.
iotclass.org

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?

AAcceptance of UDP because small actuator packets never need receiver-state evidence.
BA switch to TCP without checking receiver acceptance or application state.
CProve consequence, retry owner, receiver acceptance, and security.
DRemoval of the security boundary because selection is only about ports and packet size.
Show answer

Answer: C TCP versus UDP selection should be tied to the message consequence, reliability owner, receiver behavior, security boundary, and retest condition.

iotclass.org

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?

ANothing else, because ordered TCP delivery proves the configuration is safe to apply.
BProve framing, authorization, receiver acceptance, and rollback.
COnly the source port and TCP close event, because they prove receiver intent.
DA UDP retransmission log, even though the selected path and application claim are TCP.
Show answer

Answer: B TCP evidence supports stream delivery, while application correctness needs framing, completion, authorization, receiver-state, and recovery evidence.

iotclass.org

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?

ATreat the command as complete when the cloud-to-gateway TCP segment succeeds.
BReject all mixed paths because TCP and UDP can never share a command route.
CIgnore the security boundary because the gateway saw the command and can vouch for it.
DSplit by segment; prove handoff, device state, and security.
Show answer

Answer: D Gateway translation creates separate transport and receiver-evidence boundaries that must be reviewed independently.

iotclass.org

Print reference

Answers

Answer key.

  1. C · TCP versus UDP selection should be tied to the message consequence, reliability owner, receiver behavior, security boundary, and retest condition.
  2. B · TCP evidence supports stream delivery, while application correctness needs framing, completion, authorization, receiver-state, and recovery evidence.
  3. D · Gateway translation creates separate transport and receiver-evidence boundaries that must be reviewed independently.
iotclass.org