how/network
A switch knows nothing at startup. In the first seconds of traffic it builds its own map, who is on which port, and stops flooding frames.
When you plug a new switch into the wall, it can switch, but it does not know who is connected to which ports. How does it start working the right way within a couple of seconds, no flooding, with targeted delivery?
The magic is the CAM table (Content-Addressable Memory). This is a table of
MAC address ↔ port number that the switch learns by itself by watching
the traffic passing through. Every incoming frame carries a source MAC, and
the switch simply looks and records: "ah, this MAC lives on this port".
Press ▶ and watch an empty switch learn in 3 frames and go from "flood everything" mode to "targeted delivery".
The switch just booted. The CAM table is empty. It can receive and send frames, but it does not know which MACs live on which ports.
Any frame that arrives now will make it flood a copy to all ports, because the dst MAC is unknown to it.
recap
What matters to remember:
ff:ff:ff:ff:ff:ff). A broadcast is always
flooded, it does not depend on the CAMMAC ↔ port. ARP lives in the host and stores IP ↔ MAC.
Different layers, different jobsRelated to arp (how a host learns a neighbor's MAC) and broadcast-domain (where the switch must flood).