Physical & Data Link Layers
Signals and media, Ethernet frames, MAC addresses, switches and how they learn, ARP, VLANs, Wi-Fi, and error detection with CRC.
The bottom two layers get bits from one device to the next device over a single link: a cable, a fibre or a radio channel. Everything above relies on them.
Physical layer
The physical layer turns bits into signals and back:
| Medium | Signal | Typical use | Range |
|---|---|---|---|
| Twisted-pair copper (Cat6) | Voltage levels | Office and home Ethernet, 1–10 Gbit/s | ~100 m |
| Fibre optic | Light pulses | Data centres, backbones, undersea cables; 100–800 Gbit/s+ | Metres to 100s of km |
| Radio | Electromagnetic waves | Wi-Fi, 4G/5G, Bluetooth | Metres to kilometres |
Key concepts: bandwidth (bits per second the link can carry), encoding schemes that keep sender and receiver clocks synchronised, and noise, which limits capacity (the Shannon limit).
Ethernet and MAC addresses
Every network interface has a 48-bit MAC address, written 3c:22:fb:9a:10:4e. The first half identifies the manufacturer. MAC addresses only matter on the local link: they're rewritten at every router hop, while IP addresses stay the same end to end.
| Field | Size | Purpose |
|---|---|---|
| Destination MAC | 6 B | Who should receive it (ff:ff:ff:ff:ff:ff = broadcast) |
| Source MAC | 6 B | Who sent it |
| EtherType | 2 B | What's inside: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP |
| Payload | 46–1500 B | Usually an IP packet |
| FCS (CRC-32) | 4 B | Error detection |
Switches: learning where everyone is
A switch forwards frames only to the port where the destination lives. It learns automatically:
- A frame arrives on port 3 from MAC A → record "A is on port 3" in the MAC table.
- If the destination MAC is in the table, send the frame out that port only.
- If it's unknown (or a broadcast), flood it out of every port except the incoming one.
- Entries expire after a few minutes so moved devices are re-learned.
Loops in switched networks would make broadcasts circulate forever (a broadcast storm), so switches run the Spanning Tree Protocol to disable redundant links until they're needed.
ARP: from IP to MAC
To send an IP packet to 192.168.1.20 on the local network, a host needs that machine's MAC address. ARP asks:
The answer is cached (ip neigh, arp -a). For destinations outside the local subnet, the host ARPs for the default gateway (the router) instead and sends the frame to it.
VLANs
A VLAN splits one physical switch into several isolated virtual networks, for example separating guest Wi-Fi from office machines. Frames carry an 802.1Q tag (a 12-bit VLAN ID) on links between switches (trunks). Traffic between VLANs must go through a router or firewall.
Wi-Fi (802.11)
Wi-Fi works like Ethernet over radio, with extra challenges:
- The medium is shared, and a station can't hear collisions while transmitting. So instead of detecting collisions (Ethernet's old CSMA/CD), Wi-Fi tries to avoid them (CSMA/CA): listen, wait a random backoff, transmit, and expect an acknowledgement.
- Hidden terminals: two laptops that can't hear each other both talk to the access point; RTS/CTS handshakes help.
- Security: WPA3 (or WPA2 at minimum) encrypts the link.
- Wi-Fi 6/6E/7 add OFDMA, MU-MIMO and the 6 GHz band to serve many devices efficiently.
Error detection
Bits get flipped by noise. The link layer detects corrupted frames and drops them; recovery, if any, is TCP's job higher up.
| Method | Detects | Used in |
|---|---|---|
| Parity bit | Any single-bit error | Memory, serial lines |
| Checksum (ones'-complement sum) | Most errors; cheap in software | IP, TCP, UDP headers |
| CRC (polynomial division) | All burst errors up to 32 bits for CRC-32 | Ethernet, Wi-Fi, storage, zip files |
Error-correcting codes (Hamming, Reed–Solomon, LDPC) add enough redundancy to fix errors without retransmission; they're used in Wi-Fi, 5G, SSDs, ECC RAM and QR codes.
- The physical layer moves bits as signals over copper, fibre or radio.
- Ethernet frames carry MAC addresses, an EtherType and a CRC; MACs change at every hop.
- Switches learn MAC → port mappings and flood unknown destinations; STP prevents loops.
- ARP maps IPs to MACs on the local network (and is spoofable).
- VLANs segment networks; Wi-Fi uses CSMA/CA; CRCs detect corrupted frames.