Agree on a message format — quick review
Two friends pass notes across a room through other people's hands.
A protocol is an agreed set of rules. In this unit's card protocol every data card holds, in order, To, From, Piece (a number of a total) and Data (from 1 to 4 characters); a card that breaks the format is not used.
List the fields the protocol requires, in order.
For each data card, check that every field is there.
Check that the fields are in the agreed order: To, From, Piece, Data.
Check the Piece field: a number from 1 up to the total, written as a number of the total.
Check the Data field: at least 1 and no more than 4 characters.
Mark the card as following the protocol only when every check passes.
A card that leaves out the total, Piece 2 instead of Piece 2 of 3, breaks the protocol, and the receiver cannot learn the total from that card. Keep both numbers.
A format that only one side knows is not a protocol. If Ana changes the data length to 5 characters without telling Kai, Kai's checks reject her cards.