Switches
MAC address table
A switch's record of which port each MAC address was last seen on, learned from source addresses.
The problem
A switch cannot send a frame to one port until it knows which port that MAC is behind.
- The table starts empty. Alice pings bob; her frame comes in on the port
alice. - Learn: the switch notes her source MAC,
b6:a0:12:30:a8:0b, behindalice. - Flood: bob's MAC is not in the table yet, so the frame goes out of every other port, carol's too.
- Bob's reply comes in on
bob: now both are learned, and every later frame is forwarded to one port only. - Age: an entry not refreshed for the aging time (300 s by default) is forgotten.
What you'd see
$ bridge fdb show br br0 dynamic
b6:a0:12:30:a8:0b dev alice master br0
06:c7:51:36:4e:b8 dev bob master br0
b6:a0:12:30:a8:0b dev alice: alice's MAC, behind the portalice.06:c7:51:36:4e:b8 dev bob: bob's, learned from his reply.- No line for carol: she has sent nothing, so the switch does not know where she is.
Guess first
The table is emptied and alice pings bob three times while carol records. How many of the pings does carol hear?
Show answer
One: the first request, flooded because bob was unknown. His reply teaches the switch his port, so the other requests go to bob alone.
In short
Four rules. Learn: a frame arriving on a port teaches the switch that its source MAC is behind that port.
Forward: a frame whose destination is in the table leaves by that port only. Flood: a frame for an unknown
destination, or a broadcast, leaves by every port but the one it came in on. Age: an entry not refreshed for the
aging time (300 seconds by default) is forgotten. A device that has sent nothing is not in the table, and a
device that moves is found again as soon as it sends. Entries typed in by hand (static) never age out.
Read next
- Switch Joins devices into one network, forwarding each frame toward the port its destination MAC was seen on.
- MAC flooding Filling a switch's MAC table with made-up addresses so that it floods everyone's frames to every port.
- Broadcast domain The set of devices a broadcast reaches: one network at the link layer.
- Hub The switch's ancestor: it repeats every frame out of every port, so everyone hears everything.
- Broadcast storm A broadcast copied round a loop of switches for ever, because Ethernet frames have no hop limit.
- Spanning tree The protocol that lets switches be cabled in loops by electing a root and blocking the ports that close a loop.
- IGMP snooping A switch reading its devices' IGMP to send each multicast group only out of the ports that joined it.
- Port security A limit on how many MAC addresses one switch port accepts; one more is a violation that drops the frame or shuts the port.