网络通信 频道

STP生成树连载4:制服网络广播风暴

【IT168 专稿】要保证企业的网络中的关键应用可持续性,就需要对交换网络进行冗余设计,然而这将产生广播风暴、“网络环路”等问题,严重时,将导致整个网络瘫痪?于是,STP生成树解决办法出现了……

 
 网络冗余设计与广播风暴的矛盾
广播风暴的克星:设计STP网络生成树
技术剖析:STP生成树初始化与收敛
实战剖析:STP生成树如何配置?
技术进化:RSTP快速生成树配置
 
观察生成树收敛过程

 
经过上面的分析,引入一棵无环路树,拓扑结构如图8-13所示。交换机3台,全部为默认配置,将3台交换机连接环路。

1.Show spanning-tree的结果
下面通过观察各个交换机生成树的状态来分析无环路树的形成。
 
图8-13 网络拓扑图
 
 
SW-1#show spanning-tree
 VLAN1 is executing the ieee compatible Spanning Tree protocol
 Bridge Identifier has priority 32768, address cc01.0458.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 3 last change occurred 00:02:02 ago
          from FastEthernet0/1
 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc01.0458.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 677, received 1
 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc01.0458.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 679, received 10
 
SW-2#show spanning-tree
 VLAN1 is executing the ieee compatible Spanning Tree protocol
 Bridge Identifier has priority 32768, address cc02.0628.0000
 Configured hello time 2, max age 20, forward delay 15
 Current root has priority 32768, address cc01.0458.0000        //当前桥为SW-1
 Root port is 1 (FastEthernet0/0), cost of root path is 19          //根端口是F0/0
 Topology change flag not set, detected flag not set
 Number of topology changes 1 last change occurred 00:02:22 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc01.0458.0000
   Designated port id is 128.1, designated path cost 0         //指定端口SW-1的F0/0
   Timers: message age 1, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 1, received 72
 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc02.0628.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 70, received 3
 
SW-3#show spanning-tree
 VLAN1 is executing the ieee compatible Spanning Tree protocol
 Bridge Identifier has priority 32768, address cc03.07f4.0000
 Configured hello time 2, max age 20, forward delay 15
 Current root has priority 32768, address cc01.0458.0000        //当前根桥为SW-1
 Root port is 1 (FastEthernet0/0), cost of root path is 19                 //根端口是F0/0
 Topology change flag not set, detected flag not set
 Number of topology changes 2 last change occurred 00:01:16 ago
          from FastEthernet0/1
 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc01.0458.0000   //指定网桥为SW-1
   Designated port id is 128.2, designated path cost 0                //指定端口是SW-1 端口ID是128.2
   Timers: message age 1, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 10, received 236
 
 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 cc01.0458.0000
   Designated bridge has priority 32768, address cc02.0628.0000  //指定桥是SW-2
   Designated port id is 128.2, designated path cost 19 //指定端口是SW-2 端口ID是128.2
   Timers: message age 2, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 197, received 36
 
2.按照“STP 四步初始化原则”的计算结果
 
按照“STP 四步初始化原则”,上述3台交换机形成一个无环路生成树,经过4个阶段的比较。根据最低的根BID比较选举SW-1 为根桥,如表8-8所示;根据最低的路径开销到根桥的比较,各交换机端口的开销如表8-9所示;根据最低的发送方BID比较,可以看出SW-1<SW-2<SW-3 ,说明SW-2的F0/1为指定端口;从Show信息中可以看到,端口ID F0/0 为128.1 ,端口ID F0/1为128.2,依此类推。
 
表8-8 BID的比较
交换机BID
BID值
SW-1 BID
32768-cc01.0458.0000
SW-2 BID
32768-cc02.0628.0000
SW-3 BID
32768-cc03.07f4.0000
表8-9 根路径开销比较
交 换 机
   
到根桥的开销
根端口结果
指定端口结果
SW-1
FastEthernet 0/0
0
 
指定端口
FastEthernet 0/1
0
 
指定端口
SW-2
FastEthernet 0/0
19+0
根端口
 
FastEthernet 0/1
19+19
 
指定端口
SW-3
FastEthernet 0/0
19+0
根端口
 
FastEthernet 0/1
19+19
 
阻断端口
 
3.按照生成树收敛的3个步骤

 
如图8-14所示,首选选择SW-1为根桥(Root Bridge),然后选择根端口(Root Ports),最后确定指定端口(Designated ports)。

 
每台非根桥选择一个根端口,对于SW-2,端口F0/0的根路径为19+0,端口F0/1为19+19,所以根端口为F0/0;对于SW-3,端口F0/0也是19+0,端口F0/1为19+19,所以F0/0为根端口。
 
图8-14  一个简单的无环路生成树
 
每个以太网段均有一个指定端口,SW-1和SW-2的网段很明显,SW-1的F0/0端口为指定端口,同理SW-1的F0/1为SW-1和SW-2之间网段的指定端口,对于SW-2和SW-3的网段;SW-2的F0/1的根路径为38,SW-3的F0/1端口的根路径也为38,必须再次比较Sender ID,也就是交换机的BID,SW-2的BID小于SW-3的BID,所以SW-2的F0/1端口为指定端口。
 
4.拓扑改变后的收敛
关闭SW-3的F0/0口,该端口原为根端口,转发数据,关闭后可以利用debug spanning-tree events命令分析STP拓扑改变时的变化。请注意在调试完成之后需要停止debug信息,通过no debug all或undebug all命令来停止调试。
 
SW-3#debug spanning-tree events //调试命令,记录STP事件
SW-3# configure terminal
SW-3(config)#int f0/0
SW-3(config-if)# shutdown //关闭F0/0
SW-3(config-if)#
*Mar 1 00:10:21.395: STP: VLAN1 Fa0/0 -> blocking     //F0/0进入阻断状态
*Mar 1 00:10:21.399: STP: VLAN1 new root port Fa0/1, cost 38    //F0/1为新的根端口
*Mar 1 00:10:21.551: STP: VLAN1 Fa0/1 -> listening      //F0/1进入监听状态)
*Mar 1 00:10:23.251: STP: VLAN1 sent Topology Change Notice on Fa0/1   //因为F0/1为新的根端口,所以可以发送TCN
*Mar 1 00:10:36.559: STP: VLAN1 Fa0/1 -> learning      //10:36-10:21=15秒延时
*Mar 1 00:10:51.603: STP: VLAN1 Fa0/1 -> forwarding //10:51-10:36=15秒延时
SW-2 收到TCN,同时向根传播TCN。
SW-2# debug spanning-tree events      //调试STP事件
*Mar 1 00:12:18.655: STP: VLAN1 Topology Change rcvd on Fa0/1
*Mar 1 00:12:18.659: STP: VLAN1 sent Topology Change Notice on Fa0/0   //TCN从根端口发出
最后,SW-1收到从F0/0收到TC。
SW-1# debug spanning-tree events       //调试STP事件
*Mar 1 00:20:31.127: STP: VLAN1 Topology Change rcvd on Fa0/0
0
相关文章