取消
显示结果 
搜索替代 
您的意思是: 
cancel
3609
查看次数
0
有帮助
2
评论
guller
Level 1
Level 1
生成树协议的出现是因为链路中有备份线路,而这种备份线路容易给网络造成环路,消耗设备性能,甚者网络出现down机。
思科交换设备默认开启生成树,大家可以放心食用。
那生成树是怎么防止环路的出现呢?
接下来欢迎走进《科学与探索》节目,带你了解生成树工作的奥秘。
120233hc3uiezfcfdsi6wu.png
我们在packet tracer中拉2台交换机,
启动设备后发现一个橙色的点点,
为啥其他端口都亮,而下面这个端口显示橙色呢?
这就是因为生成树的关系,这个端口被生成树给block,不是处于转发状态。
那生成树是什么呢?我们来瞅瞅。
在sw0 sw1上输入 show spanning-tree来看下它有哪些内容。
sw0#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0060.4750.7E4D
Cost 4
Port 1(GigabitEthernet1/0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 00D0.D34C.79A6
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi1/0/2 Altn BLK 4 128.2 P2p
Gi1/0/1 Root FWD 4 128.1 P2p
sw0#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 0060.4750.7E4D
Cost 4
Port 1(GigabitEthernet1/0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 00D0.D34C.79A6
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi1/0/2 Altn BLK 4 128.2 P2p
Gi1/0/1 Root FWD 4 128.1 P2p
发现输出的内容有 Root ID,Bridge ID,以及端口信息。
其中root id 内容一样,而 bridge ID 不同,且 sw0 中 g1/0/2接口是处于block状态。
接着来看下bridge id 信息,
其中两台设备的优先级都是一样,但是sw0的mac地址比sw1要小,
sw0_bridge_mac:0060.4750.7E4D
sw1_bridge_mac:00D0.D34C.79A6
*这是生成树选举根桥的一个条件,也是为啥没有block sw1端口的原因,
因为sw1说俺mac地址小,俺是根桥,不能阻塞我的端口,要阻塞的话,阻塞你自己的*
生成树中有根桥/非根桥的概念。
那既然根桥是sw1,那么sw0就是非根桥设备
接下来咱们来看看非根桥sw0
端口2委屈地对生成树爸爸说,“为啥是我被block,为什么不block端口1”
生成树爸爸摸着端口2的头说,因为你是老二啊。
端口2(黑脸问好???)
咱们来对比下生成树中端口1与端口2的区别
sw0#show spanning-tree detail
VLAN0001 is executing the ieee compatible Spanning Tree Protocol
Bridge Identifier has priority of 32768, sysid 1, 00D0.D34C.79A6
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32769
Root port is 1 (GigabitEthernet1/0/1), cost of root path is 4
Topology change flag not set, detected flag not set
Number of topology changes 0 last change occurred 00:00:00 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 (GigabitEthernet1/0/1) of VLAN0001 is root forwarding
Port path cost 4, Port priority 128, Port Identifier 128.1
Designated root has priority 32769, address 0060.4750.7E4D
Designated bridge has priority 32769, address 0060.4750.7E4D
Timers: message age 16, forward delay 0, hold 0
Number of transitions to forwarding state: 1
Link type is point-to-point by default
Port 2 (GigabitEthernet1/0/2) of VLAN0001 is alternate blocking
Port path cost 4, Port priority 128, Port Identifier 128.2
Designated root has priority 32769, address 0060.4750.7E4D
Designated bridge has priority 32769, address 0060.4750.7E4D
Timers: message age 16, forward delay 0, hold 0
Number of transitions to forwarding state: 1
Link type is point-to-point by default
发现几个参数都一样,只是端口号不一样,难不层就是因为端口号的原因,大的被block?
咱们先这么认为吧,我们去改些参数去对比下。
第一个cost,两边都一样,我们把端口1的cost改大些再对比下。
int g1/0/1
spanning-tree cost 3
show spanning-tree detail
发现改了不生效。
嗯?啷个回事嘛?
难道这个cost以及priority是线路接口属性,改不了?
没事,咱们给他换个线,使用F口与G口来对比下。
设备还是2台设备,重新拉线。
124929g987ssussnn0ztyy.png
还说先看下spanning-tree的属性。
发现sw0的bridge ID Mac地址小,被选为根桥。
再对比下非根桥sw1的端口属性。
sw1#show spanning-tree de
VLAN0001 is executing the ieee compatible Spanning Tree Protocol
Bridge Identifier has priority of 32768, sysid 1, 0030.A334.D241
Configured hello time 2, max age 20, forward delay 15
Current root has priority 32769
Root port is 25 (GigabitEthernet0/1), cost of root path is 4
Topology change flag not set, detected flag not set
Number of topology changes 0 last change occurred 00:00:00 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/1) of VLAN0001 is alternate blocking
Port path cost 19, Port priority 128, Port Identifier 128.1
Designated root has priority 32769, address 0001.9782.8AC8
Designated bridge has priority 32769, address 0001.9782.8AC8
Timers: message age 16, forward delay 0, hold 0
Number of transitions to forwarding state: 1
Link type is point-to-point by default
Port 25 (GigabitEthernet0/1) of VLAN0001 is root forwarding
Port path cost 4, Port priority 128, Port Identifier 128.25
Designated root has priority 32769, address 0001.9782.8AC8
Designated bridge has priority 32769, address 0001.9782.8AC8
Timers: message age 16, forward delay 0, hold 0
Number of transitions to forwarding state: 1
Link type is point-to-point by default
发现g口的cost小,且f口是处于blocking状态。
说明blocking状态受cost影响,生成树爸爸会block cost值大的端口。
*在非根桥设备中,接口cost值小会被选为生成树指定根端口*
原来是介样,上面的端口2心服口服的说道。
总结:
在生成树中会首先选择根桥,即bridge ID 中Mac地址小的设备。
在非根桥选择cost值小的端口为指定端口,
将非指定端口block,禁止它处于转发状态,不然会处于环路状态。
那这样设备之间拉多条线不是很浪费?只有1条线处于转发状态。
别怕,大兄弟,思科爸爸为你准备了“端口聚合”套餐,请收纳。
啥是端口聚合?
咱们下回继续走进《科学与探索》栏目来一探究竟。
评论
18653465190
Spotlight
Spotlight
受教了楼主,谢谢
one-time
Level 13
Level 13
感谢楼主分享,谢谢~
恭喜您获得#2019倒计时#年末回顾梳理,分享赢定制台历活动奖励 - 2020定制台历一本!
入门指南

使用上面的搜索栏输入关键字、短语或问题,搜索问题的答案。

我们希望您在这里的旅程尽可能顺利,因此这里有一些链接可以帮助您快速熟悉思科社区:









快捷链接