A switch doesn’t magically know where every device lives. It learns, by watching traffic and using the source MAC address in each frame to build a small internal record called a MAC address table.
The MAC Address Table Does the Heavy Lifting
Every Ethernet device has a MAC address, a hardware level address for the network interface. The switch stores these along with the port it last saw them on.
Laptop with a certain MAC sends a frame through port 4, the switch notes that address as living on port 4, for now. That last part matters, devices move between ports, cables get unplugged, the switch never treats its table as permanent.
Learning Happens From Source Addresses
Here’s the clever part. The switch learns from the source address, not the destination. Frame arrives, switch checks who sent it, notes the incoming port, updates the entry if it’s already there.
Keeps doing this as traffic moves around, and after a while the table becomes a decent map of the local network.
What Happens When the Switch Doesn’t Know?
Say your laptop wants to send data to a computer the switch has never seen before. It knows where the frame came from, not where it’s going.
So it floods the frame out through the other ports. The right device gets it, everyone else ignores it. Once that device sends something back, the switch learns its MAC address and links it to the right port. No more flooding after that, straight there next time.
MAC Addresses Don’t Stay Forever
The switch also ages out old entries. No traffic from a MAC address in a while, the entry eventually disappears, timing depends on the switch. Keeps the network from filling the table with stale info.
Why This Makes Switches So Efficient
Once the switch knows the destination MAC address, it forwards the frame through the right port instead of blasting it everywhere. Cuts down unnecessary traffic, keeps devices from dealing with data meant for someone else.
Plug in a device, let it talk, the switch figures out where it lives. The network basically teaches the switch its own layout as traffic flows, and once that clicks, a MAC address table stops looking mysterious and starts looking like what it is, a map the switch keeps updating on its own.