实验拓扑:
SWA:
<Huawei>system-view
[Huawei]sysname SWA
[SWA]stp enable
[SWA]stp mode stp #stp协议的类型为传统stp
[SWA]stp priority 4096 #修改优先级为4096
SWB:
<Huawei>system-view
[Huawei]sysname SWB
[SWB]stp enable
[SWB]stp mode stp
[SWB]stp priority 8192
SWC:
<Huawei>system-view
[Huawei]sysname SWC
[SWC]stp enable
[SWC]stp mode stp
SWD:
<Huawei>system-view
[Huawei]sysname SWD
[SWD]stp enable
[SWD]stp mode stp
查看STP状态
在SWA和SWB上使用命令display stp
查看STP状态时,系统输出的信息,我们从红色字体部分可以看出全局STP的模式(本例中是STP),以及根网桥的BID(4096 .4c1f-cc00-4389
)。如果根网桥BID
与本地交换机BID相同,说明本地交换机就是这个STP域中的根网桥。
SWA:
[SWA]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc00-4389
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 0 CIST RegRoot/IRPC :4096 .4c1f-cc00-4389 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :35
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:32s
Number of TC :21
Last TC occurred :Ethernet0/0/1
SWB:
[SWB]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :8192 .4c1f-cc1b-0ee2
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 200000
CIST RegRoot/IRPC :8192 .4c1f-cc1b-0ee2 / 0
CIST RootPortId :128.1
BPDU-Protection :Disabled
TC or TCN received :99
TC count per hello :1
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:0s
Number of TC :20
Last TC occurred :Ethernet0/0/1
SWC:
[SWC]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-ccde-050d
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 200000
CIST RegRoot/IRPC :32768.4c1f-ccde-050d / 0
CIST RootPortId :128.1
BPDU-Protection :Disabled
TC or TCN received :206
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:1m:3s
Number of TC :15
Last TC occurred :Ethernet0/0/1
SWD:
[SWD]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-ccd3-277b
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 200000
CIST RegRoot/IRPC :32768.4c1f-ccd3-277b / 0
CIST RootPortId :128.1
BPDU-Protection :Disabled
TC or TCN received :227
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:1m:44s
Number of TC :13
Last TC occurred :Ethernet0/0/1
查看STP端口角色
使用命令display stp brief
查看一下几台交换机上的STP端口角色,在SWA上,我们可以看到三个端口都是指定端口(DESI
),状态都是转发(FORWARDING
)。在SWB上,我们则可以看到Ethernet0/0/1
是SWB的根端口(ROOT
),状态也是转发(FORWARDING
);Ethernet0/0/2
和Ethernet0/0/3
是指定端口,状态都是转发(FROWARDING
)。在SWC和SWD上,我们可以看到连接SWA的端口为根端口(ROOT
),状态是转发(FORWARDING
);而与SWB相连的端口是预备端口(ALTE
),状态是阻塞(DISCARDING
)。
[SWA]display stp brief
MSTID Port Role STP State Protection
0 Ethernet0/0/1 DESI FORWARDING NONE
0 Ethernet0/0/2 DESI FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
[SWB]display stp brief
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ROOT FORWARDING NONE
0 Ethernet0/0/2 DESI FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
[SWC]display stp brief
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ROOT FORWARDING NONE
0 Ethernet0/0/2 ALTE DISCARDING NONE
[SWD]display stp brief
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ROOT FORWARDING NONE
0 Ethernet0/0/2 ALTE DISCARDING NONE
查看端口开销
命令display stp interface e0/0/1的输出内容中我们可以看出e0/0/1的STP相关信息,该端口使用的开销标准是Dot1T,也就是802.1t标准,开销值为20000。管理员可以使用命令stp pathcost-standard legacy
,将STP使用的端口开销标准更改为华为的私有标准。
SWA:
[SWA]display stp interface e0/0/1
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc00-4389
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc00-4389 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :37
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:7m:10s
Number of TC :25
Last TC occurred :Ethernet0/0/1
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc00-4389 / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
转发延迟的配置方法:
[SWA]stp timer forward-delay 2000 #转发延迟的时间修改为20秒
配置STP计时器值:
[SWA]stp timer hello 300
[SWA]stp timer max-age 3000
转发延迟可以使用命令stp timer forward-delay
进行配置,这条命令的参数单位为厘秒(百分之一秒),取值范围是400~3000
,默认为1500
,也就是15秒
。
使用命令stp timer hello
来修改默认的Hello时间,Hello时间的配置同样以厘秒为单位,取值范围是100~1000
,默认为200
,也就是2秒
。根网桥会根据这个时间设置来生成并发送CBPDU
(配置BPDU
)。
使用命令stp timer max-age
来修改默认的保存BPDU时间,以厘秒为单位,取值范围是600~4000
,默认为2000
,也就是20秒
。当STP环境中发生故障时,若处于阻塞状态的端口(预备端口)无法从对端的指定端口收到BPDU,那么在MaxAge
计时器超时后,这台交换机就会重新开始计算STP。
SWD上查看STP信息
[SWD]display stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-ccd3-277b
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 3s MaxAge 30s FwDly 20s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 200000
CIST RegRoot/IRPC :32768.4c1f-ccd3-277b / 0
CIST RootPortId :128.1
BPDU-Protection :Disabled
TC or TCN received :451
TC count per hello :2
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:41s
Number of TC :21
Last TC occurred :Ethernet0/0/1
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Protocol :Enabled
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc00-4389 / 128.3
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
注意这两行:
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 3s MaxAge 30s FwDly 20s MaxHop 20
SWD上查看STP信息上一行是SWD本地的计时器设置,下一行是当前使用的计时器值。华为交换机通常会按照默认的STP
计时器配置正常工作,管理员无需修改默认值。如果有特殊需求,在修改时一定注意这些计时器值需要全网统一,否则会造成链路状态不稳定的情况。
指定STP网络直径:
使用系统视图的命令stp bridge-diameter
来指定STP的网络直径,让STP根据管理员定义的网络环境自动计算出适用于这个网络的计时器值。
[SWA]stp bridge-diameter 2
[SWA]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc00-4389
Config Times :Hello 2s MaxAge 10s FwDly 7s MaxHop 20
Active Times :Hello 2s MaxAge 10s FwDly 7s MaxHop 20
CIST Root/ERPC :4096 .4c1f-cc00-4389 / 0
CIST RegRoot/IRPC :4096 .4c1f-cc00-4389 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :41
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:2m:5s
Number of TC :30
Last TC occurred :Ethernet0/0/1
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
其中:
Hello 2s MaxAge 10s FwDly 7s MaxHop 20
从这可以看出:
交换机根据网络直径2自动计算出了计时器值:Hello计时器为2秒,MaxAge计时器为10秒,转发延迟计时器为7秒。