Hey I'm kinda new to networking. Forgive the basic nature of the doubt.
Switches, when they receive frames to an unknown destination, broadcast the frame to find the correct destination. Meanwhile routers use routing protocols like RIP, OSPF etc. to find the correct destination. My doubt is why can't switches also use some sort of protocol similar to RIP but at level 2 to find the MAC addresses of all the devices? We can avoid the unicast flooding which take away a lot of the bandwidth right?
Best Answer
As mentioned in my comments on Ron Royston's answer, I assume you mean "why can't switches also use some sort of protocol to populate their mac-address-table". If that is not what you meant then disregard the rest of this answer. If that is what you meant then I think this is a great question!
First of all, if you really meant "why can't switches use..." then I think the answer is, theoretically they could - or at least off the top of my head I can't think of a reason why they could not. You could invent a L2 protocol that allows switches to query the device connected to a port to get the device's MAC address, or a list of MAC addresses reachable through that device (in case it is another switch). This could perhaps even remove the need for STP. Of course this are just my initial thoughts and real experts (which I don't consider myself to be) may have already given this much more thought and may have found specific reasons why this would not work.
However if your question (or next question) is "why don't switches use..." then I can think of a few reasons: