As you might have understood from the preceeding discussion on how Loops can be detrimental to a network, it is highly necessary that bridges must be able to correctly handle loops. This problem is tackled by having the bridges run a Distributed Spanning Tree Algorithm.If the extended LAN can be thought of as being represented by a graph that possibly has loops, then the Spanning Tree is a subgraph of this graph that covers (spans) all the vertices, but avoids the loops. The Spanning Tree algorithm was developed by Radia Perlman at Digital. It is a protocol used by a set of bridges to agree upon a spanning tree for a particular extended LAN. In practice, this means that each bridge decides the ports over which it is and is not willing to forward frames. In a sense, it is by removing ports from the topology that the extended LAN is reduced to an acyclic tree. It is even possible that an entire bridge will not participate in forwarding frames. Let us consider the network topology that is shown below:
Note the loop in the network given.... The main idea of the Spanning Tree is for the bridges to select the ports over which they will forward frames. The algorithm selects ports as follows. Each bridge has a Unique identifier. The algorithm first elects the bridge with the 'smallest ID' as 'The Root Bridge' of the tree. The root bridge always forwards frames out over all its ports. Next, each bridge computes 'the shortest path' to the root and notes which of its ports is on this path. This port is also selected as the bridge's 'Preferred Path' to the root. Finally, all the bridges connected to a given LAN elect a single 'Designated Bridge' that will be responsible for forwarding frames towards the root. Each LAN's desiganted bridge is the one that is closest to the root, and if two bridges are equally close to the root, then the bridges' identifiers are used to break ties; the smallest ID wins. Of course, each bridge is connected to more than one LAN, so it participates in the election of a designated bridge for each LAN it is connected to. In effect, this means that each bridge decides if it is the designated bridge relative to each if its ports. The bridge forwards frames over those ports for which it is the designated bridge. On running this algorithm the LAN is reduced to an acyclic tree as shown below:
If you feel interested in this topic, Please visit the following sites for newer information and more tech-Savy details.... Here are some links to material that we found good..
Link1 Link2 Link3