生成树协议(STP 一)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
生成树协议(STP)原理
在许多交换机或交换机设备组成的网络环境中,通常都使用一些备份连接,以提高网络的健全性、稳定性。
备份连接也叫备份链路、冗余链路等。
备份链路使网络存在环路,环路问题是备份链路所面临的最为严重的问题,环路问题将会导致:
广播风暴
多帧复制
MAC地址表的不稳定
在局域网通信中,为了能确保网络连接可靠性和稳定性,常常需要网络提供冗余链路。
当一条通信信道遇到堵塞或者不畅通时,就启用备份链路。
为了解决冗余链路引起的问题,IEEE通过了IEEE 802.1d协议,即生成树协议
生成树协议的发展过程划分成三代。
第一代生成树协议:STP/RSTP
第二代生成树协议:PVST/PVST+
第三代生成树协议:MISTP/MSTP
一、STP工作原理
术语:
Bridge ID:每个交换机唯一的桥ID,由桥优先级和Mac地址组合而成(优先级+MAC地址);Root path cost:交换机到根交换机的路径花费,以下简称根路径花费;
Port ID:每个端口ID,由端口优先级和端口号组合而成;
BPDU:交换机之间通过交换BPDU(Bridge Protocol Data Units,交换机协议数据单元)帧来获得建立最佳树形拓扑结构所需要的信息。
STP将一个环形网络生成无环拓朴的步骤:
选择根网桥(Root Bridge)
选择根端口(Root Ports)
选择指定端口(Designated Ports)
1、选择根网桥
网桥ID是唯一的,交换机之间选择BID值最小的交换机作为网络中的根网桥
选择根网桥的目的是为了给将生成的树形结构确定一个树根
2、选择根端口
在非根网桥上选择一个到根网桥最近的端口作为根端口
选择根端口的依据是:
根路径成本最低(是网桥到根网桥的路径上所有链路的成本之和);
直连的网桥ID最小;
端口ID最小;
路径成本根据链路带宽的高低规定:
链路带宽(Mb/s)路径成本
10 100
16 62
45 39
100 19
155 14
622 6
1000 4
10000 2
3、选择指定端口
在每个网段上,选择1个指定端口
首先,根桥上的端口全是指定端口。
非根桥上的指定端口的判断依据如下:
根路径成本最低
端口所在的网桥的ID值较小
端口ID值较小
举例:
查看生成树状态和端口状态:
SW_A#sh spanning-tree
VLAN1 is executing the ieee compatible Spanning Tree protocol Bridge Identifier has priority 32768, address cc00.0128.0000 Configured hello time 2, max age 20, forward delay 15
We are the root of the spanning tree
Topology change flag not set, detected flag not set
Number of topology changes 1 last change occurred 00:03:26 ago
from FastEthernet0/2
Times: hold 1, topology change 35, notification 2
hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0, aging 300
Port 1 (FastEthernet0/0) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.1.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.1, designated path cost 0
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 106, received 9
Port 2 (FastEthernet0/1) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.2.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.2, designated path cost 0
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 106, received 10
Port 3 (FastEthernet0/2) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.3.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.3, designated path cost 0
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 106, received 10
SW_A#sh spanning-tree bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address cc00.0128.0000
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 32768
Address cc00.0128.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0 128.1 128 19 FWD 0 32768 cc00.0128.0000 128.1 FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0128.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 32768 cc00.0128.0000 128.3
SW_B#sh sp bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address cc00.0128.0000
Cost 19
Port 1 (FastEthernet0/0)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0bd0.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0 128.1 128 19 FWD 0 32768 cc00.0128.0000 128.1 FastEthernet0/1 128.2 128 19 FWD 19 32768 cc00.0bd0.0000 128.2
SW_B#sh sp
*Mar 1 00:05:09.863: %SYS-5-CONFIG_I: Configured from console by console
SW_B#sh sp
VLAN1 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.0bd0.0000
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address cc00.0128.0000
Root port is 1 (FastEthernet0/0), cost of root path is 19
Topology change flag not set, detected flag not set
Number of topology changes 1 last change occurred 00:03:56 ago
from FastEthernet0/0
Times: hold 1, topology change 35, notification 2
hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0, aging 300
Port 1 (FastEthernet0/0) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.1.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.1, designated path cost 0
Timers: message age 1, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 11, received 124
Port 2 (FastEthernet0/1) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.2.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0bd0.0000
Designated port id is 128.2, designated path cost 19
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 135, received 1
SW_C#sh spanning-tree
VLAN1 is executing the ieee compatible Spanning Tree protocol Bridge Identifier has priority 32768, address cc00.0d14.0000 Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address cc00.0128.0000
Root port is 2 (FastEthernet0/1), cost of root path is 19 Topology change flag not set, detected flag not set
Number of topology changes 1 last change occurred 00:04:08 ago from FastEthernet0/0
Times: hold 1, topology change 35, notification 2
hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0, aging 300
Port 1 (FastEthernet0/0) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.1.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0d14.0000
Designated port id is 128.1, designated path cost 19
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 133, received 9
Port 2 (FastEthernet0/1) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.2.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.2, designated path cost 0
Timers: message age 2, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 13, received 129
SW_C#sh sp
*Mar 1 00:05:05.019: %SYS-5-CONFIG_I: Configured from console by console
SW_C#sh sp bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address cc00.0128.0000
Cost 19
Port 2 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0d14.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0 128.1 128 19 FWD 19 32768 cc00.0d14.0000 128.1 FastEthernet0/1 128.2 128 19 FWD 0 32768 cc00.0128.0000 128.2
SW_D#sh spanning-tree
VLAN1 is executing the ieee compatible Spanning Tree protocol
Bridge Identifier has priority 32768, address cc00.0fb0.0000
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32768, address cc00.0128.0000
Root port is 3 (FastEthernet0/2), cost of root path is 19
Topology change flag not set, detected flag not set
Number of topology changes 1 last change occurred 00:04:21 ago
from FastEthernet0/0
Times: hold 1, topology change 35, notification 2
hello 2, max age 20, forward delay 15
Timers: hello 0, topology change 0, notification 0, aging 300
Port 1 (FastEthernet0/0) of VLAN1 is blocking
Port path cost 19, Port priority 128, Port Identifier 128.1.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0d14.0000
Designated port id is 128.1, designated path cost 19
Timers: message age 3, forward delay 0, hold 0
Number of transitions to forwarding state: 0
BPDU: sent 9, received 136
Port 2 (FastEthernet0/1) of VLAN1 is blocking
Port path cost 19, Port priority 128, Port Identifier 128.2.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0bd0.0000
Designated port id is 128.2, designated path cost 19
Timers: message age 3, forward delay 0, hold 0
Number of transitions to forwarding state: 0
BPDU: sent 1, received 143
Port 3 (FastEthernet0/2) of VLAN1 is forwarding
Port path cost 19, Port priority 128, Port Identifier 128.3.
Designated root has priority 32768, address cc00.0128.0000
Designated bridge has priority 32768, address cc00.0128.0000
Designated port id is 128.3, designated path cost 0
Timers: message age 3, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 10, received 132
SW_D#sh sp
*Mar 1 00:04:52.415: %SYS-5-CONFIG_I: Configured from console by console SW_D#sh sp bri
VLAN1
Spanning tree enabled protocol ieee
Root ID Priority 32768
Address cc00.0128.0000
Cost 19
Port 3 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32768
Address cc00.0fb0.0000
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID -------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0 128.1 128 19 BLK 19 32768 cc00.0d14.0000 128.1 FastEthernet0/1 128.2 128 19 BLK 19 32768 cc00.0bd0.0000 128.2 FastEthernet0/2 128.3 128 19 FWD 0 32768 cc00.0128.0000 128.3。