Pages

Wednesday, November 20, 2013

Spanning Tree Protocol along with commands

Spanning Tree Protocol (STP) is a network protocol that ensures a loop-free topology for any bridged Ethernet local area network. The basic function of STP is to prevent bridge loops and the broadcast radiation that results from them.

Working of STP:
1. Choosing the root bridge:

1. Each switch has a bride ID(BID)= Priority value + MAC Address
2. Switches exchange BPDUs (Bridge Protocol data units) to compare bridge IDs
3. The switch with the lowest bridge ID becomes the root bridge(first priority is compared, if they are equal, MAC address is compared. Lower values get the priority)
4.Administrator can set the priority to fix the selction: If there are low speed switches which has lower MAC address they can act as root bridge which reduces the performance of the network. 
 If the network administrators would like some switch to become the root bridge, they must set its priority to be less than 32768 or configure the spanning tree a root primary/secondary. When configuring the root primary and root secondary the switch will automatically change the priority accordingly, 24577 and 28673 respectively with the default configuration.

Commands:
spanning-tree vlan 1 root primary 
spanning-tree vlan 1 root secondary
To avoid this, we change change the priority so that the required switch act as root bridge or we can set any switch to root using the following commands.

Commands:
spanning-tree vlan 1 priority ?
  % Bridge Priority must be in increments of 4096.
  % Allowed values are:
  0     4096  8192  12288 16384 20480 24576 28672

  32768 36864 40960 45056 49152 53248 57344 61440

Root bridge is the switch that has all ports working in the designated role. 
It will be the reference point from which the loop free topology is computed. 
Root bridge will impose the timers that other switches will use such as: 

hello time - how often BPDUs are going to be sent/relayed (default timer=2 seconds), 
max age - how long the configuration is valid (default timer=20 seconds),
forward delay - how long a port should be in listening/learning state (default timer=15 seconds). 

Commands:
Switch(config)# spanning-tree vlan 10 hello-time 10 
Switch(config)# spanning-tree vlan 10 forward-time 20 
Switch(config)# spanning-tree vlan 10 max-age 40

Root bridge will be announcing its presence by sending BPDU frames. 
Other switches will relay those frames out their designated port given the hello time. 

Also, the root bridge has all its ports in the designated role (forwarding).

2. Determine the least cost paths to the root bridge

Least cost path from each bridge. 
After the root bridge has been chosen, each bridge determines the cost of each possible path from itself to the root. From these, it picks one with the smallest cost (a least-cost path). The port connecting to that path becomes the root port (RP) of the bridge.
When multiple paths from a bridge are least-cost paths, the chosen path uses the neighbor bridge with the lower bridge ID. The root port is thus the one connecting to the bridge with the lowest bridge ID


The table below shows the default cost of an interface for a given data rate.
Data rateSTP Cost (802.1D-1998)RSTP Cost (802.1D-2004 / 802.1w)
4 Mbit/s2505,000,000
10 Mbit/s1002,000,000
16 Mbit/s621,250,000
100 Mbit/s19200,000
1 Gbit/s420,000
2 Gbit/s310,000
10 Gbit/s22,000

Least cost path from each network segment. 
The bridges on a network segment collectively determine which bridge has the least-cost path from the network segment to the root. The port connecting this bridge to the network segment is then the designated port (DP) for the segment.

When more than one bridge on a segment leads to a least-cost path to the root, the bridge with the lower bridge ID is used to forward messages to the root. The port attaching that bridge to the network segment is the designated port for the segment.In some cases, there may still be a tie, as when two bridges are connected by multiple cables.
In this case, multiple ports on a single bridge are candidates for root port.
In this case, the path which passes through the port on the neighbor bridge that has the lowest port identifier [Port priority(default=128) + Port number] is used.
Bridge ID = priority (16 bits) + ID [MAC address] (48 bits); the default bridge priority is 32768, and

Port ID = priority (4 bits) + ID [Interface number] (12 bits); the default port priority is 128.

Commands:
Switch(config)#int fa0/10
Switch(config)#spanning-tree port-priority 50

Disable all other root paths. Any active port that is not a root port or a designated port is a blocked port (BP).



No comments:

Post a Comment