Data Link Layer
How Layer 2 Frames and Polices the Link
Where the physical layer worries only about turning bits into voltages, light, or modulated RF, the data link layer gives those bits meaning. It groups them into frames bounded by a recognizable preamble and a start-of-frame delimiter, attaches source and destination MAC addresses so the right interface accepts the frame, and appends a frame check sequence that lets the receiver decide whether the frame survived the channel intact. Because Layer 2 operates only between directly connected nodes, its addresses are flat and link-local; routing across multiple hops is the job of the network layer above it.
The IEEE 802 family divides the layer into two cooperating sublayers. The Media Access Control (MAC) sublayer decides when a station may transmit, which is the central problem when many nodes share one channel. Wired Ethernet historically used CSMA/CD, sensing the medium and detecting collisions during transmission, but modern full-duplex switched links remove collisions entirely. Wireless 802.11 cannot detect collisions while transmitting, so it uses CSMA/CA with a DIFS idle period, a randomized contention window, and an acknowledgement returned after a SIFS gap. Above MAC, the Logical Link Control (LLC) sublayer presents a uniform, medium-independent interface to the network layer and can optionally provide acknowledged, sequenced delivery.
Reliability at Layer 2 is handled by Automatic Repeat reQuest (ARQ). When an acknowledgement does not arrive within a timeout, the sender retransmits. Stop-and-wait ARQ sends one frame and waits; sliding-window protocols such as Go-Back-N and Selective Repeat keep multiple frames in flight to keep a long, high-rate link efficient. The choice of window size is governed by the bandwidth-delay product of the link.
Frame Check and Throughput Equations
FCS = (M(x) · xr) mod G(x) (CRC-32: r = 32, G(x) = 0x04C11DB7)
Sliding-window efficiency:
η = W / (1 + 2a) for W < 1 + 2a (η = 1 otherwise)
Normalized propagation:
a = tprop / tframe = (d / v) × (R / L)
Useful Layer-2 throughput:
Throughput ≈ η × R × (Lpayload / Lframe) bit/s
Where M(x) = message polynomial, G(x) = generator polynomial, W = window size, a = normalized propagation delay, d = link distance, v ≈ 2 × 108 m/s in copper, R = line rate, L = frame length in bits. Example: a 1500-byte Ethernet frame at R = 1 Gbit/s over 100 m gives tframe ≈ 12 μs, tprop ≈ 0.5 μs, so a ≈ 0.04.
Data Link Layer Across Common Link Types
| Link Standard | Access Method | Address / ID | Frame Check | Typical Max Frame | Layer-2 ACK |
|---|---|---|---|---|---|
| Ethernet (802.3) | CSMA/CD (legacy), full-duplex switched | 48-bit MAC | CRC-32 | 1518 B (9018 B jumbo) | None |
| Wi-Fi (802.11) | CSMA/CA + backoff | 48-bit MAC | CRC-32 | 2304 B (MSDU) | Per-frame ACK |
| LTE / 5G NR | Scheduled (eNB/gNB grants) | RNTI (16-bit) | CRC-24 / CRC-16 | Variable (RLC PDU) | HARQ |
| HDLC / PPP | Point-to-point | Address field | CRC-16 (FCS) | Configurable | ARQ (optional) |
| Zigbee (802.15.4) | CSMA/CA (slotted/unslotted) | 16/64-bit address | CRC-16 | 127 B | Optional ACK |
Frequently Asked Questions
What is the difference between the MAC and LLC sublayers?
IEEE 802 splits Layer 2 in two. The lower MAC sublayer controls when a node may transmit on a shared medium and handles 48-bit addressing, frame delimiting, and the access method (CSMA/CD for legacy Ethernet, CSMA/CA for Wi-Fi). The upper LLC sublayer (IEEE 802.2) gives the network layer a hardware-independent interface, multiplexes protocols, and can offer sequenced, acknowledged service. In switched Ethernet the LLC role is largely vestigial, whereas 802.11 loads the MAC with collision avoidance, RTS/CTS, and per-frame acknowledgement.
How does the data link layer detect transmission errors?
Each frame carries a Frame Check Sequence. Ethernet and Wi-Fi use CRC-32 with generator polynomial 0x04C11DB7: the sender appends the remainder of dividing the frame polynomial by G(x), and a nonzero remainder at the receiver flags corruption. CRC-32 catches all single- and double-bit errors, all odd error counts, all bursts up to 32 bits, and longer bursts with probability 1 minus 2-32. Layer 2 only detects errors and discards bad frames; recovery is left to ARQ retransmission at this layer or above.
Why does Wi-Fi use CSMA/CA instead of CSMA/CD at Layer 2?
A half-duplex radio cannot transmit and listen at once: its own 100 mW to 1 W output swamps the microvolt signal of a distant station, so true collision detection is impossible, and hidden nodes compound the problem. The 802.11 MAC instead avoids collisions, sensing the channel idle for a DIFS, waiting a random backoff, then transmitting, with the receiver returning an ACK after a SIFS gap; optional RTS/CTS reserves the medium. Full-duplex switched Ethernet has no collisions at all, so CSMA/CD is effectively disabled.
How is the data link layer related to the network layer?
Layer 2 moves frames between two directly connected nodes using flat, link-local MAC addresses, while the network layer (Layer 3) moves packets end to end across many hops using hierarchical IP addresses. A router strips the incoming Layer-2 frame, examines the Layer-3 destination, and builds a fresh frame, often with a different MAC address and even a different link technology, for the next hop. Address resolution protocols bridge the two by mapping an IP address to the MAC address on the local segment.