Network Hardware, Packets and Error Detection
IB Computer Science · Networks
What a packet carries. A message is split into packets, and each packet carries headers added by successive layers: the MAC addresses of the source and next device (layer 2), the IP addresses of the original sender and final destination (layer 3), the port numbers and sequence number of TCP or UDP (layer 4), then the payload — a fragment of the file, page or audio — and finally a checksum or cyclic redundancy check for error detection. Headers are overhead: small packets waste a higher proportion of capacity on headers, while large packets lose more data to a single bit error because the whole packet must be resent. Typical sizes of about 1 500 bytes are a compromise between the two.
Hub, switch, router: each reads one layer. A hub reads nothing; it repeats every incoming signal to every port, so all devices share the medium, collisions occur, and any machine can listen to any traffic — which is why hubs are obsolete. A switch reads the layer-2 MAC address and forwards the frame to the one port where that address was last seen, learning the table automatically; two pairs of machines can talk at full speed simultaneously. A router reads the layer-3 IP address and chooses the next hop between different networks using a routing table; it is the device that connects a home or school network to the internet. A wireless access point is a switch port that uses radio. A modem converts between the digital signal of the network and the form used by the telephone, cable or fibre line. Because each device reads only its own layer's header and ignores the rest, a router need not understand what the payload is — which is why the internet carries kinds of content that did not exist when it was designed.
Media. Copper twisted pair (Ethernet cable) is cheap and easy to install but limited to about 100 m per run and vulnerable to electrical interference. Fibre optic carries light, so it has far higher bandwidth, runs for kilometres, and is immune to interference and much harder to tap, but it costs more and needs skilled installation. Wireless needs no cabling and supports mobility, but shares its channel among all users in range, is slowed by walls and distance, and can be received by anyone nearby, which turns security into an encryption problem. Choosing a medium is a question of distance, required speed, mobility, interference and budget.
Detecting errors. Noise flips bits in transit, so receivers check. A parity bit makes the number of 1s in a byte even (or odd); it catches any single-bit error but misses two flipped bits, and it cannot say which bit is wrong. A checksum adds the values of the data and sends the total; the receiver recalculates and compares. A cyclic redundancy check uses polynomial division and catches burst errors that checksums miss. All of these detect; correction is done by asking for retransmission, which is what TCP does using acknowledgements and sequence numbers. Detection costs extra bits per packet — another reason header overhead matters.
Worked example: Example 1 — choosing devices and transmission media for a school with two buildings
A school has two buildings 400 m apart, each with 30 classrooms needing wired network and Wi-Fi, and a server room in building A connected to the internet. Propose devices and transmission media, explaining each choice.
Solution
Linking the two buildings — fiber-optic cable. 400 m exceeds the 100 m limit of copper cable, and an outdoor route near power lines is prone to interference; fiber covers this distance, is immune to interference, and has high bandwidth to carry all of building B's traffic to the server and the internet in building A. A point-to-point wireless link is a cheaper backup option but depends on weather and line of sight.
Inside each building — a switch per floor and copper cable. One switch per floor, connected to the sockets in the classrooms by twisted-pair copper cable because the runs are short, cheap and easy to install. Switches, not hubs, so that each room has its own bandwidth and one room's machines cannot hear another room's traffic. The floor switches connect back to a central switch in the building by fiber or high-speed copper cable.
Wi-Fi — an access point every few rooms. Each access point is a switch port that uses radio, connected by cable to the floor switch. Place one for every two to three rooms because walls attenuate the signal and because all users within range share one channel — one access point for a whole floor would be congested when three classes use it at once. WPA2 or WPA3 encryption is mandatory, because anyone nearby can receive the signal.
Out to the internet — a router and firewall in building A. The router is the only device that reads IP addresses and chooses the route between the school network and the provider's network; the firewall beside it filters traffic. Put the server in its own subnet so student traffic does not pass through the server.
Marking point. Each choice is justified by a specific constraint — distance, interference, walls, channel sharing, network boundary — rather than by a vague better. That is how examiners tell understanding apart from memorizing device names.
Worked example: Example 2 — parity check and its limits
A system uses an even parity bit. The received byte is 1011 0110 1 (the last bit is the parity bit). (a) Is there an error? (b) If the original byte was 1011 0111 1 and two bits were flipped on the way, can the receiver detect it? (c) Why does TCP use a checksum rather than parity, and why is detecting errors still not enough?
Solution
(a) Check. Count the 1 bits in the data 1011 0110: there are 5 ones. The parity bit is 1, for a total of 6 ones — even. By the even rule, this byte is valid, so no error is detected. Note: valid by parity does not mean correct; it only means there is no odd number of bit errors.
(b) Two bits flipped. The original byte 1011 0111 has 6 ones, and the parity bit 1 gives a total of 7 — but 7 is odd, so the original byte was already wrong by the even rule; the question shows candidates must check the assumption first. Suppose the original is actually 1011 0111 with parity bit 0 (total 6, even). If two bits flip, for example bit 8 from 1 to 0 and bit 5 from 0 to 1, the data becomes 1011 1110, still 6 ones, and with parity bit 0 the total is still even — the receiver cannot detect it. Parity catches every odd number of bit errors and misses every even number; it also does not know which bit is wrong, so it cannot correct.
(c) Why a checksum, and why it is still not enough. Real errors on a transmission line are usually bursts — several adjacent bits corrupted by one noise pulse — and a burst easily contains an even number of bits, so parity is almost useless. A checksum adds all the data into a 16-bit sum, so the probability that a burst of errors leaves the sum unchanged is very small; the cyclic redundancy check at layer 2 is even better against burst errors. But both only detect: the receiver knows the packet is corrupted without knowing what the correct content is. So TCP also needs sequence numbers and acknowledgments — a corrupted packet is dropped, no acknowledgment is sent, the sender times out and resends. Detection plus retransmission is what makes transmission reliable; detection alone only tells you that you have lost data.
Common mistake
Trap 1 — saying a switch and a router do the same job. A switch reads the MAC address and forwards within one network; a router reads the IP address and chooses the path between networks.Trap 2 — treating a parity bit as error correction. Parity only detects an odd number of bit errors, misses an even number, and does not know which bit is wrong; correcting is done by retransmission.
Trap 3 — choosing a medium with the word better. You must state the constraint: the 100 m limit of copper cable, interference, walls, wireless channel sharing.