Session 1 STP
The STP (Spanning tree Protocol) is the acronym for the Spanning Tree protocol. This protocol can be used to establish a tree topology in the network, eliminate the loop in the network, and can realize path redundancy through certain methods, but it is not certain that path redundancy can be realized. Spanning tree protocol is suitable for all manufacturers of network equipment, in the configuration and reflect the functional strength of the difference, but in principle and application effect is consistent.
The basic principle of STP is to determine the topology of a network by passing a special protocol message between the switches, the Bridge Protocol Data Unit (bridge, Protocol Data unit, or BPDUs). There are two types of BPDUs, which configure BPDUs (configuration BPDUs) and TCN BPDUs. The former is used to calculate a non-ring spanning tree, which is used to reduce the refresh time of Mac table entries (by default 300s to 15s) when the two-layer network topology changes.
Spanning Tree Protocol (STP) is defined in the IEEE802.1D document. The principle of the Protocol is to construct the network topology according to the structure of the tree, eliminate the loop in the network and avoid the broadcast storm caused by the existence of the loop.
Private in Cisco is the pvst+ spanning tree, STP per VLAN, the protocol that is currently run by all Cisco switches, and a spanning tree for each VLAN, with the same principles and elections as the ieee802.1d.
The basic idea of the Spanning Tree Protocol (STP) is to construct the topological structure of the network according to the structure of the tree, the root of which is a bridge device called the Root bridge, and the root bridge is determined by the bid (bridge ID) of the switch or bridge. The lowest bid device becomes the root bridge in the two-tier network. Bid is also made up of bridge priority and MAC address, and the number of bytes in the bridge priority of different vendors ' devices may be different. Starting with the root bridge, a tree is gradually formed, the root bridge is dispatched to configure BPDUs, the non-root bridge receives configuration BPDUs, and the best bpdus are refreshed and forwarded. The best BPDUs here refer to the BPDUs sent by the current Root bridge. If a subordinate BPDU is received (the newly-accessed device sends BPDUs, but the device's bid is larger than the current root bridge), the device that receives the subordinate BPDU sends its own stored best bpdus to the newly-accessed device to inform its current network of root bridges, and if the received BPDUs are better, The spanning tree topology will be recalculated. When the non-root bridge has not received the best bpdus since the last time it received the best BPDU (Max age, default 20s), the port will enter the listening state, the device will generate TCN BPDUs and forward from the root port, and receive the TCN from the specified port. The superior device of the BPDU sends an acknowledgment, and then sends TCN BPDUs to the parent device, which continues until the root bridge, and then the root bridge will carry a tag in the configuration bpdus that it sends to indicate that the topology has changed and that the refresh time of the Cam table entry is reduced from 300s to 15s after all devices in the network have received it. The whole convergence time is about 50s.
Session 2 STP election steps and detailed procedures
I. Election steps and port status in STP
Election steps:
1, election ROOT-SW Root Bridge
2, election root port RP (root ports)
3, election of the specified port DP (Designate Port)
4, The remaining ports are blocked by block
STP election time port status (15s to listening, the election is over):
5 States of the STP
Disabled-It can be understood that the switch port does not have active at this time, Or forcibly close the port or STP for that port. Discard all received data frames, do not learn MAC address, can receive bpdus, but do not do processing. The
Blocking-port listens for BPDUs, but does not forward bpdus, discards all received data frames, discards all received data frames, discards all received data frames, discards all received data frames, discards all received data frames, discards all received data frames, discards all received data frames, does not learn Mac MAC address, nor does it produce any cam table entries.
Listening-Continues 15s, receives and sends BPDUs, does not forward user data, does not produce CAM table entries for that port, and completes STP convergence in this state. In this state, the switch is able to determine the root, and can select the root port, specify the port, non-specified port
Learning-lasts 15s, receives and sends BPDUs, does not forward user data, completes part of the Port's Cam table entry, in order to reduce the flooding that is brought when the user starts to forward the data. (explains why it is possible to communicate after 30 seconds after SW startup)
Forwarding-Receives and sends BPDUs, starting to forward user data.
Second, the structure and effect of BPDUs
BPDUs are the messages used for election in STP, a two-layer data frame that transmits STP information between bridges, by Default,bpdus is sent out every seconds. The switch compares the BPDUs sent by the BPDUs and corresponding interfaces received by each interface, and if the received BPDUs or BPDUs sent from that interface have a lower value, the BPDUs saved by that interface will be replaced. In the STP protocol, the multicast address sent by BPDUs is 0180.c200.0000 (BPDUs), and the BPDU multicast address sent in pvst+ is (0100.0CCC). Cccd-pvst messages)
frame format for BPDUs: 35 bytes 12 fields
Protocol ID (Protocol ID): This value is always 0
Version: 802.1D is 0 to indicate which STP protocol is used (802.1D or pvst+, etc.)
Message type: Configuration BPDUs are 0X00,TCN BPDUs are 0x80
Flags (flag): For TCN-BPDU (topology change network) to announce changes in the topology of the networks to re-elect the spanning tree use
Root ID: The bridge ID of the root bridge indicates who the root is (made up of Priority+mac) and Root-id when the network is first Rootid=bridge Id,root elected.
Bid for IEEE802.1D bid and Cisco private pvst+
IEEE802.1D's bid is a 8Bytes (64bits) consisting of 2 parts, a maximum of 2 bytes for priority, and the last 6 bytes for the MAC address. The MAC address is in hexadecimal notation. Prirotiy value range: 0-65535, default value 32768. Cisco switches are targeted at Priority field Spanning-tree extend System-id This feature generates an extended system ID for the bridge priority (ID is represented by the VLAN number or the instance number of the MST).
Pvst+ 's bid is: The highest 4bits represents the switch priority, and the latter 12bis represents the extended system ID (which can support a range of 4,096 VLANs, generating a separate ID for each LAN). Two fields are added to get the bridge priority. (All instances of Mac use the switch backplane or the smallest Mac in the monitoring engine)
Bid comparison is the first priority, if the same priority, and then compare the Mac, the low value of the party first.
Cost of Path (route cost): The path overhead of sending BPDUs SW to the root bridge
Bridge ID (BID, bridge ID): Each switch will have a BID indicating itself (consisting of the bridge Priority+mac), In 802.1D, at the beginning each bridge is configured BPDUs, and when a switch discovers that the bid in the received BPDU is more appropriate than the root bridge, the switch is not sending BPDUs at this time.
Port ID (Ports ID): Port priority+port number
Message Age: Indicates the number of seconds that have elapsed since the root bridge was issued, and now evolves to add 1 to each bridge, a bit like a TTL value
Max Age (Maximum lifetime): The maximum time the bridge retains the root bridge ID before the root bridge is considered unavailable, a bit like hold time, which is 20 seconds by default and can be manually configured between 6-40s
Hellotime (Hello time): The root bridge sends BPDUs time interval, default is 2 seconds, 2s, can be manually configured between 1-10s
Forward Delay (forwarding delay): The time interval at which the bridge is listening and learning state, the default is 15 seconds, can be manually configured between 4-30s
III. STP election process
A, determine the root Bridge-by bid comparison verdict. In the same two-tier network, elections are required, that is, a broadcast domain is to be elected, and only one root switch (root) can be elected in a network. The priority number in the Birdge-id is the root switch, the priority range is 0-65535, and if the priority is the same, the MAC address is small for the root switch.
B. All non-root bridge switches elect RP (Root Port)-each non-root bridge has and has only one RP(The primary function is to receive and listen for BPDUs on the root bridge.)
1. Compare the cost of each port to root, the port with the minimum cost becomes the RP port, and the overhead is the total path overhead after the port receives the BPDUs of the terminal Bridge, after the sum of this port is accumulated. Cost Same comparison sender BID
2, compare send bid, received in the BPDU send bid the smallest port becomes the RP, responsible for forwarding the root bridge BPDUs of the switch each forwarding will be the bid to replace their own, first priority after the Mac smaller the better, Sender BID the same words compare Port ID
3. Compare the port ID, received in the BPDU, and the ports with the lowest-ID of the terminal become RP. The Port ID consists of 2 bytes. Contains an ordered pair of numbers. The first number is the port priority, and the second number is port. The order of the permutations is not necessarily the same as the physical port order, but the exact number is not the same.
C, all links determine the DP (Design Port)-the port that forwards BPDUs. In each conflict domain that requires an election, it is simply understood that for each of the two ports of the physical line connected to the switch, one to be selected as the specified port, each segment elects a designated port, which ensures that each network segment is linked to the root switch. The peer of the root port must be the specified port (the primary function is to forward bpdus from the bridge)
1, compare 2 ports on the same section of the link to send BPDUs to root cost, the smaller one port becomes DP, if the same and then compare sender BID
2, compare the same section of the link on the 2 port send BPDUs sender BID (sending SW is usually the SW of this port), the smaller one port becomes DP
D, the remaining ports in the network are not all blocks, only accept and listen to BPDUs, but do not send accept data.
Session 3 STP Election example analysis Summary and configuration command
Look at the following topology for an example of STP elections: F is a gigabit link cost=19,e is a 10M link cost=100
The green number is the priority of the port
Problem:
1. What is the convergence time of STP elections?
A: 15 seconds, STP operation of the first stage, the port does not have any electrical signal disable, when the pretext for an electrical signal or no shutdown after conversion to blocking state, after a short period of time may be less than 1 seconds, will be converted to listening state for the election of the spanning tree, including Root, RP, DP, etc., after 15 seconds of listening election completed, the interface into the learning state with 15 seconds to build the cam table (prevent flood), 15 seconds after the interface formally into the forwarding forwarding packet status. So the election time for STP is 15 seconds.
2. How long can stp forward data?
A: 30 seconds, to go through the learning to create the cam table time to enter the forwarding state
3. Who is the root of the network?
A: The selection of A,root is based on the bid in the BPDU of the sender, consisting of Priority+mac, the smaller the priority, the least priority number of a in the topology, so a is elected as root. A, B, c all interfaces send out BPDUs with their own bid at the same time, and when a is elected root, B and C do not send BPDUs.
4, what is the RP in the network? (The RP is always the receiving direction, always the parameter that computes the accepted port, such as which interface receives the BPDU and calculates the path cost for all receive ports on the receiving direction)
A: There is no root port on a, the RP on B is 1 port, the RP on C is 2 port. The election is based on: 1. Compare the port path cost of the receive ports (the port reaches the cost of root). 2, compare send BID. 3, compare Portid,port-priority+mac (small excellent).
A is the root, and the root has no RP.
B Upper: 1 Port of Cost=a 1 port of the cost+b of the 1 mouth of the cost=0+19=19, was selected as RP (where 0 is the default of the root can be omitted, the following is also the same)
The 3-Port cost=a of the 1-port Cost+d of the 3-port cost=19+19+19=57 (since SW receives BPDUs will only store the BPDUs in the interface's cache to the shortest root path, so cost calculates the fastest short reach to root cost, Here Port 3rd is issued from the A1 through the B1 after B4 through the D3 and then sent to B3, where B and D are passed a bpdus, with a bpdus to calculate the RP and DP, after the root election B and C itself no longer send BPDUs, and the right side of the 10M link to reach the root bandwidth is small, So SW will choose a path with large bandwidth by default to calculate cost)
4-Port Cost=a 1-Port Cost+d 4-Port cost=19+19+19=57
C Above: 2 port of Cost=a of the cost+c2 mouth of the cost=0+19, was selected as RP
6-Port Cost=a 1 cost+d11 Mouth cost=0+19+19+100
8-Port Cost=a 1 cost+d10 Mouth cost=0+19+19+100
D Upper: 3 Port: A1 mouth cost+b3 mouth cost=0+19+19 is selected as RP (Cost and 4 ports the same, compared to sendbid (that is, B's bid) B (a) Bpdu,bid is also the same
4 Port: A1 mouth cost+b4 mouth cost=0+19+19
10 Port: A2 mouth cost+c8 mouth cost=0+19+100
11 Port: A2 mouth cost+c6 mouth cost=0+19+100
5. What is DP in the network? Always send (forward) the send-bid of the BPDU port (typically the SW to which the port belongs) and the value of port to root cost as the comparison parameter
A: All ports on the root are DP, so a on 1 port, 2 port is DP
All ports on the non-root SW direct-connect RP are DP. So:
B Top: 3 Port is DP
Remaining compare election dp, rule send send-bid port to root cost
Obviously the bid of B is less than the bid of D, and the bid of C is less than the bid of D. So the 4 port of the B connection D is Dp,d's 4 mouth is naturally blk. The 8 and 6 ports of C are dp,d 10 and 11 are naturally blk.
If the bid of B and C and D are the same (of course not, unless it is the same device, here is just the cost algorithm), using the cost algorithm to calculate:
B above: B4 port and D4 port for comparison, B4 port send cost=19,d4 send cost=19+19 (d4+b1 cost), B4 port for DP
C Above: C6 Port and D11 port comparison, C6 port send cost=19,d11 port send cost=100+19,c6 port is selected as DP
C8 Port and D10 port comparison, C8 port send cost=19,d10 port send Cost=100+19,c8 port is selected as DP
D above: 10 port and 11 port send direction can only walk C, so D above except 3 RP outside are block, only receive bpdus but not processing, do not receive data frame.
The above root, RP, DP are all elections completed, the entire STP election process is over, enter the learning state to build the cam table
6. How long does it take for the network topology change to converge again?
A: 50 seconds, because the SW interface stores BPDUs The default time is 20 seconds, and then re-start the STP election after 30 seconds, so the topology changes need 50 seconds to switch to normal forwarding data.
7, modify what value can change the RP and DP
Answer: Cost, Bandwiteh
Summary: 1, Root on all interfaces are DP
2, the RP oriented (face to the direction of BPDUs), DP back BPDU data flow direction of transmission
3. Block port does not process data but listens for BPDUs
4. When the topology changes, STP forces the Cam table cache to clear during the election (15S)
Configuration commands for STP:
1. Enable spanning Tree command
Switch (config) #spanning-tree VLAN vlan-list
You can also turn off the spanning tree for a VLAN by adding no to this command.
2. Configure the root bridge command
Switch (config) #spanning-tree vlan vlan-list Root Primary | Secondary
You can use this command to specify the root bridge of the switch, and if configured as primary, the switch's priority becomes 24576, configured as secondary, and the priority becomes 28672, fixed.
3, modify the priority of the bridge
Switch (config) #spanning-tree VLAN vlan-list priority 4096
4. Modify Port Cost
swithc (config) #spanning-tree vlan vlan-list cost 19
5. Modify Port Priority
Switch (config) #spanning-tree VLAN vlan-list port-priority 64
6, configure the stroke speeds link
Switch (config) #spanning-tree uplinkfast
7. Configure the speed port
Switch (config-if) #spanning-tree portfast
8. View the configuration of the spanning tree
Switch#show Spanning-tree
9. View spanning tree details for a VLAN
Switch#show Spanning-tree VLAN Vlan-id Brief
10, the configuration of the Ethernet channel
Switch (config) #interface range fastethernet 0/1-2
Switch (config-if-range) #channel-group 1 mode on
Creating a Port-channel Interface Port-channel 1 appears this message indicates a successful configuration
11. View the configuration of the Ethernet channel
Switch#show EtherChannel 1 Summary
The above configuration without VLAN option is valid for all VLANs, ieee802.1d default is not all VLANs are in effect, while pvst+ is a single VLAN that can implement multi-VLAN load to reduce bandwidth pressure.
Session 4 TCN-BPDU
When the forwarding port is closed (for example, blocked) or a port is converted to a forwarding state when the switch has a specified port, the switch considers itself to have detected a topology change. If a change is detected, the switch notifies the root bridge of the spanning tree. The root bridge then broadcasts the information to the entire network.
In a regular STP run, the switch configures the BPDU frames from the root bridge through the root port. However, it will never emit bpdus to the root bridge. In order to be able to notify the root bridge, people introduced a special BPDU called Topology Change notification (Tcn,topology Notification) BPDUs. When the switch needs to emit a topology change signal, it begins to send TCN through the root port, and the receiving switch (called the designated Bridge) immediately echoes the regular BPDU with the topology Change acknowledgment (TCA) bit set to confirm receipt of the TCN, which continues until the root bridge responds. TCN is a very simple BPDU that is sent at the Hello interval, which does not contain any information.
Normally, the switch will only receive configuration BPDU packets from its root port, but will never send the configuration BPDU packet to root bridge. There is a need to mention the second type of BPDU packet, which is topology change Notification (TCN) BPDUs. This way, when a switch detects a topology change, it can send TCN to root bridge, noting that TCN is sent to Root bridge via ROOT port. When the switch receives the TCN class BPDU from its designate port, it must forward it, sending out the TCN type of BPDU packet from its own root port, so that the TCN task is completed after the first level is uploaded to Root bridge. In the above process, regardless of which switch received the TCN type of BPDU packet from its designate port, it must give a reply, which must emit a TCA bit 1 of the normal configuration BPDU packet from the designate port, Note that this is the normal configuration BPDU package. Its TCA bit is set to 1, indicating that it is to give TCN a reply, but it is not a type of package with TCN. Then when the TCN is spread across the entire network, until the root bridge is reached, Root bridge also responds, it sends a normal configuration BPDU packet, of course, there are some differences, the TC field within the package will be set to 1, The TC is the topology change, which indicates the discovery of topology changes. This package will be forwarded by all switches, the same TC bit will be set to 1, until the entire network, all switches are aware of the topology changes.
Configuration BPDUs: Flows outward from the root bridge along the active path. The switch will always send configuration bpdus on each of its ports until better configuration BPDUs are received. If the neighbor stops sending these better bpdus, then 20 seconds later the switch sends BPDUs from that port
Configuration BPDUs originated by root Bridge, configuring BPDUs is rooted id=bid
Topology Change Notification (TCN) BPDUs: Flows along the active path to the root bridge, and the primary function is to notify the root bridge that the current active topology has changed. If there is no TCN BPDU then the topology changes, the convergence rate is not 50 seconds, but 300 seconds (mac-address-table aging-time) topology change notication bpdus alert the Root Bridge that the active topology has changed.
Final: Summary of the focus
1. All RPS are used to receive BPDUs
2. All DP is used to send BPDUs
3. All SW receives a BPDU that is smaller than its own bid priority and stops sending its own bpdus and forwards its bpdus to the other SW for the lower-priority SW
LAYER2-STP Spanning Tree Protocol