IoT Fundamentals · Study deck

Packet Error Detection

Picture a temperature packet crossing a noisy link with one bit changed.

Physics Phoebe is your guide for this deck.

packeterrordetection
Physics Phoebe, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: A receiver ported from one microcontroller library to another can therefore reject every clean frame if the polynomial notation, reflection flags, initial register, final XOR, or output byte order silently changes.
  • Explain: A gateway that crosses a security boundary needs a different layer: a keyed message authentication code, AEAD tag, or protocol-provided integrity check that an attacker cannot recompute without the key.
  • Explain: A broken seal tells you something changed in transit, but it does not tell you what the contents should have been, and a maker could counterfeit the seal.
iotclass.org

Major section

In 60 Seconds

The resulting number may still look believable, so the receiver needs a defined check and a safe response.

  • CRC means cyclic redundancy check, a calculation used to detect changed bits.
  • JSON means JavaScript Object Notation, a readable text format for named data.
  • A payload means the useful reading or command inside a message.
iotclass.org

Major section

Start With the Story

You will choose an error check, define which bytes it covers, and decide what happens when validation fails.

  • The first two panels show why a plausible value cannot prove that its bytes survived the link.
  • The third adds a check over an exact packet range.
  • The last rejects the bad copy and requests clean data.
iotclass.org

Major section

What a Check Value Proves (and What It Doesn't)

A practical receiver also keeps the check value tied to the packet boundary.

  • The important idea is to know the limits.
  • A passing check gives the receiver evidence to accept, drop, retry, or escalate a frame.
  • Deliberate tampering needs a keyed integrity tag, not a bigger CRC.

Why it matters

In both cases, the check is useful because the receiver knows the covered bytes and the action to take when they fail.

iotclass.org

Major section

What a Check Value Proves (and What It Doesn't) (continued)

A framed link uses a CRC trailer; two devices that both say "CRC" still disagree unless the exact variant and protected range match.

  • A broken seal tells you something changed in transit, but it does not tell you what the contents should have been, and a maker could counterfeit the seal.
  • The One-Minute Check-Value ViewIt protects a byte range A record should always say exactly which bytes are covered: header, payload, length, or selected fields.
  • If you can name what a check value proves and does not prove, you can stop here.
iotclass.org

Major section

Apply It: Validate a Packet and Choose Recovery

The receiver should validate boundaries, scope, algorithm, and recovery in a repeatable order.

  • Recompute locally: Use the captured bytes, not a decoded display value, to calculate the expected check.
  • The checksum path adds byte values, so a byte swap can preserve the sum.
  • The CRC changes for reorderings that leave the simple sum unchanged.
Checksum and CRC comparison: addition checksums are cheap but miss swaps and some bursts; CRC variants spend trailer bits to catch more position-sensitive corruption.
Checksum and CRC comparison: addition checksums are cheap but miss swaps and some bursts; CRC variants spend trailer bits to catch more position-sensitive corruption.
iotclass.org

Major section

Apply It: Validate a Packet and Choose Recovery (continued)

That blind spot is exactly why stronger links use a CRC, whose result depends on bit position and order.

  • The capability summary is a selection aid, not a substitute for recording the exact CRC variant, protected length, and recovery action.
  • The sum is still 0x1A8 and the checksum still reads 0xA8, so the corrupted order passes.
  • If you can validate a frame and choose recovery, you can stop here.
iotclass.org

Major section

Under the Hood: CRC Parameters, Selection, and Residual Risk

A CRC treats the protected bits as a polynomial and divides by a generator polynomial; the remainder becomes the check value.

  • That makes the result sensitive to bit position and ordering, which is why a CRC catches many error patterns an addition checksum misses.
  • But "CRC" alone is not a specification.
  • Implementation details matter because many field failures are variant mismatches, not bad mathematics.
  • A reflected CRC implementation processes least-significant bits first; a non-reflected implementation processes most-significant bits first.

Why it matters

Implementation details matter because many field failures are variant mismatches, not bad mathematics.

Selection drivers: error model, frame length, consequence, and threat boundary steer the method; a wider CRC lowers random collision probability, but width alone is not the full definition.
Selection drivers: error model, frame length, consequence, and threat boundary steer the method; a wider CRC lowers random collision probability, but width alone is not the full definition.
iotclass.org

Major section

Under the Hood: CRC Parameters, Selection, and Residual Risk (continued)

A wider CRC lowers accidental collision risk for a stated model, but it does not create trust.

  • A receiver ported from one microcontroller library to another can therefore reject every clean frame if the polynomial notation, reflection flags, initial register, final XOR, or output byte order silently changes.
  • Selection also depends on what the protocol is trying to defend against.
  • A mismatch here makes both sides disagree even on clean bytes.
iotclass.org

Major section

Under the Hood: CRC Parameters, Selection, and Residual Risk (continued)

Assuming one clean demo represents field behavior.

  • A small sensor link that mainly sees random bit flips can often use a CRC plus retry because the receiver only needs to screen accidental corruption.
  • A gateway that crosses a security boundary needs a different layer: a keyed message authentication code, AEAD tag, or protocol-provided integrity check that an attacker cannot recompute without the key.
  • Explicit accept, drop, retry, or escalate policy.
iotclass.org

Major section

Under the Hood: CRC Parameters, Selection, and Residual Risk (continued)

It should identify the CRC variant, the bytes covered, byte ordering on the wire, the comparison result, and the receiver action for mismatch.

  • That record prevents a later port, library upgrade, or protocol bridge from changing one parameter while keeping the same label in the documentation.
  • Wider usually lowers random collision probability, but width alone is not the full definition.
  • Using a CRC where a keyed integrity tag is required.
iotclass.org

Major section

Under the Hood: CRC Parameters, Selection, and Residual Risk (continued)

Byte orderThe transmitted check field needs a defined byte order so the receiver compares the same value.

  • A useful review states what the chosen variant guarantees and what residual risk remains.
  • Choosing a Check MethodThe choice is driven by the error model, frame length, failure consequence, and threat boundary.
  • The bottom checksum example misses a byte swap, showing why a passing check cannot rule out every error.
iotclass.org

Major section

Summary

Detection is not correction; the protocol still needs a recovery action on failure.

  • The sender creates the check value, and the receiver repeats the same work before it accepts the frame.
  • A checksum is cheap but can miss ordered changes that leave the sum intact.
  • A CRC is not authentication; use a keyed integrity mechanism when deliberate modification is in scope.
iotclass.org

Deck summary

Key takeaways

The resulting number may still look believable, so the receiver needs a defined check and a safe response.

  • You will choose an error check, define which bytes it covers, and decide what happens when validation fails.
  • A practical receiver also keeps the check value tied to the packet boundary.
  • A framed link uses a CRC trailer; two devices that both say "CRC" still disagree unless the exact variant and protected range match.
  • The receiver should validate boundaries, scope, algorithm, and recovery in a repeatable order.
iotclass.org

Retrieval practice

Recall check 1 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q1A receiver recomputes a frame check and gets a mismatch. The sender can retry. What should the receiver do?

ADeliver the frame and label it uncertain.
BChange the check value to match the received bytes.
CTreat the mismatch as proof of deliberate tampering.
DReject the frame and request a clean copy.
Show answer

Answer: D A mismatch means this copy cannot be accepted; a retry can supply a clean copy.

iotclass.org

Retrieval practice

Recall check 2 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q2A packet uses an 8-bit addition checksum. The payload bytes 03 10 are received as 10 03. Why might the checksum still pass?

AThe checksum automatically corrects the byte order
BThe receiver ignores all payload bytes
CThe CRC polynomial was too small
DThe checksum sum stays unchanged when bytes swap.
Show answer

Answer: D Addition is commutative, so swapping two bytes preserves the same sum and the checksum does not notice the change.

iotclass.org

Retrieval practice

Recall check 3 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q3Which information is needed to reproduce a CRC result from a packet capture?

AOnly the family name and the decoded payload fields shown by the analyzer
BWidth, polynomial, initial value, reflection, final XOR, covered bytes, and check-field byte order
COnly the packet timestamp and the received frame length from the capture log
DOnly the nominal CRC width, such as CRC-16 or CRC-32, plus the payload size
Show answer

Answer: B CRC is a family of algorithms; these parameters define how both sides compute and compare the value.

iotclass.org

Retrieval practice

Recall check 4 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q4An engineer argues that upgrading from a 16-bit to a 32-bit CRC makes the link tamper-proof. What is the strongest correction?

AA 32-bit CRC is cryptographically secure once the polynomial is secret
BAny CRC already proves the sender's identity
CWider CRCs remove the need for a recovery action
DA CRC of any width detects accidental corruption only.
Show answer

Answer: D An attacker can recompute a CRC after modifying the data, so width does not add authenticity.

iotclass.org

Print reference

Answers

Answer key.

  1. D · A mismatch means this copy cannot be accepted; a retry can supply a clean copy.
  2. D · Addition is commutative, so swapping two bytes preserves the same sum and the checksum does not notice the change.
  3. B · CRC is a family of algorithms; these parameters define how both sides compute and compare the value.
  4. D · An attacker can recompute a CRC after modifying the data, so width does not add authenticity.
iotclass.org