Saturday, 1 November 2014

Spanning Tree Protocol (STP), Per-Vlan Spanning Tree (PVST)

STP uses messaging between switches to stabilize the network into a logical loop-free topology. STP uses 2 BPDU types - Configuration BPDU and Topology Change Notification(TCN) BPDU.

To determine which BPDU out of a pair of BPDUs is superior, they are compared in
the following sequence of values, looking for the first occurrence of a lower value:
   -Root Bridge ID (RBID)  
   -Root Path Cost (RPC)  
   -Sender Bridge ID (SBID)  
   -Sender Port ID (SPID)  
   -Receiver Port ID (RPID; not included in the BPDU, evaluated locally)  

Only Configuration BPDUs are compared.
Each port in STP stores (that is, remembers) the superior BPDU it has either sent or received. Root Ports and Blocking ports store the received BPDU sent by the “upstream” designated switch (because that BPDU is superior to the one that would be sent out from this port), while Designated Ports store their own sent BPDU (because that one is superior to any received BPDU). Essentially, each port stores the Designated Port’s BPDU—whether it is the port itself that is Designated or it is a neighbor’s port.


Electing a Root Switch

Only one switch can be the root of the spanning tree. Each switch begins its STP logic by creating and sending an STP Hello bridge protocol data unit (BPDU) message, claiming itself to be the root switch. If a switch hears a  superior Hello  to its own Hello—namely, a Hello with a lower bridge ID—it stops claiming to be root. The
switch starts forwarding the superior Hellos received from the superior candidate. Eventually, all switches except the switch with the lowest bridge ID cease to  originate
Hellos; that one switch wins the election and becomes the root switch. IEEE 802.1D bridge ID held two fields 2-byte Priority field and 6-byte MAC Address field.

The System ID Extension eliminates the need to consume a separate MAC address on each switch for each STP instance. The use of the System  ID Extension field is also called  MAC address reduction.

Determining the Root Port

   1. The root switch creates and sends a Hello every Hello timer (2 seconds by default). This Hello contains the RBID and SBID fields set to the ID of the root, RPC set to 0, and SPID set to the identifier of the egress port.   
   2. Each nonroot switch receiving a BPDU on a particular port adds that port’s cost to the RPC value in the received BPDU, yielding a  resulting  BPDU. Subsequently, the 
switch declares the port receiving the superior resulting BPDU as its Root Port.   
   3. Hellos received on the Root Port of a nonroot switch are forwarded through its remaining designated ports after updating the RPC, SBID, SPID, and MessageAge fields accordingly. Hellos received on other ports of a nonroot switch are processed but they are not forwarded.   
   4.    Switches do not forward Hellos out Root Ports and ports that stabilize into a Blocking state. Hellos forwarded out these ports would be inferior (and therefore 
uninteresting) to Hellos originated by some neighboring switch’s Designated Port on those segments.    
A Root Port always provides the least-cost path toward the switch with the lowest Bridge ID. If there are multiple equal-cost paths, additional tiebreakers (SBID, SPID, RPID) will be used.
Each time a Hello is received, the receiving  switch can be thought to reevaluate its choice of a Root Port and updates the choice if necessary,
A switch must examine the RPC value in each Hello, plus the switch’s STP port costs, to determine its least-cost path to reach the root.

Determining the Designated Port  

A converged STP topology results in only one switch forwarding Hellos onto each LAN segment. Only the DP forwards Hellos onto a LAN segment.Neither Root Ports nor ports in the Blocking state send BPDUs.

STP Rules
   -The root switch is the switch that has the lowest Bridge ID in the topology.  
   -On each nonroot switch, a Root Port is the port receiving the best (that is, superior) resulting BPDUs from all received BPDUs on all ports. The adjective “resulting” refers to the addition of the port’s cost to the BPDU’s RPC value before comparing the received BPDUs.  
   -On each connected segment, a Designated Port is the port sending the best (that is, superior) BPDUs on the segment. No modifications to the BPDUs are performed; BPDUs are compared immediately.  
   -All ports that are neither Root Ports nor Designated Ports are superfluous in an active topology and will be put into the Blocking state.  
   -Configuration BPDUs are sent out only from Designated Ports. Root and Non-Designated ports do not emit Configuration BPDUs because they would be inferior to BPDUs of a Designated Port on this segment and hence ignored.  
   -Each port stores the best (that is, superior) BPDU it has received or sent itself. Designated Ports store the BPDU they send; Root and Blocking ports store the best BPDU they receive. The stored BPDU determines the role of the port and is used for comparisons.  
   -Received superior stored BPDUs will expire in MaxAge-MessageAge seconds if not received within this time period.    

Converging to a New STP Topology  

With each received BPDU, a switch reevaluates its own choice of the root switch, Root Port, and Designated/Non-Designated Ports, effectively performing all three steps all over again. For STP, a  topology change  is an event that occurs when   
   -A Topology Change Notification BPDU is received by a Designated Port of a switch   
   -A port moves to the Forwarding state and the switch has at least one Designated Port
   -A port moves from Learning or Forwarding to Blocking   
   -A switch becomes the root switch    

When STP reconverges on a new active topology, some Content Addressable Memory (CAM) entries might be invalid. A switch that detects a topology change must notify the root switch, and the root switch in turn can notify all switches in the topology. To do so, a switch detecting a topology change notifies the root switch using a Topology Change Notification (TCN) BPDU. The TCN goes up the tree to the root. After that, the root notifies all the rest of the switches.

   1. A topology change event occurs on a port of a switch.   
   2. After detecting the event, the switch sends a TCN BPDU out its Root Port; it repeats this message every Hello time until it is acknowledged.   
   3. The next designated switch receiving that TCN BPDU sends back an acknowledgment through its next forwarded Hello BPDU by marking the Topology Change Acknowledgment (TCA) bit in the Flags field of the Hello.   
   4. The designated switch on the segment in the second step repeats the first two steps, sending a TCN BPDU out its Root Port, and awaits acknowledgment from the designated switch on that segment.   
   5. After the TCN arrives at the root switch, it also acknowledges its arrival through sending a BPDU with the Topology Change Acknowledgment bit set through the 
port through which the TCN BPDU came in. At this point, the root switch has been informed about a topology change that occurred somewhere in the network.   
   6. For the next MaxAge+ForwardDelay seconds, the root switch will originate BPDUs with the Topology Change (TC) bit set, instructing all switches to shorten the aging time for CAM entries to ForwardDelay seconds.    

A switch receiving a Hello BPDU with the TC flag set uses the short (ForwardDelay time derived from the value in the received BPDU, set by the root switch) timer to time out unused entries in the CAM.

Per-VLAN Spanning Tree

Cisco Per VLAN Spanning Tree Plus (PVST+) feature creates an STP instance for each VLAN. Non-Cisco switches that follow exclusively the IEEE standard support only a so-
called Common Spanning Tree (CST). 

PVST+ instances for VLANs other that VLAN 1 in PVST+ regions treat CST regions simply as loop-free shared segments. This is done by encapsulating the PVST+ BPDUs on trunks differently than ordinary BPDUs. Each PVST+ BPDU has a special TLV record placed at its end that carries the VLAN number in which the PVST+ BPDU was originated. This record is called Port VLAN ID TLV, or a PVID TLV. PVST+ BPDUs are tunneled across CST regions, with CST switches flooding them as ordinary multicasts without processing them.


As PVST+ BPDUs are effectively tunneled across CST regions, the CST regions simply appear as shared segments to non-VLAN 1 PVST+ STP instances. PVST+ BPDUs will be flooded across the CST region without being processed. When forwarded PVST+ BPDUs reach the first Cisco PVST+ switch in the other PVST+ region, the switch, listening for multicasts to 0100.0CCC.CCCD, reads and interprets the BPDU.  

STP Configuration

The root cost of 0 implies that the switch where the command is executed is the root.
Root ID = priority (multiples of 4096) + VLAN ID .followed by MAC address //since the switch is using System ID extension
  show spanning-tree root
  show spanning-tree vlan 1 root detail
  show spanning-tree root priority
  show spanning-tree vlan 1
  (config)#spanning-tree vlan 1 priority <multiple of 4096>
  (config)#spanning-tree vlan 1 root {primary|secondary}
  (config-if)#spanning-tree vlan 1 cost <cost>


No comments:

Post a Comment