I have been learning about spanning tree protocol (STP/RSTP/MSTP) and was wondering, once I turn it on and it's protecting against for example network loops, how do I know there is a network loop?
I suppose in most cases it would be obvious, because the room the loop is in would be down, but what if there is no complaint?
It seems like I would still want a way to know, that there is a network issue such as this. Maybe the device sending some kind of alert, or maybe someone has to check a log or something else occasionally?
You watch your switch logs for spanning tree events, or configure your switches to send SNMP traps when STP shuts down a port.
Testing. If you want to know that something is working, you test it.
Once you've enabled STP, schedule network maintenance and plug a cable in a loop. If the network is still working then the loop was detected by STP. If your network goes down then STP isn't working.
Spanning tree does not think a loop is an "error". They are part of the protocol and it will find the ports that cause loops, and then disable forwarding on them. I think you're trying to use a protocol to find out if a certain condition exists, but that's not really its primary purpose. A "well-designed" network may very well have loops normally (for redundancy). In addition to turning on logging event spanning-tree status (or the equivalent on your platform), think outside the box. A loop in your network (if not disabled by spanning tree) will cause large traffic levels in a broadcast storm. So graph those levels and in your monitoring platform if you see a sharp rise in traffic you've probably got a loop.
Here are some extra things to consider in your STP/RSTP/MSTP implementation along with your testing:
In addition to the earlier diagnostic suggestions, you should also learn to interpret the output from your switch's "show spanning-tree" command (or equivalent). It will show you the root port, designated ports, and a number of other important diagnostics.
Here's an example network i just set up with 2 x Cisco 2950 and 1 x HP 3400cl. The connections in the network are as follows:
The switches are all in MSTP mode, with only the common spanning tree instance set up. hp3400cl has priority 0, c2950 is the next highest priority at 8192, and c2950b is last with priority 12288. So hp3400cl should be the root. Here's how the "show spanning-tree" output looks:
The important things to note about port states in the above listing are: