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.

Intermediate 4 min readLesson 3 of 15

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:

MediumSignalTypical useRange
Twisted-pair copper (Cat6)Voltage levelsOffice and home Ethernet, 1–10 Gbit/s~100 m
Fibre opticLight pulsesData centres, backbones, undersea cables; 100–800 Gbit/s+Metres to 100s of km
RadioElectromagnetic wavesWi-Fi, 4G/5G, BluetoothMetres 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.

FieldSizePurpose
Destination MAC6 BWho should receive it (ff:ff:ff:ff:ff:ff = broadcast)
Source MAC6 BWho sent it
EtherType2 BWhat's inside: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP
Payload46–1500 BUsually an IP packet
FCS (CRC-32)4 BError detection

Switches: learning where everyone is

A switch forwards frames only to the port where the destination lives. It learns automatically:

  1. A frame arrives on port 3 from MAC A → record "A is on port 3" in the MAC table.
  2. If the destination MAC is in the table, send the frame out that port only.
  3. If it's unknown (or a broadcast), flood it out of every port except the incoming one.
  4. 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:

Host A 192.168.1.10Everyone (broadcast)Host B 192.168.1.20ARP: who has 192.168.1.20? tell 192.168.1.10ARP reply: 192.168.1.20 is at aa:bb:cc:dd:ee:ffEthernet frame to aa:bb:… carrying the IP packet

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.

MethodDetectsUsed in
Parity bitAny single-bit errorMemory, serial lines
Checksum (ones'-complement sum)Most errors; cheap in softwareIP, TCP, UDP headers
CRC (polynomial division)All burst errors up to 32 bits for CRC-32Ethernet, 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.

Key takeaways
  • 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.