The Quiet Message Window

Grade 4 Scratch 3.0 Simulation first The Digital Handshake
Simulation lab
Tool: Scratch 3.0
Open Scratch ↗
Simulator preview

Follow instruction sequences to guide the character to the goal.

📁 Tools ▴
  • Web browser (Chrome, Edge, Firefox)
  • Internet connection
  • Scratch 3.0 online editor

🔧 Build Your Digital Handshake System

1 Create two sprites: Nurse Station (Sender) and Central Pharmacy (Receiver).
2 Create a shared variable 'channel_ready' initialized to 0 (disconnected).
3 Program the sender to transmit a 'ping_request' broadcast and wait for a reply.
4 Program the receiver to answer with 'ack_ready', completing the handshake before sending data!
🧩 Block plan / Starter code ▴
// Sender Script (Nurse Station)
when [space v] key pressed
say [Checking if Pharmacy is open...] for (1) seconds
set [channel_ready v] to [0]
broadcast [request_connection v]
wait until <(channel_ready) = [1]>
say [Handshake confirmed! Transmitting order: 5 Amoxil.]
play sound [Chime v]

// Receiver Script (Pharmacy)
when I receive [request_connection v]
wait (0.8) seconds // Simulate system processing
set [channel_ready v] to [1]
say [Pharmacy online: Ready to receive prescription.]

The sender pauses until channel_ready equals 1, preventing lost data transmissions.

⚗️ Test your model

Test Condition / ActionExpected Result
Press Space (Handshake)Sender says 'Checking if Pharmacy is open' and sends request
Pharmacy answerschannel_ready switches to 1; confirmation chime sounds
Prescription SentData transmits only after confirmed connection
⚑ Try a challenge

Simulate a 'Pharmacy Closed' state where the receiver does not answer, and sender times out after 3 seconds!

❓ Quick check
Why does the sender in our project wait for the receiver to signal readiness before transmitting the message?

📖 Our Story & Concepts

Imagine shouting a secret message across a noisy playground when your friend isn't listening. Your words disappear in the wind! In healthcare, banking, and space travel, sending data when the receiver is asleep or busy can cause disastrous errors.

To solve this, computers use a digital handshake: 1. Hello, are you ready? → 2. Yes, I am ready! → 3. Great, here is the data. This protocol ensures zero dropped messages and bulletproof reliability.

</> Full Annotated Code Walkthrough

// Complete Protocol Script with Timeout Protection
when [space v] key pressed
set [channel_ready v] to [0]
set [timeout_timer v] to [3]
broadcast [ping_receiver v]
say [Initiating handshake...] for (0.5) seconds

repeat until <(channel_ready) = [1]> or <(timeout_timer) = [0]>
    wait (1) seconds
    change [timeout_timer v] by (-1)
end

if <(channel_ready) = [1]> then
    say [Handshake successful! Transmitting packet.]
    play sound [Magic v]
else
    say [TIMEOUT ERROR: Receiver unreachable. Message aborted.]
    play sound [Oops v]
end

The sender pauses until channel_ready equals 1, preventing lost data transmissions.

▷ Expected Results & Troubleshooting

Test Condition / ActionExpected Result
Press Space (Handshake)Sender says 'Checking if Pharmacy is open' and sends request
Pharmacy answerschannel_ready switches to 1; confirmation chime sounds
Prescription SentData transmits only after confirmed connection

⚑ Extension Challenges & Blueprints

⚑ Extension Challenges
  • Level 1: Add a 3-way handshake: Sender Pings -> Receiver Acks -> Sender Confirms Receipt.
  • Level 2: Display an animated signal antenna with green waves during active connection.
  • Level 3: Add an error log list that records every failed handshake attempt.

❓ Check Your Understanding

Question 1: Why does the sender in our project wait for the receiver to signal readiness before transmitting the message?

Question 2: What is the technical term for the agreement sequence where two devices say 'I am ready' and 'I am sending'?

Question 3: If the receiver is busy (is_ready = 0) and the sender sends a note, where does the note go?

Question 4: What changes the receiver's state to 'Ready' in our Scratch model?

Feedback appears after you check your answer.