生成树协议(STP 一)
- 格式:doc
- 大小:97.50 KB
- 文档页数:8
生成树协议(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 10016 6245 39100 19155 14622 61000 410000 23、选择指定端口在每个网段上,选择1个指定端口首先,根桥上的端口全是指定端口。
非根桥上的指定端口的判断依据如下:根路径成本最低端口所在的网桥的ID值较小端口ID值较小举例:查看生成树状态和端口状态:SW_A#sh spanning-treeVLAN1 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 15We are the root of the spanning treeTopology change flag not set, detected flag not setNumber of topology changes 1 last change occurred 00:03:26 agofrom FastEthernet0/2Times: hold 1, topology change 35, notification 2hello 2, max age 20, forward delay 15Timers: hello 0, topology change 0, notification 0, aging 300Port 1 (FastEthernet0/0) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.1.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.1, designated path cost 0Timers: message age 0, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 106, received 9Port 2 (FastEthernet0/1) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.2.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.2, designated path cost 0Timers: message age 0, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 106, received 10Port 3 (FastEthernet0/2) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.3.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.3, designated path cost 0Timers: message age 0, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 106, received 10SW_A#sh spanning-tree briVLAN1Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0128.0000This bridge is the rootHello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 32768Address cc00.0128.0000Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface DesignatedName 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.3SW_B#sh sp briVLAN1Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0128.0000Cost 19Port 1 (FastEthernet0/0)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768Address cc00.0bd0.0000Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface DesignatedName 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.2SW_B#sh sp*Mar 1 00:05:09.863: %SYS-5-CONFIG_I: Configured from console by consoleSW_B#sh spVLAN1 is executing the ieee compatible Spanning Tree protocolBridge Identifier has priority 32768, address cc00.0bd0.0000Configured hello time 2, max age 20, forward delay 15Current root has priority 32768, address cc00.0128.0000Root port is 1 (FastEthernet0/0), cost of root path is 19Topology change flag not set, detected flag not setNumber of topology changes 1 last change occurred 00:03:56 agofrom FastEthernet0/0Times: hold 1, topology change 35, notification 2hello 2, max age 20, forward delay 15Timers: hello 0, topology change 0, notification 0, aging 300Port 1 (FastEthernet0/0) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.1.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.1, designated path cost 0Timers: message age 1, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 11, received 124Port 2 (FastEthernet0/1) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.2.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0bd0.0000Designated port id is 128.2, designated path cost 19Timers: message age 0, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 135, received 1SW_C#sh spanning-treeVLAN1 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 15Current root has priority 32768, address cc00.0128.0000Root port is 2 (FastEthernet0/1), cost of root path is 19 Topology change flag not set, detected flag not setNumber of topology changes 1 last change occurred 00:04:08 ago from FastEthernet0/0Times: hold 1, topology change 35, notification 2hello 2, max age 20, forward delay 15Timers: hello 0, topology change 0, notification 0, aging 300Port 1 (FastEthernet0/0) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.1.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0d14.0000Designated port id is 128.1, designated path cost 19Timers: message age 0, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 133, received 9Port 2 (FastEthernet0/1) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.2.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.2, designated path cost 0Timers: message age 2, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 13, received 129SW_C#sh sp*Mar 1 00:05:05.019: %SYS-5-CONFIG_I: Configured from console by consoleSW_C#sh sp briVLAN1Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0128.0000Cost 19Port 2 (FastEthernet0/1)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768Address cc00.0d14.0000Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface DesignatedName 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.2SW_D#sh spanning-treeVLAN1 is executing the ieee compatible Spanning Tree protocolBridge Identifier has priority 32768, address cc00.0fb0.0000Configured hello time 2, max age 20, forward delay 15Current root has priority 32768, address cc00.0128.0000Root port is 3 (FastEthernet0/2), cost of root path is 19Topology change flag not set, detected flag not setNumber of topology changes 1 last change occurred 00:04:21 agofrom FastEthernet0/0Times: hold 1, topology change 35, notification 2hello 2, max age 20, forward delay 15Timers: hello 0, topology change 0, notification 0, aging 300Port 1 (FastEthernet0/0) of VLAN1 is blockingPort path cost 19, Port priority 128, Port Identifier 128.1.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0d14.0000Designated port id is 128.1, designated path cost 19Timers: message age 3, forward delay 0, hold 0Number of transitions to forwarding state: 0BPDU: sent 9, received 136Port 2 (FastEthernet0/1) of VLAN1 is blockingPort path cost 19, Port priority 128, Port Identifier 128.2.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0bd0.0000Designated port id is 128.2, designated path cost 19Timers: message age 3, forward delay 0, hold 0Number of transitions to forwarding state: 0BPDU: sent 1, received 143Port 3 (FastEthernet0/2) of VLAN1 is forwardingPort path cost 19, Port priority 128, Port Identifier 128.3.Designated root has priority 32768, address cc00.0128.0000Designated bridge has priority 32768, address cc00.0128.0000Designated port id is 128.3, designated path cost 0Timers: message age 3, forward delay 0, hold 0Number of transitions to forwarding state: 1BPDU: sent 10, received 132SW_D#sh sp*Mar 1 00:04:52.415: %SYS-5-CONFIG_I: Configured from console by console SW_D#sh sp briVLAN1Spanning tree enabled protocol ieeeRoot ID Priority 32768Address cc00.0128.0000Cost 19Port 3 (FastEthernet0/2)Hello Time 2 sec Max Age 20 sec Forward Delay 15 secBridge ID Priority 32768Address cc00.0fb0.0000Hello Time 2 sec Max Age 20 sec Forward Delay 15 secAging Time 300Interface DesignatedName 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。