Skip to content
Book 1: Theory Fundamentals

Book 1 · Chapter 2

Communication

§2.1Core · ≈ 12.5 m · ↘B1·2

This chapter is in the ebook.

Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.

Open in the ebook

For the whole chapter

§2.1 Networks · Media and LAN hardware · The internet

Short code B1·2·1

Why connect computers?

Short code B1·2·10

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

LANs and WANs

Short code B1·2·11

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Client-server and peer-to-peer

Short code B1·2·12

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Thin clients and thick clients

Short code B1·2·13

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Bus and star topologies

Short code B1·2·14

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Mesh, hybrid, and choosing a topology

Short code B1·2·15

for n in [5, 20]:
    print(n, "devices:", n * (n - 1) // 2, "links")
Links in a full mesh of n devices, n(n − 1)/2.

Output

5 devices: 10 links
20 devices: 190 links
Run and checked before printing

Cloud computing

Short code B1·2·16

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Wired and wireless media

Short code B1·2·17

distance_km = 2 * 35786     # up to the satellite and back down
speed_km_s = 299792        # speed of light in km per second
print(round(distance_km / speed_km_s, 3), "seconds")
Up to the satellite and back down, at the speed of light. Notice the answer is in seconds, not milliseconds.

Output

0.239 seconds
Run and checked before printing

Connecting devices: NIC, WNIC, WAP

Short code B1·2·18

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Switches, servers, repeaters and bridges

Short code B1·2·19

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

The router

Short code B1·2·20

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Ethernet and CSMA/CD

Short code B1·2·21

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Bit streaming

Short code B1·2·22

bits = 4.5 * 1_000_000 * 60      # 4.5 Mbps for 60 seconds
print(bits / 8 / 1_000_000, "MB")
One minute of a 4.5 Mbps stream: bits per second × seconds, then ÷ 8 for bytes.

Output

33.75 MB
Run and checked before printing
DECLARE Arrive : ARRAY[1:8] OF INTEGER
DECLARE Buffer : INTEGER
DECLARE Second : INTEGER
DECLARE Playing : BOOLEAN
Arrive[1] ← 6
Arrive[2] ← 6
Arrive[3] ← 1
Arrive[4] ← 1
Arrive[5] ← 1
Arrive[6] ← 6
Arrive[7] ← 6
Arrive[8] ← 6
Buffer ← 0
Playing ← FALSE
FOR Second ← 1 TO 8
   Buffer ← Buffer + Arrive[Second]
   IF Buffer >= 8 THEN
      Playing ← TRUE
   ENDIF
   IF Playing = TRUE AND Buffer >= 4 THEN
      Buffer ← Buffer - 4
      OUTPUT Second, " playing ", Buffer
   ELSE
      Playing ← FALSE
      OUTPUT Second, " waiting ", Buffer
   ENDIF
NEXT Second
The whole buffering model from the bit-streaming spread: the video uses 4 Mbit a second and starts once 8 Mbit are buffered.

Output

1 waiting 6
2 playing 8
3 playing 5
4 playing 2
5 waiting 3
6 playing 5
7 playing 7
8 playing 9
Run and checked before printing

The internet and the World Wide Web

Short code B1·2·23

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Hardware that carries the internet

Short code B1·2·24

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

IP addresses: IPv4 and IPv6

Short code B1·2·25

ip = "192.168.10.77"
print(".".join(format(int(octet), "08b") for octet in ip.split(".")))
Each of the four denary numbers is one byte. Notice the leading zeros: 10 is 00001010, so every group stays 8 bits.

Output

11000000.10101000.00001010.01001101
Run and checked before printing
print(2 ** 32)
print(2 ** 128)
Number of different IPv4 and IPv6 addresses: 2 to the power of the number of bits.

Output

4294967296
340282366920938463463374607431768211456
Run and checked before printing
import ipaddress
full = "2001:0db8:004a:0000:0000:0000:0000:0c1a"
address = ipaddress.IPv6Address(full)
print(address.compressed)
print(address.exploded)
Python's ipaddress module applies both rules. The first line is the shortest form; the second puts every zero back.

Output

2001:db8:4a::c1a
2001:0db8:004a:0000:0000:0000:0000:0c1a
Run and checked before printing

Subnetting

Short code B1·2·26

ip   = [192, 168, 10, 77]
mask = [255, 255, 255, 192]
for i in range(4):
    print(ip[i], mask[i], ip[i] & mask[i])
The subnetting trace, run: each address octet ANDed with the mask octet.

Output

192 255 192
168 255 168
10 255 10
77 192 64
Run and checked before printing
host_bits = 32 - 26
print(2 ** host_bits, "addresses,", 2 ** host_bits - 2, "for devices")
A /26 subnet (26 network bits) leaves 6 host bits.

Output

64 addresses, 62 for devices
Run and checked before printing
import ipaddress
print(ipaddress.ip_interface("192.168.10.150/255.255.255.192").network.network_address)
The network ID of the Mark Ladder's address, 192.168.10.150 with mask 255.255.255.192.

Output

192.168.10.128
Run and checked before printing
import ipaddress
print(ipaddress.ip_interface("192.168.10.45/255.255.255.192").network.network_address)
The faded twin: 192.168.10.45 with mask 255.255.255.192.

Output

192.168.10.0
Run and checked before printing

Public, private, static and dynamic addresses

Short code B1·2·27

def is_private(ip):
    a, b = [int(x) for x in ip.split(".")[:2]]
    return a == 10 or (a == 172 and 16 <= b <= 31) or (a == 192 and b == 168)

for ip in ["192.168.10.77", "203.0.113.25", "172.20.4.9", "172.40.1.1", "10.0.0.8"]:
    print(ip, "private" if is_private(ip) else "public")
Sorting addresses by the three private ranges. Notice 172.40.1.1: the first number is 172, but the second is outside 16–31, so it is public.

Output

192.168.10.77 private
203.0.113.25 public
172.20.4.9 private
172.40.1.1 public
10.0.0.8 private
Run and checked before printing

URLs and the DNS

Short code B1·2·28

Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.

Workbook 1: Communication

Short code W1·2 · Theory Fundamentals Workbook

The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.

Ask Z about Communication
Buy ZAK's books — WhatsApp the books desk: Buy the booksPrint or ebook