Timedora

1 Layer 2 Switching Fundamentals

Learn how Layer 2 switches learn MAC addresses and forward Ethernet frames within VLANs, including flooding, filtering, and common forwarding scenarios.

The role of a

A connects devices on an Ethernet LAN and forwards frames using MAC addresses. It examines the Ethernet header—not the destination IP address—to choose the port for a frame. This allows devices on the same Layer 2 network to communicate without sending every frame to every connected device.

The switch’s , also called a forwarding table or CAM table, associates MAC addresses with ports and, where VLANs are used, with VLANs. Entries are generally learned dynamically, although some devices and configurations can use static entries.

A does not by itself route traffic between IP networks or VLANs. Communication between separate Layer 2 networks requires a Layer 3 device, such as a router or Layer 3 switch. Each provides a separate switching context in which MAC learning and forwarding apply.

How switches learn MAC addresses

When a frame arrives, the switch reads its and records it against the incoming port and . If a device later sends a frame from a different port, the switch can update the entry to reflect the device’s new location.

Dynamically learned entries are typically removed after they have been inactive for a period of time; this process is called . Learning from the source address and forwarding based on the destination address are separate actions performed on a received frame.

How switches forward frames

After processing the source address, the switch looks up the destination MAC address in the table for the relevant . The result determines whether the frame is sent to one port, flooded within the , or filtered.

Known, unknown, and traffic

For a frame, if the destination MAC address maps to a different port, the switch forwards the frame out that port only. If the known destination is on the incoming port, the switch filters the frame instead of sending it back out the same port.

For an frame, the switch floods it to eligible ports in the same , except the port on which it arrived. This is normal while the switch is learning: the frame has a chance to reach its recipient, and the recipient’s reply may allow the switch to learn its for later direct forwarding.

A frame is flooded within its , except back out the incoming port. is limited to the relevant ; it does not automatically reach every port in every .

A first exchange between two devices

Suppose PC-A is connected to port 1 and PC-B to port 2 in the same , and the switch has not yet learned either address.

  1. PC-A sends a frame to PC-B. The switch learns PC-A’s on port 1.

  2. PC-B’s destination MAC address is not in the table, so the switch floods the frame to other eligible ports in that .

  3. PC-B replies. The switch learns PC-B’s on port 2, looks up PC-A’s destination MAC address, and forwards the reply only through port 1.

  4. Subsequent frames between the PCs are forwarded to their known ports rather than flooded.

Interpreting common switching scenarios

If a frame arrives on port 3 for a MAC address learned on port 8, the switch forwards it out port 8, provided the entry is in the applicable and the port is eligible to forward.

If the destination is absent from the table, the switch floods the frame within the incoming frame’s , excluding the incoming port. The destination’s response may create the table entry needed for later direct forwarding.

If two devices use the same MAC address, the switch may repeatedly relearn that address on different ports as frames arrive. This can cause unstable forwarding; duplicate or unexpectedly moving MAC addresses should be checked.

When a host moves to a new port, a frame received from that host on the new port can update its learned location. If a dynamic entry has aged out, traffic to the host may first be flooded until the switch learns the location again.