STP (Spanning Tree Protocol) - IOS

Function: 

The learning algorithm from the previous LAN Switching Lab builds the MAC forwarding tables of bridges, without the need for a routing protocol. However, since learning bridges flood a packet on all ports when a destination is not known, it may happen that packets are forwarded in a cycle and loop indefinitely. The spanning tree protocol for bridges, standardized in the IEEE 802.1d specification, prevents such forwarding loops from occurring. This is done by organizing the bridges in a spanning tree topology. Learning bridges that run the spanning tree protocol are called transparent bridges.

The spanning tree protocol, which is used by virtually all Ethernet switches, works as follows. One bridge, called the root bridge, is elected to be the root of the tree. Each bridge determines which of its ports has the best path to the root bridge. This is the root port of the bridge. On each LAN, the bridges elect one bridge, called the designated bridge, which, among all bridges on the same LAN, has the best path to the root bridge. The port that connects a bridge to the LAN where it is a designated bridge is called the designated port. Then, all bridges disable all ports that are not root ports or designated ports. What results is a spanning tree of bridges. Since a tree topology does not have a loop, forwarding packets along the edges of the tree guarantees that forwarding loops are entirely avoided.


Commands useful in configuring the Spanning Tree Protocol

[no] spanning-tree vlan [vlan range]

     -Enable/disable STP on indicated VLANs

spanning-tree vlan [#] priority [#]

     -Set the priority of the current switch for the indicated VLAN

show spanning-tree [summary | root | interface | vlan| brief]
   - 
Show information about a spanning-tree

    summary         shows summery of port states
    root                 shows status and configuration of root bridge
    interface         shows spanning-tree interface status and configuration
    vlan                 shows spanning-tree interfaces on specified VLAN
    brief                shows brief sumary of interface information

 


Spanning-Tree Protocol Configuration Example

Router1# configure terminal

Router1(config)# spanning-tree vlan 1

Router1(config)# spanning-tree vlan priority 8192

Router1(config)# exit


Identifying Spanning-Tree Port Roles in Cisco IOS 12.3

To identify the roles of the ports your CIsco devices after you have set up STP on the network, use the “show spanning-tree brief ” command.

R2#show spanning-tree brief

VLAN1
 Spanning tree enabled protocol ieee
 Root IDPriority4090
 Address cc01.70a9.0000
 Cost    19
 Port    3 (FastEthernet0/2)
         Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Bridge ID  Priority4096
        Address cc02.70a9.0000
        Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
        Aging Time 0  

Interface                               Designated
Name                   Port ID Prio Cost  Sts Cost  Bridge ID                Port ID
-------------------- ------- ---- ----- ---   ----- --------------------   -------
FastEthernet0/2      128.3   128 19    FWD  0     4090 cc01.70a9.0000 128.3  
FastEthernet0/3      128.4   128 19    FWD  19    4096 cc02.70a9.0000 128.4  
FastEthernet0/5      128.6   128 19    BLK   19    4096 cc00.70a9.0000 128.6
 
Note that the "Sts" field in the table describes the status of the port in terms of whether it is forwarding traffic; this does not reflect the role of the port in STP routing terms of Root, Designated or Blocked. However we can determine each port's role using the following rules:
 
  • All ports with Status "BLK" are in the Blocked role.
  • The port specified as the Root port in the "Root" section at the top of the output is in the Root role (note, this port will always show "FWD" in the "Sts" field).
  • All ports labeled "FWD" in the "Sts" field that are not identified as Root are in the Designated role.

 Therefore, on router R2 in this example, fa0/2 is Root, fa0/3 is Designated, and fa0/5 is Blocked.


Cisco Ethernet Switch Module documentation (pdf)

PacketLife Cheat Sheets: Spanning Tree