How do layer 2 switches learn address locations

Layer 2 switching

Using devices' MAC addresses to determine where to forward frames is known as layer 2 switching (L2) or data link layer switching. For layer 2 switching, switches and bridges are typically utilized. They assist in splitting up large collision domainsThe term "collision domain" refers to a network segment where multiple data transmissions can clash, such as wireless shared medium, bus topology, and ethernet. into smaller ones.

Layer 2 ethernet switches are faster than routers since they do not need much time to evaluate network layer header data. Instead, they examine the frame's hardware addressesMAC address, which aid in deciding whether to forward, flood, or drop the frame. When forwarding packets, L2 switches do not allow to make intelligent decisions as no intelligent devices such as routers are involved in decision making.

Flooding refers to the switch sending the incoming frame to all occupied and active ports other than the one it actually received from. Flooding is essentially occurs when a switch acts as a hub.

Learning address location

Here's an illustration of a network with three host devices identified as A, B, router 1 connected to switch 1, and router 2 connected to a server:

1 of 9

The following points clarify the step-by-step procedure:

  • For the first time, B wants to transmit a data packet to the server.

  • B is familiar with the server's IP address, but it is unaware of the receiver's MAC address.

  • Therefore B employs ARP protocol to identify the server's MAC address.

  • ARP requests are forwarded by switch 1 to all ports other than the port to which B is connected.

  • When router 1 receives the ARP request, it is not the destination, so it forwards the request to router 2. Communicating takes place through the routers.

  • Then router 2 forwards the ARP request to its linked port.

  • The server receives the ARP request and responds with its MAC address. In this fashion, B gathers the MAC address of the server.

  • The server also sends its MAC address in the ARP response, MAC address of the server is stored in the MAC address table of switch 1.

  • Additionally, it also saves the MAC address of B.

  • In this fashion, communication between B and the server is established.

  • Therefore, switch 1 will check the table anytime B wishes to transmit any data and forward it to the server's destination port.

  • In this manner, the layer 2 switch will continue to keep track of the hardware address of each connecting host.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved