Quarry School

Agree on a message format

Subject: Computing
Level 1 · FoundationsAbout 5 min read2 new terms
How this was estimated

Programmatic estimate. Rung levels, worked steps, prerequisites, terms and sentence length contribute to this level. It describes the lesson, not your ability.

Reading counts the whole lesson, including folded explanations, at 180 words a minute. Practice allows two minutes per item. These are planning assumptions; take the time you need.

AI estimate unavailable.

Path to here

Open the unit’s lesson list to follow the lesson order.

    Leans on

    Quick review (2 minutes)

    In plain words

    Two friends pass notes across a room through other people's hands.

    Rule

    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.

    Step

    1. List the fields the protocol requires, in order.

    2. For each data card, check that every field is there.

    3. Check that the fields are in the agreed order: To, From, Piece, Data.

    4. Check the Piece field: a number from 1 up to the total, written as a number of the total.

    5. Check the Data field: at least 1 and no more than 4 characters.

    6. Mark the card as following the protocol only when every check passes.

    Trap

    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.

    1 In plain words

    Two friends pass notes across a room through other people's hands. Everyone involved agrees first on how a note is written, so that each person who picks one up knows who it is for.

    A protocol is an agreed set of rules for how a system behaves. The internet runs on protocols that anyone may use, which lets new devices join it.

    This unit uses an invented paper protocol, the card protocol. Every data card carries four fields in this order (acknowledgment cards, in a later lesson, have a short form of their own): To, the receiver's name; From, the sender's name; Piece, written as a number of a total, such as 2 of 3; and Data, from 1 to 4 characters of the message. A card that lacks a field, or holds no data or more than 4 characters of it, breaks the protocol. The fields are this unit's own choice; real packets also carry their origin and destination.

    Remember one sentence: a protocol is the rules both sides agreed on before the first message. To look it up, see essential knowledge CSN-1.B.3 in the AP Computer Science Principles Course and Exam Description.

    2 Picture it

    FieldExampleTells readerToKaiwho receives itFromAnawho sent itPiece2 of 3its placeData-AT-the content

    A table of the four fields of one card. To is Kai, who receives it. From is Ana, who sent it. Piece is 2 of 3, its place in the message. Data is -AT-, the content. The Piece row is marked.

    The four fields of a data card in this unit's card protocol

    3 Why

    A receiver can act only on what the format promises. The To field lets a card be passed on toward the right person; the Piece field lets the pieces be put back in order and tells the receiver how many to expect. The AP course description says the same of internet packets: they carry data used for routing them and for putting the data back together.

    Even a protocol that does not promise delivery has a formal structure: the Field Guide notes that UDP packets still carry their destination, their origin and their size.

    Both sides must hold the same rules. A sender who writes the piece number last, or a receiver who expects data of 5 characters, cannot rely on the other side reading the card as it was meant.

    4 The rule

    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.

    5 How

    1. List the fields the protocol requires, in order.
    2. For each data card, check that every field is there.
    3. Check that the fields are in the agreed order: To, From, Piece, Data.
    4. Check the Piece field: a number from 1 up to the total, written as a number of the total.
    5. Check the Data field: at least 1 and no more than 4 characters.
    6. Mark the card as following the protocol only when every check passes.

    6 Trace

    Check three data cards against this unit's card protocol
    CardProblemFollows the protocol?Explanation
    To Kai, From Ana, Piece 1 of 3, Data MEETnoneyesAll four fields, a valid piece number and 4 characters of data.
    To Kai, From Ana, Data -AT-no Piece fieldnoWithout a piece number the receiver cannot place it.
    To Kai, From Ana, Piece 3 of 3, Data NOON.5 characters of datanoThe data field holds at most 4 characters.

    7 The trap

    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.

    Quick checks

    Quick check 1 of 2

    A card reads To Kai, From Ana, Piece 2, Data NOON. Which rule of the card protocol does it break, and what can Kai not tell from it?

    Show the steps and the answer
    Answer

    Its Piece field has no total, so Kai cannot tell how many pieces the message has.

    Why: The protocol writes a piece as a number of a total, such as 2 of 3. Without the total, Kai cannot know when every piece has arrived.

    Source: University of Canterbury Computer Science Education Research Group, Computer Science Field Guide: Network Communication Protocols, 16.3 Transport layer protocols - TCP, UDP

    Quick check 2 of 2

    In one sentence, what is a protocol?

    Show the steps and the answer
    Answer

    An agreed set of rules that specifies how a system behaves.

    Why: The AP course description defines a protocol that way; the card protocol is one, agreed by sender and receiver.

    Source: College Board, AP Computer Science Principles Course and Exam Description

    Sources

    1. AP Computer Science Principles Course and Exam Description. College Board. All rights reserved. Read 2 Dec 2026.
    2. Computer Science Field Guide: Network Communication Protocols, 16.3 Transport layer protocols - TCP, UDP. University of Canterbury Computer Science Education Research Group. CC BY-SA 4.0. Read 2 Dec 2026.