Peer-to-peer and client-server communication models

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Peer-to-peer and client-server communication models

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. In a client-server model, which device is dedicated to providing data and services to other devices?
A Every device equally
B The server
2. Which communication model lets every device both request and provide data?
A Client-server
B Peer-to-peer
3. A school stores all student files on one central machine that students log in to. Which model is this?
A Client-server
B Peer-to-peer
4. Which statement describes a peer-to-peer network?
A Data and management are distributed across the devices
B All data is controlled from one central server
5. Which model is usually cheaper to set up for a small home network because it needs no dedicated server?
A Peer-to-peer
B Client-server

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1client-server AA communication model where dedicated servers provide data and services, and client devices request them
2peer-to-peer BA communication model where every device can both request and provide data, with no dedicated server
3Centralised model: one dedicated server stores the files and manages user accounts, so it is easier to manage and back up Cmodel = "peer-to-peer"
4Distributed model: each device shares its own files directly with others, so there is no single point of failure but security is harder to control DPeer-to-peer does not need a dedicated server. Each device acts as both client and server and shares directly with other peers.
5A peer-to-peer network needs a dedicated server to share files between devices Emodel = "client-server"
6If the web server in a client-server network fails, the other clients keep providing the web pages FClients do not provide the web pages, the server does. If the single server fails, the service is lost, which is a reliability weakness of client-server.

Definitions

communication model

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______.request("page.html", webServer)
2.
peer.canRequest ← TRUE peer.canProvide ← ____
3.
IF model = "client-server" THEN store(files, ______) ELSE store(files, allPeers)
4.
IF server.online = FALSE THEN clients.canAccess ← _____
5.
FOR EACH ____ IN network peer.share("notes.pdf")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A model ← "client-server"
B server ← "WebServer"
C clients ← ["Ava", "Liam"]
D FOR EACH c IN server DO
E c.request(server)
Question 2
A peers ← ["PC1","PC2","PC3"]
B FOR EACH p IN peers DO
C p.share("song.mp3")
D p.request(server)
E END FOR
Question 3
A model ← "peer-to-peer"
B hasServer ← TRUE
C IF hasServer = FALSE THEN
D OUTPUT "Peers only"
E ENDIF
Question 4
A serverCount ← 0
B IF serverCount > 0 THEN
C OUTPUT "client-server"
D ENDIF
Question 5
A peerA.request("report.docx")
B peerB.receive_request()
C server.send("report.docx")
D peerA.save("report.docx")

Answer Key

Peer-to-peer and client-server communication models
Section A: Quick Questions
Q1
B — The server
Q2
B — Peer-to-peer
Q3
A — Client-server
Q4
A — Data and management are distributed across the devices
Q5
A — Peer-to-peer
Section B: Match the Pairs
Q1
client-server → A communication model where dedicated servers provide data and services, and client devices request them
Q2
peer-to-peer → A communication model where every device can both request and provide data, with no dedicated server
Q3
Centralised model: one dedicated server stores the files and manages user accounts, so it is easier to manage and back up → model = "client-server"
Q4
Distributed model: each device shares its own files directly with others, so there is no single point of failure but security is harder to control → model = "peer-to-peer"
Q5
A peer-to-peer network needs a dedicated server to share files between devices → Peer-to-peer does not need a dedicated server. Each device acts as both client and server and shares directly with other peers.
Q6
If the web server in a client-server network fails, the other clients keep providing the web pages → Clients do not provide the web pages, the server does. If the single server fails, the service is lost, which is a reliability weakness of client-server.
Section C: Definitions
Q1
communication model — How devices share the work of requesting and providing data: client-server uses dedicated servers, while peer-to-peer lets every device do both.
Section D: Fill in the Blanks
Q1
client.request("page.html", webServer)
Q2
peer.canRequest ← TRUE peer.canProvide ← TRUE
Q3
IF model = "client-server" THEN store(files, server) ELSE store(files, allPeers)
Q4
IF server.online = FALSE THEN clients.canAccess ← FALSE
Q5
FOR EACH peer IN network peer.share("notes.pdf")
Section E: Spot the Error
Q1
D — The loop must go through the list of clients, because every client sends a request to the single server. A server is one device, not a list to loop over. It should be: FOR EACH c IN clients DO.
Q2
D — Peer-to-peer has no dedicated server. Each peer requests data from another peer, so the line should be p.request(random(peers)).
Q3
B — A peer-to-peer network has no dedicated server, so every device is equal. hasServer should be FALSE, otherwise the IF check and the output would not match the model.
Q4
A — The client-server model needs at least one dedicated server. With serverCount set to 0 the condition is false and the client-server message never prints. It should be serverCount ← 1.
Q5
C — In peer-to-peer file sharing, the peer that holds the file sends it directly to the requesting peer. There is no dedicated server in this model. The line should be peerB.send("report.docx").