I am just wondering how a switch does know how to route packets to destinations "hidden" behind another switch.
In my understanding a switch has a table that maps each of its hardware ports to exactly one MAC-address. So far so good, when a packet/frame (?) arrives it now can determine the port at which the packet should be routed.
But what happens when there is another switch connected to one of these ports and this second switch has more than one devices connected?
I am wondering how a switch is able to resolve this (on OSI-Layer 2, without a router), as I think this does indeed work in reality (?)
I am sorry if this question already exists (I think so, it should not be that uncommon), but I could not manage to put my thought into a suitable search query.
Best Answer
A Layer 2 switch learns most of its information about the location of other endpoints via "listening" to ingressing frames, and when it is not aware of the location, it uses
flooding
and will learn from the answer. Lets say the topology is:(Host A) <--> (Switch A) <--> (Switch B) <-->(Host B).
Also important to note, a L2 Switch forwards, it does not route. By that I mean, when it receives an encapsulated frame, it forwards it out interfaces.
Here's a related question: How does a switch learn a switch table?