hop 5 of 32 · 5 min
Frames, MAC addresses and switches
The link layer moves a frame from one device to the next device on the same wire. That is all. It has no idea the internet exists.
Why a MAC address as well as an IP
They answer different questions.
IP is routable: it says which network you are on, so routers worldwide can work out a path. It changes when you move networks.
MAC is local: it says which card on this segment should pick the frame up. It is burned in and never routes anywhere.
When you send to a distant server, the IP header carries the server's address the whole way. The MAC address is rewritten at every hop to name the next device. ARP is what maps one to the other on each link.
Hub versus switch
A hub repeats every bit to every port. All machines share the bandwidth and one collision domain.
A switch reads the destination MAC and forwards to one port. It learns which port each machine is on by noting the source of every frame it sees. The one exception is a destination it has not learned yet, which it floods to every port, after which the reply teaches it.
Detecting damage
A frame carries a checksum so the receiver can tell whether it arrived intact.
Parity catches an odd number of flipped bits and misses an even number. Checksum adds the words and sends the sum. CRC treats the frame as a polynomial and divides: it catches every burst error shorter than the check value, which is why every real network uses it.