I thought that a switch learnt the mac addresses by the computers sending out packets. However when I configured 2 switches, and 2 pc's, 1 pc connected to 1 switch, the other pc connected to the other switch, and then both switches connected to each other, there were mac addresses in the mac address table without there being any packets being sent. Why/How does this happen?
When you connect a PC to a network switch ("link up"), the PC performs at least one of these procedures (assuming IPv4 use):
- (most commonly) request an IP address lease from a DHCP server
- (when DHCP fails or is deactivated) automatically configure a link-local IP address (aka zero-config or APIPA)
- (when a static IP address is configured) send an ARP probe to detect an address collision
All of these methods send out broadcast frames from the PC which populate the MAC table in all the switches in the network (broadcast domain / VLAN).
PCs have many background tasks that send data all the time, even when you’re “not doing anything.” These frames will populate the MAC table.
You might think no packets have been sent, but Computers do a lot of talking in the background, given all the services functioning in the background.