A protocol toolkit
The problem
Write a toolkit that moves messages over an unreliable, chunked byte stream: a framer for messages, an integrity check, and a reliable sender that survives losses, with a simulation that proves it works.
Requirements
- Frame messages with a two-digit length prefix and rebuild them from chunks cut at any place
- Attach a CRC or checksum to every message and discard messages that fail the check
- Simulate a Go-Back-N sender over a link that loses chosen packets and count the transmissions
- Print a short report: messages sent, messages received, damaged, retransmissions
Technologies
- Python 3
- Strings and bytes
- Checksums and CRC
- Simulation with fixed loss lists
Step by step
- Write the framer and test it with the stream cut at every possible position.
- Add a checksum to each message and test it by changing one character.
- Write a Go-Back-N simulation with a window and a list of packets lost the first time.
- Run the full pipeline on 20 messages with some losses and damage, and print the report.
Expected result
A toolkit and a report showing that every message arrives intact and in order even though some packets are lost or damaged.
How it is evaluated
- Framing works for every way of cutting the stream
- Damaged messages are detected and never delivered
- The retransmission count matches a hand calculation
- The simulation is repeatable, with fixed losses and no randomness
Ways to improve it
- Replace Go-Back-N with Selective Repeat and compare the counts
- Add an HMAC so tampering is detected as well as damage
- Add a simple congestion window that halves after each loss