Chapters

10 Error Detection: CRC and Checksums

iot
transport-protocols
reliability
retry-sequencing

10.1 Start With the Suspicious Packet

Connect the Check Result to a Receiver Action

Picture a pressure reading that reaches a pump controller with one changed bit. The receiver must decide whether to accept, reject, ask again, or enter a safe unknown state. A red error light is useful only if that decision and its limit are clear.

A checksum is a small value calculated from a stated part of a message. A cyclic redundancy check, or CRC, is a stronger form designed to catch common bit changes. Record the message version, protected bytes, method and settings, expected value, received value, receiver rule, and final result.

Flip one bit, swap two bytes, cut the message short, repeat it, change its order value, use the wrong format, and restart the receiver. Check accepted and rejected paths. Keep a known bad test that would pass if someone removed or narrowed the check by mistake.

A matching value does not prove who sent the message, whether it is fresh, whether the sensor is right, or whether every possible change was detected. Error detection is one bounded claim, not security or full reliability.

Practitioner builds the message and receiver test. Under the Hood explains parity, checksum behavior, CRC polynomials, coverage, undetected patterns, and how sequence and identity rules complete the decision path.

Use this receiver check:

  • Save one known good message.
  • Mark the exact protected bytes.
  • Record the method and settings.
  • Flip one bit and reject.
  • Swap two bytes and reject.
  • Cut the message and reject.
  • Repeat it and check identity.
  • Change order and check state.
  • Restart the receiver and retry.
  • Test the normal path again.
  • Keep each bad case as a test.
  • State what the check cannot prove.

Imagine a receiver facing one packet that might be corrupted, duplicated, truncated, or out of sequence. Detection mechanisms are useful because they help the receiver decide whether to accept, reject, retry, or escalate that packet. The review has to preserve both sides: what the check can detect and what it still cannot prove.

10.2 Overview: Detection Is a Bounded Claim

Error detection asks whether a receiver can notice a corrupted, malformed, repeated, or suspicious message before treating it as valid. Checksums, CRCs, parity bits, sequence values, and duplicate markers can all help, but each one supports only the claim it was actually designed and observed to support.

A useful IoT reliability review ties the check method to the message scope and the receiver action. The record should say what was protected, how the check was computed or interpreted, what evidence showed accept or reject behavior, what the evidence cannot prove, and which change requires retest.

For example, meter-12 sends a pressure sample with payload bytes, a sequence value, and a CRC. A useful review packet does not stop at "CRC failed." It records the exact frame or trace, the byte range covered by the check, the receiver rule, and the action that followed. If the receiver drops the malformed frame and emits a diagnostic, the evidence supports bounded rejection. If it silently retries, accepts a stale duplicate, or logs only a generic parsing error, the review conclusion changes.

A matching check value is not a broad reliability, security, or data-quality guarantee. It is evidence that one check passed under one stated message format and receiver rule.

The opening examples become reviewable only when the observed packet is connected to the receiver’s decision and to an explicit limit. Trace Figure 10.1 to see that complete evidence chain before comparing particular check methods.

Reliability error-detection evidence path from message scope through check method, observed packet, receiver result, limit note, and retest trigger.
Figure 10.1: Error-detection evidence becomes reviewable when every step connects a protected message to an observed receiver decision and a stated limit.

Read Figure 10.1 from the protected message scope into the named check method and observed condition. Continue to the receiver result, then finish at the limit and retest trigger. That order separates detecting a mismatch from deciding what the system did about it, preserving the chapter’s bounded claim instead of turning one clean check into universal reliability proof.

Message scope

Name the packet, frame, field range, application message, source, receiver, and observation point under review.

Check method

Name the checksum, CRC profile, parity rule, sequence value, duplicate marker, or combined rule used by the receiver.

Receiver result

Record accept, reject, quarantine, retry request, diagnostic event, or ignored duplicate behavior after the check.

Review limit

State what the evidence does not show, such as payload meaning, authorization, replay safety, or future coverage.

Overview Check

10.3 Practitioner: Build the Error-Detection Record

Start with the question the record must answer: can this receiver notice and handle this failure condition in this transport path? Then separate the method from the outcome. The method describes how the check is interpreted. The outcome describes what the receiver did when the check passed, failed, repeated, or appeared out of sequence.

This separation matters in IoT systems because the same packet evidence can lead to different operational decisions. A routine telemetry sample might be dropped. A command might be rejected and alarmed. A repeated idempotent update might be ignored. A malformed frame might be quarantined for investigation.

To turn that evidence path into a reusable review artifact, inspect the field groups in Figure 10.2. They show what must be recorded together so a later reviewer can repeat the check and understand its consequence.

Reliability error-detection record grouping scope, check method, observed condition, receiver action, decision, and retest trigger.
Figure 10.2: A compact record keeps method details, observed condition, receiver action, decision, limits, and retest ownership separate.

In Figure 10.2, begin with scope and method, move through the observed condition and receiver action, and only then read the decision, limits, ownership, and retest trigger. The progression keeps calculation details separate from operational behavior while still joining them in one record, which is exactly what the worked CRC example needs.

Record area
Minimum evidence
Review consequence
Common shortcut
Scope
Message type, source, receiver, observation point, included fields, and artifact link or trace name.
Prevents a local packet result from being over-applied to other messages or paths.
Saying "the checksum passed" without naming the bytes checked.
Method
Checksum or CRC profile, parity rule, sequence field, duplicate key, byte order, and excluded fields.
Makes the check repeatable and reveals when another implementation would calculate a different value.
Treating the label "CRC" as enough method detail.
Receiver action
Accept, reject, quarantine, retry request, ignore duplicate, diagnostic event, or operator-visible alarm.
Connects detection to system behavior instead of stopping at packet inspection.
Showing a mismatch but not showing what the receiver did.
Limit and retest
Known non-claims, owner, and triggers such as format, parser, firmware, path, seed, byte order, or policy changes.
Keeps the record useful after design changes and avoids unsupported reliability claims.
Leaving no trigger for stale evidence.

Worked Record

Assume a sensor frame is rejected after a CRC mismatch. The log names the frame, receiver, and rejection result, but not the configured CRC profile or included bytes. Keep the rejection as receiver-action evidence, then request the missing method details so another reviewer can recompute or interpret the result.

The bounded conclusion is narrow: this receiver rejected this observed frame under the recorded condition. It does not prove every frame format, every corruption pattern, every parser revision, or the semantic correctness of later accepted payloads.

Practitioner Check

10.4 Under the Hood: Know What the Check Cannot Prove

Different checks answer different questions. A simple checksum can catch many accidental changes, but a weak checksum may miss some error patterns. A CRC can be much stronger for a configured error model, but the record must still name the actual profile and receiver behavior. Parity can support a narrow bit-level check. Sequence values and duplicate keys can reveal gaps, repeats, or stale observations, but they do not validate payload meaning.

Error detection also sits below several other review layers. A clean check value does not authenticate the peer, authorize the action, decrypt the payload, prove freshness by itself, confirm idempotent application behavior, or decide whether a retry is safe. Those claims need their own evidence.

Mechanically, the receiver recomputes the check over the same byte range and compares the result with the transmitted value. Two correct implementations can disagree if one uses a different byte order, seed, polynomial profile, included-field set, padding rule, or trailer encoding. A review record should therefore describe the calculation contract, not just the word "CRC" or "checksum." The check can say that the protected bytes arrived in a form consistent with that contract; it cannot say whether those bytes represent the current command, the right actuator, or a safe side effect.

The limits of a CRC are easiest to understand by following the bytes through both endpoints. Figure 10.3 exposes the calculation and comparison points where two implementations must agree before the receiver can make its narrow accept-or-reject decision.

CRC workflow for packet transmission: the sender assembles header and payload bytes, a CRC engine runs the polynomial to produce a short integrity value, the value is appended on the wire, and the receiver recomputes and compares it to accept a matching frame or reject a changed one.
Figure 10.3: A CRC review is repeatable only when both sides use the same protected byte range, profile, and comparison rule, and the record still limits the claim to packet-level error detection.

Trace Figure 10.3 from the sender’s header and payload through the configured polynomial calculation and appended check value. On the receiver side, follow the same protected byte range through recomputation and comparison, ending at accept or reject. The flow explains why profile, byte order, seed, and included fields belong in the record—and why even a match says nothing by itself about freshness, authorization, or safe application meaning.

Checksum limit

Record included bytes, byte order, initial value if relevant, receiver comparison, and what error patterns remain out of scope.

CRC limit

Record the configured profile, included fields, check-value encoding, accept evidence, failed-check evidence, and retest triggers.

Sequence limit

Use sequence values for ordering, gaps, repeats, or stale-message review, not as proof that payload content is correct.

Security limit

Use security evidence for identity, confidentiality, integrity, authorization, and replay protection when those claims matter.

Failure Review Prompts

Use the prompts to widen the review one boundary at a time. Begin by testing whether a clean check can still carry stale or unauthorized meaning, then confirm that both implementations share the calculation contract. Compare positive and negative receiver evidence, match the receiver action to application risk, and finish by naming the change that makes the check stale. The sequence keeps packet detection separate from freshness, authorization, and safe outcome.

Preserve the exact artifact behind each answer. A trace can identify protected bytes and transmitted values, while endpoint logs show recomputation, rejection, quarantine, or application delivery. A sequence or duplicate record answers a different question from a checksum. Keeping those sources separate makes the resulting accept, retry, alarm, or hold decision defensible.

  • Could a clean check value still carry stale, unauthorized, or semantically wrong data?
  • Could another parser, byte order, seed, or excluded field calculate a different result?
  • Does the record show both a normal accept case and a failed-check or duplicate case?
  • Does the receiver action match the application risk: drop, retry, quarantine, alarm, or hold?
  • Which later change reopens the review: format, firmware, parser, gateway, security layer, retry policy, or receiver action?

Under-the-Hood Check

10.5 Retries and Sequence Numbers

10.5.1 Start With the Duplicate Message

Design the Second Copy Before Sending the First

Picture a pump command sent just as a reply is lost. Sending again may be right, but running the pump twice may not be.

Give each command an identity and sequence value. Set the wait, retry limit, stop rule, and safe state after doubt. A gateway is the unit that links one device group to another network or service. It must keep or translate the identity without making an old command look new.

Lose the reply, delay the first copy, reorder two commands, restart the receiver, and wrap the sequence range. Record what the sender knows and what the pump actually did.

Retries reduce some loss; they do not prove the result. Practitioner builds the evidence record. Under the Hood defines receiver state, duplicate rules, wrap, and side-effect limits.

A retry design is tested by the second copy of a message, not the first. Ask how the receiver distinguishes a valid retry from a duplicate command, how sequence state wraps, and when acknowledgements stop the loop. That story turns retry counts and sequence numbers into application safety evidence.

10.5.2 Overview: Retry Only Means Something With Boundaries

Retries and sequence numbers help an IoT system reason about loss, duplication, delay, and reordering. They do not prove that every message arrived or that every command was safe. They support a reliability decision only when the sender limit, receiver state, duplicate rule, and side-effect boundary are explicit.

A retry policy says when a sender tries again, when it stops, and what state remains after the limit. A sequence policy says how the receiver recognizes a new, duplicate, stale, missing, or reordered message.

For example, gateway-east sends command C-512 with sequence 181 to a valve controller and expects acknowledgement A-181 before the response window closes. If the acknowledgement is missing, a reviewable retry policy might wait a short interval, add jitter so a fleet does not retry in the same millisecond, try twice, then mark the command unresolved and leave the valve state at last-confirmed. That record is stronger than "three retries" because it names the command identity, the acknowledgement identity, the stop condition, and the state after the sender gives up.

The receiver side needs the same discipline. If sequence 181 arrives twice, the receiver may acknowledge the duplicate so the sender can stop, but it must not apply the valve command twice unless the command is explicitly idempotent. If sequence 183 arrives after 181, the receiver needs a rule for the missing 182: wait inside a reordering window, reject the gap, or flag the state as incomplete. Without those sequence rules, retries can turn a recoverable timeout into a duplicate write, stale dashboard value, or unsafe actuator action. The important evidence is the tested state transition, not the fact that a retry occurred.

The duplicate-command example needs one continuous route from the first timeout to the receiver’s final state. Use Figure 10.4 to follow that route before deciding whether the retry policy is safe.

Retry and sequence review loop from observed timeout or sequence gap through retry decision, acknowledgement or sequence state, final state, and retest trigger.
Figure 10.4: Retry and sequence evidence should close the loop from observation to final state.

Trace Figure 10.4 from the missing acknowledgement or sequence gap into the retry decision. Next inspect acknowledgement and receiver sequence state, then follow the path to the final state and retest trigger. The diagram connects sender limits to receiver-side duplicate handling, showing why visible retries alone do not prove delivery or side-effect safety.

Message Boundary

Name the telemetry report, command, queue item, gateway handoff, or state update that retry and sequencing protect.

Retry Boundary

Record timeout observation, delay behavior, retry limit, acknowledgement result, and the final state after stop or success.

Sequence Boundary

Record accepted sequence state, duplicate rule, missing-message rule, reordering window, reset behavior, and wraparound rule.

Side-Effect Boundary

Show whether repeated or late messages can change stored state, actuator state, command status, or operator decisions.

Review rule:

Do not approve retry behavior from repeated attempts alone. The evidence must show a bounded decision and the state left behind.

10.5.3 Practitioner: Build the Evidence Record

A practitioner should review retry and sequence behavior as a record, not as a slogan. The record starts with the message boundary and observed condition, then ties retry policy, acknowledgement handling, sequence state, side effects, final decision, and retest trigger together.

This works for TCP-based reconnect decisions, UDP paths with application acknowledgements, CoAP or MQTT message IDs, gateway queues, and application command logs. The exact protocol changes the signals available, but the record still needs bounded evidence.

The practitioner record must preserve both sender policy and receiver state without hiding either inside a generic retry count. Figure 10.5 shows the fields to inspect in order.

Retry and sequence decision record fields for message boundary, observed condition, retry policy, acknowledgement result, sequence state, side-effect boundary, final decision, and retest trigger.
Figure 10.5: Retry and sequence decision record fields for message boundary, observed condition, retry policy, acknowledgement result, sequence state, side-effect boundary, final decision, and retest trigger.

In the diagram Figure 10.5, begin with the protected message and observed condition, then compare the retry policy with the acknowledgement and accepted sequence state. Continue through the side-effect boundary to the final decision, owner, and retest trigger. This order makes the record suitable for TCP reconnects, datagram acknowledgements, and queue handoffs while keeping each conclusion tied to its tested path.

Evidence Flow

1. State the boundary Identify the message, receiver expectation, state update, and observation point.
2. Record the condition Name the timeout, missing acknowledgement, duplicate, stale value, sequence gap, reorder, or reset.
3. Review the retry Capture delay behavior, jitter if used, retry limit, stop condition, and final sender state.
4. Review receiver state Capture acknowledgement identity, late response rule, accepted sequence value, duplicate rule, and gap rule.
5. Close the record Record side-effect guard, final decision, owner, and retest trigger.
Review Signal
Weak Evidence
Stronger Evidence
Decision Pressure
Timeout
A log says "timeout" without the expected response or observation point.
Expected acknowledgement, message identity, timer start, observation point, and state at timeout.
Retry, hold, fail safe, reconnect, or mark unknown.
Retry
A counter increments with no delay rule, limit, or final state.
Delay behavior, limit, stop condition, final state, and congestion or battery concern when relevant.
Accept for scope, revise policy, or add operational alert.
Sequence value
A sequence number appears in a trace without an accept or reject rule.
Prior accepted state, duplicate rule, gap rule, reset boundary, and wraparound rule when finite.
Accept, ignore, reject, wait for repair, or retest after reset.
Side effect
The command is retried without saying whether repeating it is safe.
Idempotency rule, command identifier, receiver state, duplicate action, and rollback or hold behavior.
Guard side effects before accepting the retry path.

10.5.4 Under the Hood: State Rules Prevent False Confidence

Under the hood, retry and sequencing are state machines. A sender tracks attempts, delays, acknowledgements, and stop conditions. A receiver tracks accepted values, stale values, duplicate decisions, gaps, resets, and sometimes a finite sequence space.

The hard part is not naming a retry or a sequence number. The hard part is proving what happens when evidence arrives late, twice, out of order, after reconnect, after a reset, or after the retry limit has already changed the final state.

State Boundaries to Inspect

Boundary
Failure Mode
Evidence Needed
Retest Trigger
Acknowledgement identity
A late or unrelated acknowledgement is accepted for the wrong message.
Message identifier, expected response, late-response rule, and association with the retry attempt.
Acknowledgement format, gateway mapping, batching, or session behavior changes.
Retry stop state
The sender keeps retrying, hides a persistent fault, or leaves command state ambiguous.
Retry limit, stop condition, state after limit, alert or hold rule, and owner of next action.
Timeout policy, retry limit, firmware, power mode, or network path changes.
Duplicate and stale values
A repeated or old message changes state again or overwrites newer data.
Accepted sequence state, duplicate action, stale-data rule, and side-effect guard.
Receiver storage, reconnect behavior, queue behavior, or reset logic changes.
Gap and wraparound
A missing value is assumed lost too early, or a wrapped value is mistaken for stale traffic.
Gap handling, reordering window, reset boundary, wraparound rule, and tested final state.
Sequence space, window size, session boundary, or message rate changes.
Common pitfall:

A retry trace is not a delivery guarantee. Treat it as evidence only after the receiver state and side-effect rules are visible.

Acceptance Checklist

Apply the checklist from message identity to future change. Fix the protected boundary and expected response, capture the observed timeout or sequence condition, and then inspect sender retry limits and receiver sequence state together. Guard application side effects before accepting the final state, and record every policy, firmware, gateway, message, or path change that requires a retest. This order closes the reliability loop rather than merely counting retries.

Exercise both success and ambiguity. Show a normal acknowledgement, a lost acknowledgement followed by a retry, a duplicate or delayed original, and the state after the sender stops. Where sequence space resets or wraps, record the receiver rule explicitly. These cases reveal whether an apparently successful retry can still repeat a write, command, or actuator action.

  • Name the protected message boundary and expected response.
  • Record timeout, missing acknowledgement, duplicate, stale value, gap, or reorder evidence.
  • Show retry delay behavior, limit, stop condition, and final state.
  • Show accepted sequence state, duplicate rule, stale rule, gap rule, reset rule, and wraparound rule when relevant.
  • Guard side effects before accepting repeated commands, repeated writes, or repeated actuator actions.
  • List retest triggers for policy, firmware, gateway, receiver state, message shape, and path changes.

10.5.5 Summary

Retry and sequencing evidence has to join sender policy to receiver state. Name the message, timeout or gap, delay and retry limit, acknowledgement identity, duplicate and reorder rules, side-effect boundary, and final state before accepting the path. The summary below preserves that sequence and the reset, wraparound, firmware, or policy changes that require the record to be rebuilt.

The practical test is the second or late copy, not the successful first delivery. A safe record shows whether that copy was acknowledged, ignored, held, or applied and how the decision interacted with stored or actuator state. That receiver evidence turns sequence values and retry counters into a defensible reliability claim.

  • A retry or sequence claim needs a named message boundary, acknowledgement identity, retry timer, sequence window, and receiver side-effect rule.
  • Retry evidence needs timeout observation, acknowledgement identity, retry delay behavior, retry limit, stop condition, and final state.
  • Sequence evidence needs accepted state, duplicate handling, stale-message rules, gap handling, reset behavior, and wraparound boundaries when relevant.
  • Receiver state and side-effect guards decide whether repeated or delayed messages are safe.
  • Retest when timeout policy, retry policy, acknowledgement format, sequence-window behavior, firmware, gateway behavior, message shape, or transport path changes.

10.5.6 Key Takeaway

Approve retry and sequence behavior only when the record proves bounded retry, receiver state, duplicate handling, side-effect safety, and retest ownership for the tested path.

10.5.7 See Also

10.6 Summary

Error detection gives reviewers evidence that a receiver noticed a mismatch, duplicate, malformed message, or suspicious sequence condition. The evidence is strongest when it names the message scope, check method, checked fields, observed receiver action, known limits, and retest trigger.

Checksums, CRCs, parity, sequence values, and duplicate markers answer different questions. None should be stretched into a broad reliability, security, or application-correctness conclusion. Use error-detection evidence to decide the bounded claim, then hand off retry behavior, application state, authorization, freshness, and data-quality questions to the right review layer.

10.7 Key Takeaway

Error detection is reviewable when the record connects the method to receiver behavior and states the limit: a passed check value is not the same as a correct, fresh, authorized, or safe application outcome.

10.8 See Also

How DTLS Protects UDP

Separate corruption detection from security evidence for identity, integrity, confidentiality, and replay handling.