Book 1 · Chapter 2
Communication
B1·2This 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.
For the whole chapter
- Topic pageCommunication
B1·2·T - QuizCommunication
B1·2·Q1 - LabIP addressing & subnets
B1·2·X1 - LabPacket switching
B1·2·X2 - LabParity & checksums
B1·2·X3
§2.1 Networks · Media and LAN hardware · The internet
Short code B1·2·1
- FlashcardsFlashcards §2.1: Network types, models & topologies
B1·2·F1 - FlashcardsFlashcards §2.1: Transmission media, hardware & Ethernet
B1·2·F2 - FlashcardsFlashcards §2.1: Internet, IP addressing & DNS
B1·2·F3 - Past-paper questionsPast-paper questions §2.1 (networks)
- Past-paper questionsPast-paper questions §2.1 (media-and-lan-hardware)
- Past-paper questionsPast-paper questions §2.1 (the-internet)
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")Output
5 devices: 10 links 20 devices: 190 links
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")Output
0.239 seconds
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")Output
33.75 MB
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 SecondOutput
1 waiting 6 2 playing 8 3 playing 5 4 playing 2 5 waiting 3 6 playing 5 7 playing 7 8 playing 9
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(".")))Output
11000000.10101000.00001010.01001101
print(2 ** 32)
print(2 ** 128)Output
4294967296 340282366920938463463374607431768211456
import ipaddress
full = "2001:0db8:004a:0000:0000:0000:0000:0c1a"
address = ipaddress.IPv6Address(full)
print(address.compressed)
print(address.exploded)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
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])Output
192 255 192 168 255 168 10 255 10 77 192 64
host_bits = 32 - 26
print(2 ** host_bits, "addresses,", 2 ** host_bits - 2, "for devices")Output
64 addresses, 62 for devices
import ipaddress
print(ipaddress.ip_interface("192.168.10.150/255.255.255.192").network.network_address)Output
192.168.10.128
import ipaddress
print(ipaddress.ip_interface("192.168.10.45/255.255.255.192").network.network_address)Output
192.168.10.0
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")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
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.


