STP Spanning tree protocol
Trunk port : A trunk port is a port that is assigned to carry traffic for all the VLANs that are accessible by a specific switch, a process known as trunking. Trunk ports mark frames with unique identifying tags - either 802.1Q tags or Interswitch Link (ISL) tags - as they move between switches. Therefore, every single frame can be directed to its designated VLAN. Access port : A access port re tags the traffic which it receives and send them. It is used to tag traffic which don’t have tag already. But it is also used to add some security as well. End user pcs are good example.
Why STP? The core lan switch logic would literally forward a frame around lan forever with out some external method like STP. Lan switch forwarding method: Process is divided into 3 steps Step1: Determination of Vlan in which the frame should be forwarded. A ) If the frame arrives on access interface, use interface access vlan. B) if the frame arrives on a trunk interface, use vlan listed in frame trunking header.
Step 2 : add the source mac address to mac address table, with incoming interface and vlan id. Step 3 : Look for the destination Mac address of the frame in mac address table but only for entries in the vlan identified at step1. A) if it found destination mac address forward the frame B) if not found then flood the frame around all access ports in same vlan and also on all trunk ports.
VLAN1 VLAN2 VLAN3 Fa0/11 Fa0/12 Fa0/16 Fa0/15 Fa0/13 Fa0/14
Viewing Mac address table: Command used to find out mac address table is show mac address-table dynamic Gi0/1 Gi0/2 Gi0/ Fa0/13Fa0/12 Fa0/9 SUNIL SID SW1SW2
SW1: show mac address-table dynamic Mac address table VlanMac addressTypePorts ???
Displaying interfaces and vlans: To find out all switch interfaces and their current status also which Vlan it belongs to we use following commands A) show interfaces status B) show vlan brief Need for Spanning tree: STP prevents three common problems 1) broadcast storms 2) Mac table instability 3)Multiple copies of frame arriving at destination
Broadcast storms: Broadcast storm happens if a frame loops around network causing disruption. It happens when broadcast, unicast, multi-cas or unknown- destination unicast frames loop around network indefinitely. When broadcast storm happens frames loop around network until something changes like, someone shuts down interface, reloads a switch, or do something else to break loop.
Fa0/13 Gi0/2 Gi0/1 Bob ALICE LARRY G0/1 GI0/2 Fa0/11 Fa0/12 Broadcast storm example sw3 sw1 sw2
Mac address instability: Switches mac address tables will keep changing for the information listed for source. Because of unknown mac address packets will be doubled and sent out to destination with multiple packets, which could ultimately confuse actual receiver and could do potential application failure.
Fa0/13 Gi0/2 Gi0/1 Bob ALICE LARRY G0/1 GI0/2 Fa0/11 Fa0/12 Broadcast storm example sw3 sw1sw2 Implementation of spanning tree protocol
Stp prevents loops by placing one of the ports in forward state and other in blocking state Interface in the forward state acts normal, receives and forwards frames. But interface in blocking state wont receive or forward any packets and it wont learn new mac addresses. Except some overhead messages. Example : bob sends frame to sw3. Sw3 forwards to sw1 but not sw2. Sw1 forwards frames to fa0/11 and gi0/1. Sw2 forwards to f0/12 and gi0/2 but it will be dropped since port is in blocking mode.
Questions remain are….. How does stp keeps port in forward or blocking stage? What if some thing changes in network scenario like outages? How network converges and changes according to network needs ? How does it converges from blocking mode to forward mode.
The Logic (STA) The logic behind stp is STA ( spanning tree algorithm) is what chooses if switch port should be in forwarding state or blocking state. In process first stp elects root switch and keeps all working interfaces on forwarding state. Each nonroot switch consists of ports to have least administrative cost to root switch is called switche’s root cost. That port is called root port and stp keeps it in forward mode In modern network two switches connect to each link. The switch with lowest cost, as compared with other switches attached to the same link, is placed in forwarding state.
Electing root switch: Switch BID is 8-bit value which is unique for any switch first 2-bytes are priority field and 6-bytes are mac address hardcoded into switch which is unique and wont change. Switches exchange information using hello packets which are also called BPUD ( bridge protocol data units ) called hello BPUD. Switches elects the root switch based on value of BID in BPUD hello packets. The switch with lowest BID wins and becomes master switch, by finding out the lowest priority in BID first 2 bytes.
If switch with the priority value 1056 and another with priority 4356 then irrespective of what mac address it binded to switch with value 1056 will be elected as root switch. If the priorities are same then the comparison between mac address will go on and the BID with low mac address will be master switch. This process begins with all switches first announcing them as root switch by sending hello BPDU’s and root BID. if a switch hears better BPUD then its then it stops announcing it as master and follows that switch. If there is tie occur in BID priority, then tie breaker will be used in this occasion mac address portion of Bid is tie breaker. The lowest mac address wins and there will be no more tie breaker needed because mac address is unique.
Root cost: 0 My BID 32,769: Root BID: 32,769: Gi0/1 Gi0/2 Gi0/1 Gi0/2 Root cost: 0 My BID 32,769: Root BID: 32,769: Root cost: 4 My BID 32,769: Root BID: 32,769: Root cost: 0 My BID 32,769: Root BID: 32,769:
Root cost: 0 My BID 32,769: Root BID: 32,769: Gi0/1 Gi0/2 Gi0/1 Gi0/2 Root cost: 0 My BID 32,769: Root BID: 32,769: Root cost: 4 My BID 32,769: Root BID: 32,769: Root cost: 5 My BID 32,769: Root BID: 32,769: Root cost: 0 My BID 32,769: Root BID: 32,769:
Choosing switch’s root port: After election process each non root switch work is to select one root port, by choosing lowest stp cost to reach root switch Switch add its local interface stp cost to root cost which received in hello BPDU. STP port cost is simply nothing but integer which attached to each integer. Switch also looks at its neighbor’s root cost as announced in hello BPDUs received from each neighbor. In complex situations the choice of root port is not so obvious, in this case they use tie breakers to solve root cost’s tie.
Root cost: 0 Gi0/1 Gi0/2 Gi0/1 Gi0/2 Interface cost 5 + Root cost 0 = 5 hello Root cost: 4 Interface cost 4 + root cost 4 = 8 Root cost: =4 Root cost out G0/1 is 5 Root cost out G0/2 is 8 Root cost out G0/2 is 4 Root
Choosing designated port: This is final step in STP topology. The Designated port (DP) on each LAN segment is the switch port that advertises the lowest-cost hello onto a LAN segment. When a non root switch forwards a hello, the nonroot switch sets the root cost field in the hello to that switch cost to reach the root, in effect, the switch with the lower cost to reach the root, among all switches connected to a segment, becomes the DP on the segment. STP topology wont happen once and stay like that in network. Scenarios will change when ever network outages
Hello packetThe time period between hellos created by the root 2 seconds Max AgeHow long any switch should wait, after ceasing to hear hellos, before trying to change the STP topology. 10 time hello Forward delayDelay that affects the process that occurs when an interface changes from blocking state to forwarding state. 15 seconds In forward delay ports first convert to listening mode and then only it will convert to forward state.
Changing interface states with STP When any switch is deleted from network or some thing else is happened in network then network changes will happen. Then other switch DP and RP will change. Sometimes from blocking state ports will come to forward stage by converging through two step process, listening and learning. In listening mode switch does not forward any packets like blocking port. But switches remove old stale mac address. These stale mac address could be caused by temporary loops. In learning state switch still do not forward frames but it will start learning mac address of frames received on the frame.
RSTP: The only difference between STP and RSTP is convergence. With default settings STP takes around 50 seconds by default to converge where as this can be reduced down to 2 or 3 seconds using RSTP. At worst case scenarios it will take around 10 seconds to converge for RSTP. There are optional features in STP like Etherchannel, Portfast, BPDU guard which STP can take advantage of