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?
-
4PCs are actually pretty chatty. They do a lot of things in the background.– Ron TrunkCommented Feb 13, 2019 at 11:56
-
1Are you sure there were no packet sent? How? Modern OSes have a lot of background network activity. This can also be due to gratuitous ARP. See this answer for example– JFLCommented Feb 13, 2019 at 11:57
-
Definitely no packets sent when it was first viewed, packets were sent afterwards and the table was view again.– The_BearCommented Feb 13, 2019 at 11:58
-
4Then you have magic switches.– JFLCommented Feb 13, 2019 at 13:02
-
6Clearly the PCs sent frames. That’s how the switch learned the MACs.– Ron TrunkCommented Feb 13, 2019 at 13:11
3 Answers
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).
-
Also, gratuitous ARP, as mentioned in the comments to the question. Commented Feb 13, 2019 at 20:17
-
And an ARP for the default gateway and DNS servers if defined either locally or by DHCP plus UPNP discovery, etc. Commented Feb 13, 2019 at 20:20
-
Strictly speaking this depend on OS and network configuration. If you were to disable IPv4 none of the packets you mention would be sent. For another example look at IPv6, it doesn't use broadcast only multicast. There are switches which will treat them the same, but a switch does not have to forward multicast packets onto all ports.– kasperdCommented Feb 13, 2019 at 22:20
-
@kasperd Absolutely. However, 99.x% of users are using IPv4 and the question didn't call for a too thorough/complicated answer.– Zac67 ♦Commented Feb 14, 2019 at 7:21
-
@Zac67 Your 99% number sounds like one you made up rather than anything based on actual data. One would need telemetry implemented in native code deployed to a very large user base to give a number with that amount of accuracy. I most certainly don't have access to a large enough number of client machines to say how widespread the use of IPv6-only networks with NAT64 is. But given that more than 20% of users have IPv6 access I would guess the number of such IPv6-only networks to amount for more than 1%.– kasperdCommented Feb 14, 2019 at 21:20
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.