Most Layer 2 issues are related to some kind of loop within the domain and this has multiple problems associated with it, including network downtime. When you are working with switch configuration and are plugging/unplugging a device, you should make sure that you aren’t creating a loop in the process. To mitigate against such problems, you should usually configure Spanning Tree Protocol on switches in order to avoid situations that might occur if you happen to accidently create a loop somewhere in the network.
Every switch in a network is communicating using MAC addresses. As packets come in, the MAC address is analysed and the switch determines where that packet goes based on the destination MAC address in the Layer 2 header. Every device in the network has its own MAC address, so all the packets are very specific as to where they are going. Unfortunately, things like Broadcasts and Multicasts go to every port on the switch. If a Broadcast frame arrives at a switch port, it copies that Broadcast to every other device that might be connected to that switch. This process can often be a problem when you have loops in the network.
You should also keep in mind that the MAC address packets have no mechanism inside them to time out. In the case of TCP/IP, the IP protocol has within its header a function called TTL (Time to Live), which refers to the number of hops through a router, not actually to a specific unit of time. So if IP packets happen to be in a loop and are going through multiple routers, they will eventually time out and be removed from the network. On the other hand, switches do not offer that kind of mechanism. Layer 2 frames can theoretically loop forever, as there is no mechanism to time them out, meaning that if you create a loop, it is going to be there until you manually remove it from the network.
If you are plugging in one workstation to the network and a Broadcast reaches it, it will terminate at that point and will not be a problem for the network. On the other hand, if you misconfigure a port configuration on the switch side or you plug both ends into a switch without enabling STP, this might lead to a Broadcast storm within the Layer 2 domain. This happens because Broadcast packets are forwarded to all other ports, so the Broadcast packet keeps exiting and entering the switch on the same cable, causing a Layer 2 loop. This can lead to high resource usage and even network downtime.
If you enable STP on such a misconfigured network, the switch will recognise that a loop has occurred and it would block certain ports to avoid Broadcast storms. Every other port in the switch continues to operate normally, so the network is not affected. If STP is not configured, the only option would be to unplug the network cable that is causing the problem or administratively disable it if you can still operate the switch at that moment.
STP issues usually fall within the following three categories:
- Incorrect Root Bridge
- Incorrect Root Port
- Incorrect Designated Port
Incorrect Root Bridge
Priority and base MAC addresses decide whether the Root Bridge is incorrect. You can issue the show spanning-tree vlan <vlan#> command to see the MAC address and switch priority. You can fix this problem with the spanning-tree vlan <vlan#> priority <priority> command.
Incorrect Root Port
The Root Port provides the fastest path from the switch to the Root Bridge, and the cost is cumulative across the entire path. If you suspect an incorrect Root Port, you can issue the show spanning-tree vlan <vlan#> command. If the Root Port is incorrect, you can issue the spanning-tree cost <cost> command to fix it.
Incorrect Designated Port
The Designated Port is the lowest cost port connecting a network segment to the rest of the network. If you suspect a problem with the Designated Port, you can issue the show spanning-tree vlan <vlan#> and spanning-tree cost <cost> commands.
A useful STP troubleshooting command that can debug related events is Switch#debug spanning-tree events.