Source: https://mokxi.com/teachers/plans/protocol-design
Updated: 2026-11-19

Lesson plan

# Design a protocol lesson plan

A deep-sea probe and its surface buoy, two Unos on a noisy serial link: framing, byte stuffing, CRC-16, acks and retries, versioning, binary against text, and a dive log that crosses a storm without losing a single reading.

4 chapters, 7 lessons, about 6 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Start bytes, lengths, flags, and the escape that keeps a flag a flag.
- A CRC to catch damage, and acks and retries to repair it.
- Versions, message types, and choosing between binary and text.
- Two boards that never lose a message, through a storm.

### Materials for the whole unit

- Arduino Uno R3 x 2
- Half breadboard
- LED x 2
- Resistor x 2
- Slide switch

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 30 min

## Bytes into messages

Start bytes, lengths, flags, and the escape that keeps a flag a flag.

Lesson | Time | What students do

Framing A serial link carries bytes, not messages. A start byte and a length turn the stream into frames, a three-state parser finds them, one lost byte swallows two readings, and a silence timeout gets them back. | 45 min

- Run it: a probe and a buoy
- Bytes, not messages
- Lose one byte
- Why the parser could not know
- Time out a half frame

Escaping Frames that end on a flag byte resynchronize by themselves, until the data contains the flag. At 125 and 126 meters the frames fall apart; byte stuffing with a 0x7D escape, as HDLC and PPP do it, puts them back together. | 45 min

- Run it: a flag at the end
- Watch it descend
- 126 meters
- Turn on byte stuffing
- The price of stuffing

### Materials

- Arduino Uno R3 x 2
- Half breadboard
- LED x 2
- Resistor x 2
- Slide switch

### Check for understanding

Each student finishes "Escaping" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The price of stuffing".

Chapter 2. About 1 h 50 min

## Surviving the noise

A CRC to catch damage, and acks and retries to repair it.

Lesson | Time | What students do

Catching damage with a CRC A CRC-16 over every frame, computed a bit at a time and checked against the standard’s check value: the storm flips one bit, the buoy catches it every time, and with the check switched off the same bit becomes a believable wrong depth. | 55 min

- Run it: a CRC on every frame
- A CRC you can check
- Flip a bit
- The bad frame lamp
- Why not just add the bytes up?
- Switch the check off

Acks and retries Stop-and-wait: every good frame is acked by its sequence number, a missing ack means send it again, a lost ack makes a duplicate the buoy must recognize, and with no retries the readings are simply gone. | 55 min

- Run it: every frame acked
- Stop and wait
- Retry
- The ack that never came
- No second chances
- Choosing the numbers

### Materials

- Arduino Uno R3 x 2
- Half breadboard
- LED
- Resistor
- Slide switch

### Check for understanding

Each student finishes "Acks and retries" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Choosing the numbers".

Chapter 3. About 1 h 40 min

## Protocols that last

Versions, message types, and choosing between binary and text.

Lesson | Time | What students do

Versioning A buoy that has been at sea for two years meets a new probe: a version in every frame, a hello, message types skipped by their length, and new fields only ever on the end, so old and new keep talking. | 45 min

- Run it: hello
- A header that describes itself
- A type it has never heard of
- Upgrade the probe
- The rules for a protocol that lasts

Binary or text The same reading as an NMEA-style text sentence with an XOR checksum, and as a 9-byte binary frame with a CRC: twice the bytes against a line you can read, and ten times the parsing time against a format you can type. | 55 min

- Run it: a sentence
- The NMEA checksum
- Storm on the text
- What text costs
- Go binary
- Choosing

### Materials

- Arduino Uno R3 x 2
- Half breadboard
- LED x 2
- Resistor x 2
- Slide switch

### Check for understanding

Each student finishes "Binary or text" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Choosing".

Chapter 4. About 55 min

## Boss project

Two boards that never lose a message, through a storm.

Lesson | Time | What students do

Boss: never lose a message The probe surfaces and uploads its 20-reading dive log through a storm: flags and byte stuffing, a version and type in every frame, CRC-16, acks, retries with a growing timeout, duplicate detection, and a final count that proves nothing was lost. | 55 min

- Run it: a calm sea
- The storm
- Count the cost
- The buoy at work
- A longer dive
- Write the spec

### Materials

- Arduino Uno R3 x 2
- Half breadboard
- LED x 2
- Resistor x 2
- Slide switch

### Check for understanding

Each student finishes "Boss: never lose a message" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Write the spec".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
