Switch – Layer 2 Switch Mac Address

macswitchswitching

I know a layer 2 switch floods the frame out asking who has a certain mac address. My question is how does it know what mac address to ask for in the first place?
Scenario: A brand new switch is implemented. 5 Hosts a re connected. Host A sends a message to Host B. How does A know what the mac address is of Host B in the first place?

Best Answer

ARP (Address Resolution Protocol) is used by a source host to resolve the layer-3 address of a destination host to that host's layer-2 address. An ARP request is broadcast on layer-2, asking, "Who has this layer-3 address?" The host with that layer-3 address will unicast back to the requesting host with its layer-2 address.

Hosts populate an ARP cache with layer-3 addresses which have been resolved to layer-2 addresses so that ARP is only used the first time a host wants to send something to another host. Entries in a host's ARP cache have a timeout, and they will be eventually be flushed if there is no activity for that entry.

A switch only floods an unknown unicast, and switches don't ask who has a certain MAC address. A switch will maintain a MAC address table, which relates a particular MAC address to a switch interface. A switch builds or updates this table every time a frame enters a switch interface. The switch will look at the layer-2 source address on a frame entering an interface, and it will add to, or update, its MAC address table with that address and interface.

A switch will also look in its MAC address table for the layer-2 destination address in the frame to find to which interface the frame should be switched. Only if the switch doesn't find the destination address in its MAC address table does it flood the frame to all other interfaces. Entries in a switch MAC address table have a timeout, and they will eventually be flushed if there is no activity for the MAC address.

Related Topic