Link-layer services and error detection
The link layer moves frames across a single link between neighbouring nodes. Before frames can be shared or switched, they need framing and protection against bit errors.
What the link layer does
The link layer carries a network-layer datagram across one link, from one node to the next, wrapped in a frame. Its services can include framing (marking where frames start and end), addressing with link-layer (MAC) addresses, medium access control on shared links, error detection, and on some links, such as wireless ones, reliable delivery with acknowledgements.
Where it is implemented
The link layer is implemented largely in the network interface controller (NIC), a chip on a host's motherboard or card that combines hardware for framing, error checking, and medium access with a small amount of firmware and driver software. Each NIC has a unique MAC address, assigned by the manufacturer.
Why errors happen
Bits can be flipped by electrical noise, interference, signal fading, or faulty hardware. Error rates are tiny on fibre but much higher on wireless links. Error detection lets receivers discard corrupted frames; error correction lets them repair some errors without retransmission.
Parity and checksums
A single parity bit makes the number of 1s even (or odd), detecting any single-bit error but missing two flipped bits. Two-dimensional parity, arranging bits in a grid with a parity bit per row and column, can locate and correct a single-bit error. Internet checksums, used by IP, TCP, and UDP, are simple sums that are easy to compute in software but relatively weak.
Cyclic redundancy checks
Link layers use cyclic redundancy checks (CRCs), which treat the frame as a large binary polynomial and append the remainder of dividing it by an agreed generator polynomial. Ethernet uses a 32-bit CRC. CRCs detect all burst errors shorter than the CRC length and almost all longer ones, and are very fast in hardware.
Forward error correction
Forward error correction (FEC) adds enough redundancy for receivers to correct errors themselves, avoiding retransmissions, which is valuable on noisy or long-delay links. Hamming codes correct single-bit errors; Reed-Solomon codes protect CDs, QR codes, and DSL; and powerful LDPC and polar codes are used in Wi-Fi and 5G.
Framing
Receivers must find where frames begin and end. Ethernet frames start with a preamble of alternating bits followed by a start-of-frame delimiter, letting receivers synchronise their clocks. Other protocols use special flag patterns with bit or byte stuffing, inserting extra bits or bytes so the flag pattern never appears accidentally inside the data.
Worked example
Even parity on the 7-bit data 1011001: it has four 1s, already even, so the parity bit is 0, giving 10110010. If noise flips the third bit, the receiver sees 10010010 with three 1s: odd, so it detects an error. If noise flips two bits, say giving 10000010 with two 1s, the parity is even again and the error goes unnoticed, which is why CRCs are used on real links.
Key takeaways
The link layer moves frames across a single link, offering framing, MAC addressing, medium access, error detection, and sometimes reliability. It is implemented mostly in NICs, each with a manufacturer-assigned MAC address. Noise and interference flip bits, especially on wireless links. Parity detects single-bit errors; 2D parity can correct one; internet checksums are simple but weak. CRCs, such as Ethernet's 32-bit CRC, detect burst errors very reliably in hardware. FEC codes such as Hamming, Reed-Solomon, LDPC, and polar codes correct errors. Preambles and stuffing mark frame boundaries.
Flashcard
Link-layer unit carrying a datagram
Check your understanding
Why do link layers use CRCs rather than a single parity bit?
