Network switches build and maintain a MAC address table—also called a CAM table—to intelligently forward frames to the correct port based on destination MAC addresses. This table is dynamically updated as frames pass through the switch and ages out stale entries to keep up with changing network conditions.
Switch MAC Address Learning
We know that a switch's job is to forward frames on a network to their proper location based off of the destination MAC address. But how does it know which port those different MAC addresses are on?
That switch is going to have to somehow learn which MAC addresses are associated with which ports, and it does this anytime a frame comes through that switch. For instance, if this PC here is sending out a message and it's going to this switch, then that switch is going to look in that frame. It's going to look at the destination MAC address so it knows where to send it. But it's also going to look at the source MAC address and see where the source MAC address is coming in. So if this frame is coming in through port one, it's going to record that this is coming in through port one, and then it's also going to record the source MAC address into this table.
Then it'll keep track of this. It'll keep track of the different ports that are associated with the different MAC addresses. That way, when another frame comes through there and it's destined for this machine, it will know that that is on port one and it can send it that direction.
When this machine does a reply to that machine and it comes through that switch, then it will do the same thing. It will record, okay, this server is on port 8, and then it's going to record that that is with the MAC address into that table.
So this table that tracks this will continue to track all of the different MAC addresses and their associated ports that are on this table. This table is called the MAC address table. You'll hear the term MAC address table, or you'll also hear a CAM table as well. CAM stands for content addressable memory. These are two terms for the same thing. It's just referencing this table of MAC addresses to ports on a switch.
Our networks are very dynamic, so there are constantly machines that are being plugged in and being unplugged, and a machine could go offline. This could even be a problem if, let's say, it's plugged into one switch and then that machine moves to another location, and all the switches have not had a chance to learn the new location. Then there are some communications that can be missed and not make it to that end destination.
So what we need is some sort of mechanism that will retire these MAC addresses over a certain period of time. If a machine does not communicate on a port after a certain period of time, then it will expire that record — we call this aging, that that record will age out. So if a machine, let's say this machine right here, goes offline, and over time it doesn't renew that record, then it will remove that record and it will age out that record.
There are sometimes when a machine has not had a chance to communicate or send any information out. Let's say this device has not sent out a message yet and this switch does not know where that machine is at. So when a message gets sent that's destined for this machine right here, that switch does not know where that's located at. What it'll do is it will flood that message out all other ports.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →