Layer 2 Switching Loops in Network Explained

For backup purposes, administrators create redundant links. A redundant link is a backup link of the primary link. If the primary link fails, the redundant link prevents the network from going down. The Redundant or backup link is helpful only when the primary link fails. Until the primary link is functioning, the backup link should be disabled. If we enable both links at the same time, it creates a switching Loop.

Let us take an example.

Suppose we have two switches. If we connect these switches with a single link, the link will work as a primary link. As long as the switches have only one link, there will be no Loop between the switches.

However, connecting switches with a single link always has a chance of connectivity loss. If switches work in the core layer, it could bring the entire network down.

To avoid this situation, administrators use backup links. However, using more than one link between two switches creates switching Loops. A switching Loop creates many performance-related issues. Among them, three are the main ones. These are broadcast storms, unstable cam tables, and network bandwidth.

switching loop issues

Before we learn these issues, let us understand how switches make forwarding decisions.

A switch uses a relatively simple concept to forward a frame. It finds the destination Mac address of the incoming frame in the cam table. If the cam table has an entry for the destination Mac address, it forwards the frame from the port mentioned in the entry.

building cam table

If the cam table does not have an entry for the destination Mac address, it forwards the frame from all ports except the port on which it arrived. Forwarding a frame from all ports except the port on which it arrived is called frame flooding.

A switch floods a frame if it has an unknown unicast, multicast, or broadcast address in the destination address field. 

An unknown unicast address is an address that is not available in the cam table. A multicast address belongs to a group of devices. A broadcast address belongs to all devices on the local network.

Multicast and broadcast are destination-only addresses. End devices never use these addresses in the source address field of a frame. Since a frame never contains these addresses in the source address field and a switch uses the frame source field to learn MAC addresses, a switch never learns about these addresses. These addresses always remain unknown to the switch.

unknow address

As we know, a switch always floods a frame having an unknown address in the destination address field. Because of this, a switch always floods a frame containing an unknown unicast, multicast, or broadcast address in the destination address field.

frame flooding

Switching Loop example

The following image shows a switching Loop. Let us see how it works.

switching loop

PC1 generates a broadcast frame. The frame reaches S1 on switch Port one. The S1 switch reads the source and destination addresses of the frame.

It adds the Source address to the cam table and uses the destination address to make a forwarding decision. Since it is a broadcast frame and we know a switch always forwards a broadcast frame from all ports, S1 forwards it from all active ports.

loop

S2 receives it on ports 4 and 6. Let us suppose, first, it receives it on port 4. S2 reads the frame source and destination addresses. It adds the source address to the cam table and forwards the frame from all ports apart from the port on which it arrived.

switch read address

Right now, S2 knows Mac 1 is available on port 4. Now, it receives the same frame on port 6. It reads the source and destination addresses of the frame. It uses the source address to update the cam table.

switching loop

If the switch receives a frame on the same port from the same source, it only updates the timer. But if it receives the frame on a new port, it assumes the device has relocated and attaches the source address with the new port. After updating the cam table, it forwards the frame from all ports.

switching loop

S1 receives both frames back from S2 in reverse order. On port 4, it gets the frame forwarded by port 6. On port 4, it receives the frame forwarded by port 4.

When it receives the frame on port 6, it repeats the same process. It reads the source address to update the cam table and the destination address to make the forwarding decision. It repeats the same process when it receives the frame on port 4. Similarly, S2 receives its forwarded frames back on ports 4 and 6 in reverse order. It takes the same learning and forwarding steps. It forwards the frames to S1, and S1 forwards them back to it.

Switches forward frames blazingly fast. They can forward millions of frames per second. It means this process can be repeated millions of times per second. It creates a broadcast storm.

fast forwarding

A broadcast storm consumes most of the network bandwidth. A few broadcast storms are enough to bring the entire network down.

switching loop bring network down

Since the switch updates the cam table each time, it receives a frame. It also makes the cam table unstable. Switches use the cam table to make forwarding decisions. If the cam table is unstable the switch fails to make the correct forwarding decisions.

unstable cam table

All these happen just because of a single broadcast frame. In real life, networks and devices generate many broadcast frames every second. Considering these facts, if a loop exists, the network will not work. However, Ethernet switches are smart enough to automatically detect and remove Loops. They use a protocol called spanning tree protocol to deal with loops. The STP protocol creates a virtual topology of the entire network and disables ports that create a loop. If the primary link goes down, it automatically enables the disabled port to maintain the connectivity.

ComputerNetworkingNotes CCNA Study Guide Layer 2 Switching Loops in Network Explained