IO8: Store-and-forward and edge computing

Lesson 5 of 5 · reading 15–25 minutes; practice and project time is on the module page

The server side: duplicates, gaps and late data

🎯You'll be able to

Store device data so resends don't double-count, gaps are visible, late data lands in the right place, and device health is clear.

🏠The everyday picture

A teacher collecting homework ticks off each roll number once, even if a pupil hands in two copies, and notices who hasn't handed anything in.

📘What it really is

📝A worked example

Input: T07 sends seq 310 to 312. The PUBACK for 311 is lost, so 311 arrives twice. Later, 314 arrives but 313 doesn't.

Steps:

  1. Store with a unique key (device, seq): the second 311 is ignored.
  2. The server sees 313 missing and checks T07's status: dropped count 0, readings waiting 1. So 313 is still on the device.
  3. On the next send 313 arrives, and the gap closes.

Expected output: one copy of each reading, and a gap that's explained instead of a mystery.

🌍Where it's used

📝Case scenario

A water utility's dashboard showed usage spikes every few days. The spikes were resends after lost acknowledgements, counted twice. A unique key on device and sequence number removed them.

🖱️Try it

A device sends readings 1 to 10. Readings 4 and 7 arrive twice, and 9 is missing. Write what the server stores and what it reports. Success: one copy each of 1 to 8 and 10, and a gap at 9.

⚠️Common mistakes

🛠️For your project

The kit's sim/collector.py stores one copy per (device, seq) and counts copies, so Project 2's tests can check resends.

✅Quick check

How does the server ignore a resent reading?

Show the answer

It stores readings with a unique key of device and sequence number, so a second copy isn't added.

Why chart readings by their own time rather than arrival time?

Show the answer

Because a backlog can arrive hours late, and arrival time would put it in the wrong place.

← PreviousEdge computing: deciding on the device
ProLearners Assist