← All system designs

Link Layer

Framing, error detection, medium access (CSMA family), Ethernet, Wi-Fi, switches, VLANs.

7 items 3 Foundational 4 Intermediate

The link layer is the last layer between you and the wire. Ethernet is the dominant wired link; Wi-Fi is the dominant wireless link; both share the same medium-access ancestry (CSMA family) even though they handle collisions differently (CD for Ethernet, CA for Wi-Fi). The medium-access story has two parents — static allocation (TDMA / FDMA / CDMA, still the right answer for cellular and satellite) and stochastic access (ALOHA → slotted ALOHA → CSMA), which the rest of the topic walks in order.

Most backend engineers don't write link-layer code, but they should know enough to read tcpdump output, understand how a switch differs from a router, and reason about VLANs when the ops team mentions them.

Key concepts

  • The link layer frames bits into packets and detects errors with CRC / FCS
  • Static MAC (TDMA / FDMA / CDMA) pre-allocates the channel — right for cellular and satellite
  • Stochastic MAC (ALOHA / slotted ALOHA / CSMA family) takes turns by collision detection
  • Medium access matters when the link is shared (Wi-Fi, classic Ethernet hubs)
  • Switches forward based on MAC addresses; routers forward based on IP
  • VLANs let one physical switch host multiple logical broadcast domains
  • Wi-Fi has different security generations (WEP / WPA / WPA2 / WPA3) — pick the latest

Reference template

// Reading an Ethernet frame
1. Preamble + SFD       (clock sync, ignored by upper layers)
2. Destination MAC      (who's this for?)
3. Source MAC           (who sent it?)
4. EtherType / Length   (what protocol is the payload?)
5. Payload              (often an IP datagram)
6. FCS                  (CRC-32; if mismatched, drop)

Adapt to your problem; the structure is the load-bearing part.

Common pitfalls

  • Confusing a switch (L2, forwards by MAC) with a router (L3, forwards by IP)
  • Treating Wi-Fi as 'wireless Ethernet' — the MAC layer differs significantly
  • Forgetting VLAN tag (802.1Q) when capturing on a trunk port
  • Assuming a working physical link guarantees a working IP path

Related topics

Items (7)

  • The Data Link Layer

    Framing, error detection, and medium access — what the link layer adds on top of raw signal.

    Concept Foundational
  • Static Medium Access — TDMA, FDMA, CDMA

    Pre-allocated time, frequency, or code slots. The schemes mobile and satellite links rely on, and why static beats stochastic for them.

    Concept Intermediate
  • ALOHA and Slotted ALOHA

    The original stochastic medium-access protocol from 1971 Hawaii, the throughput math (18% and 37%), and what slotting bought.

    Concept Foundational
  • Medium Access Control — CSMA, CSMA/CD, CSMA/CA

    Stochastic medium access: listen, defer, transmit, detect collisions. The mechanism behind classic Ethernet and Wi-Fi.

    Building Block Intermediate
  • Ethernet — Frame Format, Switches, VLANs

    Preamble + dst + src + EtherType + payload + FCS; the switch fabric; VLAN tagging (802.1Q); the spanning tree.

    Building Block Foundational
  • Spanning Tree Protocol (STP)

    How a switched LAN avoids loops — BPDUs, root-bridge election, port roles, blocked links — and why RSTP and MSTP exist.

    Building Block Intermediate
  • Wi-Fi (802.11) Basics

    PHY layers (a/b/g/n/ac/ax/be), CSMA/CA, association, hidden terminals, RTS/CTS, the security generations (WEP→WPA→WPA3).

    Building Block Intermediate
Search ESC

Keyboard shortcuts

Shortcuts are disabled while typing in inputs.