ByteByte CityCity
All lessons
OSI Model

New Network Card, Network Forgets You: MAC Addresses | OSI Layer 2

6:28 Watch on YouTube

You replace a dead network card — same computer, same cable, same wall port — and the network treats the machine like a total stranger. Why? Because Layer 2 never looked at the computer. It looked at the brass plaque. In this episode Professor Flows explains the Data Link layer using Byte City: the brass plaque is the MAC address, the crate is the frame, and the switch-depot is a switch that teaches itself where everyone lives.

You'll learn

Chapters

  1. 0:00The stranger
  2. 0:25The brass plaque: MAC addresses
  3. 1:10The crate: frames and the checksum
  4. 1:49The switch-depot: how a switch learns
  5. 3:06ARP: "Who lives at number twenty?"
  6. 3:36Leaving the street: which plaques go on the new crate
  7. 4:57The whole wrapping order: segment, packet, frame
  8. 5:16The real thing: ipconfig, arp -a, and exam corner
  9. 6:00Recap and next time

The written lesson

The problem: the stranger

A computer's network card dies. You swap in a new one. Same computer, same cable, same port on the wall.

And the network treats it like a total stranger. Its reserved address is gone. The Wi-Fi allow-list won't let it in. Nothing about the computer changed, except the one thing this layer actually looks at. That layer is Layer 2 of the OSI model: the Data Link layer.

The brass plaque: MAC addresses

A brass plaque beside a house door reading A4:BB:6D:4D:5E:6F, with the first half labelled Who built the card and the second half labelled That card's serial number
The brass plaque is the MAC address: twelve hexadecimal characters stamped on the network card.

Layer 1 gives you a road. Layer 2's job is to get data across one street, to exactly the right house.

On its own street a house is not known by the number on its lawn sign. It is known by the brass plaque bolted to the building. That plaque is the MAC address, and it isn't really on the computer. It is on the network card.

A MAC address is twelve characters in hexadecimal. The first six identify who built the card. The last six are that card's serial number. It is stamped at the factory, which is why a new card means a new identity.

One honest footnote: software can override it. Your phone does this on purpose, showing a different made-up plaque to each Wi-Fi network for privacy. The factory plaque is still underneath.

The crate: frames and the seal

A wooden crate on a Byte City street with a red wax seal and a label reading TO 9C:B6:D0:44:7E:20, FROM A4:BB:6D:4D:5E:6F, CONTENTS The Data, under the tags Destination MAC, Source MAC and Seal
The crate is a frame: a destination MAC, a source MAC and a checksum seal.

To cross the street, the data goes into a crate. The real name for the crate is a frame.

On the crateReal nameWhat it is for
The TO plaqueDestination MAC addressThe house on this street the crate is going to
The FROM plaqueSource MAC addressThe house on this street it came from
The contentsThe data being carriedWhatever the layer above handed down
The wax seal, at the very endFrame check sequence (FCS)A checksum that shows whether the crate was damaged on the road

The seal works like this. The sender does some maths on everything in the crate and writes down the answer. The receiver does the same maths. If the answers don't match, something got damaged on the road, and the crate goes straight in the bin.

Notice what Layer 2 doesn't do. It doesn't ask for a replacement. It detects damage; it doesn't repair it. If anyone wants that data sent again, that is the truck's job: TCP, two layers up.

The switch-depot: how a switch learns

The switch-depot building with coloured ribbons running out of its doors and a clipboard headed MAC address table listing three plaques against ribbons 1, 2 and 3
The switch-depot's clipboard is the MAC address table: which plaque is on which ribbon.

Every house on the street connects to one building: the switch-depot. In a real network, that's a switch.

A hub is a roundabout with no signs: everything in is copied out of every exit. The switch-depot is smarter, because it can read plaques. And nobody tells it where anyone lives. It learns.

Every time a crate arrives, the switch-depot reads the FROM plaque and notes which ribbon it came in on. A ribbon is a port. Crate by crate it builds a list: this plaque, that ribbon. That list is the MAC address table.

Now when a crate arrives, the switch-depot checks the TO plaque and sends it down exactly one ribbon. Nobody else on the street ever sees it.

What if the plaque isn't on the list yet? It sends a copy down every ribbon except the one the crate came in on. That is called flooding. The right house answers, and the moment it does, the switch-depot has learned where it lives.

One special plaque means everyone: all Fs, FF:FF:FF:FF:FF:FF. A crate addressed to it rings every doorbell on the street. That is a broadcast, and it stops at the end of the street. Broadcasts don't cross intersections, and an intersection is a router.

ARP: "Who lives at number twenty?"

A Byte City street with every doorbell ringing at once, under a card reading Broadcast, to every doorbell: Who has 192.168.1.20? Tell 192.168.1.10
ARP asks the whole street: who has this IP address? Only the owner answers, with its MAC address.

One problem. Programs know lawn-sign numbers: IP addresses. Crates need plaques. So how does a house learn its neighbour's plaque?

It asks the whole street. It rings every doorbell: "Who lives at number twenty? Tell number ten." Every house hears it. Only number twenty answers: "That's me. Here's my plaque."

That question is ARP, the Address Resolution Protocol. The answer is remembered for a few minutes, so the house isn't ringing doorbells all day.

Leaving the street: which plaques go on the new crate

A diagram of three streets joined by a gate and a router. The crate's FROM and TO plaques show the gate's far side and the next intersection's near side, while the mail bag still reads 192.168.1.10 to 10.0.5.20
The IP addresses on the mail bag never change. The MAC addresses on the crate change at every hop.

What if the data is going to a house across the city?

The crate is not addressed to that far-away house. Plaques only mean something on their own street. So the crate is addressed to the plaque of the gate at the end of the street: the gateway.

At the gate the crate is opened and thrown away. Inside is a mail bag with the real destination's lawn-sign number on it. That bag is untouched. It goes into a brand-new crate, and two new plaques go on:

  • FROM is now the gate's own plaque, the one it wears on its far side, facing the next street.
  • TO is whoever comes next: the next intersection, the next router, on the route.

Your house's plaque is gone. It never leaves your street. At the next intersection it happens again. Only on the very last street does the TO plaque finally become the destination house itself. And the gate learns each next plaque the same way your house did: it rings the doorbells on the next street. ARP.

The lawn-sign number on the bag stays the same for the whole journey, at least until NAT gets involved, and NAT has its own lesson. The plaques on the crate change at every single hop. If you remember one thing from this lesson, make it that.

The whole wrapping order

The data with a TCP tag, a canvas mail bag and a sealed wooden crate in a row, then bits streaming along the road, labelled Segment, Packet, Frame and Bits, under the banner The crate is always outermost
Tag, mail bag, crate, road: segment, packet, frame, bits.

TCP's tag goes on the data first: a segment. Then the mail bag with the lawn-sign numbers: a packet. Then the crate with the plaques: a frame. The crate is always outermost. Then the road carries it as bits.

And the cube truck? It isn't a wrapper at all. It is how TCP behaves: numbered, signed for, redelivered.

The real thing: three commands

On Windows, ipconfig /all shows your plaque. It is labelled Physical Address. arp -a shows every neighbour's plaque your computer has learned. On a switch, show mac address-table is the switch-depot's clipboard: which plaque, which port.

Back to the stranger. The new card had a new plaque, and every list on the network still had the old one. Update the reservation and the allow-list, and the stranger is family again.

For the Network+ exam: a switch gets a frame for a MAC address that isn't in its table. What does it do? It floods it out of every port except the one it came in on. It doesn't drop it, and it doesn't ask the router.

Quick answers

What is a MAC address?

The hardware address of a network card: twelve hexadecimal characters, stamped at the factory. The first six identify the maker and the last six are the card's serial number.

What is the difference between a MAC address and an IP address?

A MAC address identifies a network card and only means something on its own local network. An IP address says where a host is, and it is what gets data across networks.

How does a switch learn MAC addresses?

It reads the source MAC address of every frame that arrives and records which port it came in on. That list is the MAC address table.

What is ARP used for?

Finding the MAC address that belongs to an IP address on the local network. The question goes to everyone as a broadcast and only the owner replies.

Does the MAC address change at every hop?

Yes. Every router throws away the old frame and builds a new one with its own MAC address as the source and the next hop as the destination. The IP addresses inside stay the same.

Key terms

MAC address
—
the hardware address stamped on a network card, used to deliver across one local network.
Frame
—
the Layer 2 wrapper: destination MAC, source MAC, the data, and a checksum at the end.
Frame check sequence (FCS)
—
the checksum that lets the receiver detect a damaged frame.
Switch
—
the Layer 2 device that reads MAC addresses and sends each frame out of one port.
MAC address table
—
the switch's list of which MAC address is on which port.
Flooding
—
sending a frame out of every port except the one it arrived on, because the destination isn't in the table yet.
Broadcast
—
a frame addressed to FF:FF:FF:FF:FF:FF, delivered to everyone on the local network and no further.
ARP
—
the Address Resolution Protocol: the question that turns an IP address into a MAC address.
Next: Can Print, But No Websites? The Network Layer Explained | OSI Layer 3

Quick quiz

Five questions on this lesson. Pick an answer to see why.

  1. 1. A technician replaces a failed network card. Same PC, same cable, same switch port, but the PC no longer gets its DHCP reservation. Why?
  2. 2. How does a switch build its MAC address table?
  3. 3. A packet travels from a host through two routers to a server on another network, with no NAT. Which statement about its addresses is true?
  4. 4. A host at 192.168.1.10 needs the MAC address of 192.168.1.20 on its own network. Which protocol does it use to find it?
  5. 5. A frame arrives and its frame check sequence (FCS) does not match the receiver's calculation. What does Layer 2 do?

Keep learning

Previous

Thumbnail for Slow PC After an Office Move? Physical Layer Explained | OSI Layer 14:59
OSI Model

Slow PC After an Office Move? Physical Layer Explained | OSI Layer 1

The road: copper, glass and radio, and what a dark link light means.

4:59 Watch

Next

Thumbnail for Can Print, But No Websites? The Network Layer Explained | OSI Layer 37:17
OSI Model

Can Print, But No Websites? The Network Layer Explained | OSI Layer 3

The mail bag, the road atlas and the gate at the end of the street.

7:17 Watch

Related

Thumbnail for What Happens When You Click a Link: All 7 OSI Layers in One Trip8:28
OSI Model

What Happens When You Click a Link: All 7 OSI Layers in One Trip

One click, seven floors down, across the city, and back. Every layer in one trip.

8:28 Watch

Related

Thumbnail for Ping Works, Page Won't Load: Ports, TCP and UDP | OSI Layer 49:32
OSI Model

Ping Works, Page Won't Load: Ports, TCP and UDP | OSI Layer 4

Numbered doors, the truck that calls ahead and the bullhorn that doesn't.

9:32 Watch

Exam objectives: CompTIA Network+ N10-009: 1.1 (OSI model), 1.2 (switches), 2.2 (switching features), 5.5 (arp, show mac-address-table).

Byte City is not affiliated with or endorsed by CompTIA.