Week 9 · Lesson 4 · 55 minutes

Send the saved report to another computer

Use a simple network model to connect files queues and shared services.

Planned lesson. Follow your teacher’s teaching order.

Source workbook pages: 58.

Resources

Vocabulary

Vocabulary
LAN: A network over a limited local area; client: A program or device that requests a service; server: A program or device that provides a service
55-minute lesson sequence
  1. 0–5 · Retrieve FIFO using three queued requests.
  2. 5–15 · Model client/server and the queue; keep the network bridge ungraded.
  3. 15–40 · Students draw the system, trace the queue and rebuild numbered pieces.
  4. 40–50 · Compare FIFO and LIFO outputs; explain a missing-piece limit.
  5. 50–55 · Collect the queue exit; record network questions for next term.

Try before notes

Which structure serves the oldest waiting request first: a stack or a queue?

Build the idea

This is an introductory, ungraded network bridge. A client requests a service; a server provides one. A LAN connects devices over a limited area. Internet access can connect to distant services but is not required for every local operation.

A FIFO queue serves the oldest waiting request first. Adding to the back and removing from the front models this order. Removing from the back instead gives a stack-like last-in-first-out order.

A numbered-piece model shows why arrival order need not be message order. Store each piece at its labelled position before joining. Real networks require additional protocols; this small simulation does not implement a real transport system.

client --request/report→ server
client ←----reply------- server
queue: front [oldest ... newest] back

See the method

Ungraded network bridge: a kiosk client can ask a file server to store a report. A LAN connects local devices; wider networks connect distant sites. A queue serves R1 before R2 if R1 arrived first. Real networks need more rules than this model.

requests = []
requests.append("R1")
requests.append("R2")
served = requests.pop(0)
print(served, requests)

Predict then reveal

Start queue ["X","Y"]. Add "Z" at the back, then serve one from the front. What is served and what remains?

Reveal reasoning

After adding: ["X","Y","Z"]. Serve X. Remaining queue: ["Y","Z"]. X arrived first, so this is FIFO.

Pieces are 0="GO",1="TO",2="CLASS" and arrive 1,2,0. Reconstruct the message.

Reveal reasoning

Place TO at index 1, CLASS at index 2 and GO at index 0. The ordered list is ["GO","TO","CLASS"]. Joining with spaces gives "GO TO CLASS". Joining arrival order would give the wrong message.

Work one step together

Read the first task. Each learner predicts the first step privately. Compare the method, then complete one intermediate row or one code iteration together. Do not display a finished workbook answer.

Practice

  1. Draw a kiosk client and file server on a school LAN. Label the report and reply arrows. Add a cloud service outside the LAN. Why could internet failure stop cloud access but leave local fan control working?

Your turn

Complete the remaining steps of task 1 alone, then the next tasks. Predict before running code. Save your own evidence before comparing.

Practice

  1. Draw a kiosk client and file server on a school LAN. Label the report and reply arrows. Add a cloud service outside the LAN. Why could internet failure stop cloud access but leave local fan control working?
  2. Build the request-queue model. Add report_A, report_B and report_C. Serve two requests. Print the service order and the remaining queue. Then compare with removing from the end of the list. Which is FIFO?
  3. A toy message has pieces 0="SUN", 1="LIGHT", 2="OK". They arrive 2, 0, 1. Build a list of three empty strings. Put each piece at its numbered position. Join them in order with spaces. What problem would a missing piece create?

Check and explain

Arrival order and logical message order are not always the same.

Point to the first step, row, condition or requirement that supports your answer. If results differ, find the first different state and repair one cause.

Show what you know

Which earlier programming idea helped you model network requests today?

HL challenge when ready

Does a different arrival order mean the message must be read in that order?

Week 9 homework

Show working. Keep code and output. Stop at 25 minutes and mark where you reached.

  1. Complete this homework before Friday 15 January. Trace sum_from([2, 5], 0), using the lesson 9.3 function. Give call indices, base return, final result and total calls.
  2. For a queue initially [A, B, C], serve one item from the front and add D to the back. State the served item and the queue after both actions. Explain FIFO in one sentence.
  3. Prepare your four evidence items for lesson 9.5. Name one item you will explain, the input or question, and the correct output or conclusion. Do not create a long new report.

Source workbook pages: 60.

Weekly homework (Word)

Python practice · two short prompts

Spend about 3 minutes on each during practice time. Predict, run, change one thing, then explain. These prompts do not add homework.

A starter is runnable code to explore or complete. If the playground restores your saved code, the linked starter is selected in Example: use Load example when ready. Download your work before confirming replacement.

Prompt 1

Convert a small report to JSON text and recover it.

Import json (standard library).

Hint and starter code

JSON is a text format for exchanging structured data. This example makes no network request.

# JSON is a text format for exchanging structured data.
import json

report = {"count": 3, "maximum": 29}
message = json.dumps(report)
print(message)
print(json.loads(message))
Open this starter in Python playground →
Prompt 2

Remove a queued message only after a simulated acknowledgement. Test both outcomes.

No imports needed.

Hint and starter code

An acknowledgement is a receiver’s confirmation. Real retry systems also need duplicate handling.

# An acknowledgement is a receiver’s confirmation.
queue = ["report-1", "report-2"]
acknowledged = False
if acknowledged and queue:
    queue.pop(0)
print(queue)
Open this starter in Python playground →