1      MSTP简介

多生成树协议MSTP(Multiple Spanning Tree Protocol)是IEEE 802.1s中提出的一种STP和VLAN结合使用的新协议,简单说来,STP/RSTP是基于端口的,而MSTP是基于实例的。它既继承了RSTP端口快速迁移的优点,又解决了RSTP中不同VLAN必须运行在同一棵生成树上的问题。

 

2      MSTP实现说明

2.1      域和实例

与STP/RSTP相比,MSTP中引入了“实例”(Instance)和“域”(Region) “的概念。

Ø  所谓“实例”就是多个VLAN的一个集合。使用的时候可以把多个相同业务的VLAN映射到某一个实例中。MSTP拓扑计算以实例为维度,各个实例独立破环。通过VLAN和实例的映射,可以实现在这些实例上实现负载均衡。缺省情况下,所有的VLAN都映射到实例0上。除实例0外的其他实例叫做多生成树实例。

 

Ø  所谓“域”,由域名、修订级别、VLAN与实例的映射关系(mapping of VIDs to spanning trees)组成。每个域内所有交换机都要有相同的MST域配置,也就是说多台交换机域中的三个配置完全相同时,才属于同一个域。缺省情况下,域名就是交换机的桥MAC地址,修订级别等于0,所有的VLAN都映射到实例0上。

 

MSTP生成树分为4种:

1、  CIST(Common Internal Spanning Tree),即公共与内部生成树。CIST由CST和IST组成。

2、  CST(Common Spanning Tree)连接交换网络内所有MST域的一棵生成树。

3、  IST(Internal Spanning Tree)各个MST域内的一棵生成树。

4、  SST(Single Spanning Tree)运行STP或RSTP的交换设备只能属于一个生成树或者MST域中只有一个交换设备,这个交换设备构成单生成树。

 

2.2      域根和总根

Ø  总根是一个全局概念,对于所有互连的运行STP/RSTP/MSTP的交换机只能有一个总根,也即是实例0的根。如上图所示,A0的CIST Root就是总根。

 

Ø  域根是一个局部概念,是相对于某个域的某个实例而言的。也就是说每个域内的每个实例都有一个域根,所以每个域所包含的域根数目与实例个数相关。

 

2.3      Master端口和域边缘端口

Ø  Master端口:Master端口是MST域的所有边界端口中,到达总根具有最小开销的端口,也就是连接MST域到总根的端口,位于整个域到总根的最短路径上。Master端口在CIST上的角色是Root Port。

 

Ø  域边缘端口:是连接不同MST域的端口,位于MST域的边缘。一个域中可以有多个域边缘端口。

 

2.4      MSTP生成树计算

Ø  CIST生成树的计算

CIST生成树计算中,通过7个维度的比较,最终把环形组网裁剪为树形组网。

7个维度是{ 根交换设备ID,外部路径开销,域根ID,内部路径开销,指定交换设备ID,指定端口ID,接收端口ID }。

 

CIST生成树计算过程,可以分为3步:

1、  网络中的设备发送接收BPDU报文,在经过比较配置消息后,在整个网络中选择一个优先级最高的交换机作为CIST的树根。

2、  在每个MST域内MSTP通过计算生成IST

3、  MSTP将每个MST域作为单台交换机对待,通过计算在MST域间生成CST。

如前所述,CST和IST构成了整个交换机网络的CIST。

 

Ø  MSTI的计算

MSTI生成树计算中,通过5个维度的比较,最终把环形组网裁剪为树形组网。

5个维度是{ 域根ID,内部路径开销,指定交换设备ID,指定端口ID,接收端口ID }。

在MST域内,MSTP根据VLAN和生成树实例的映射关系,针对不同的VLAN生成不同的生成树实例。每棵生成树独立进行计算,计算原则与STP/RSTP计算生成树的相同,请参见华为手册或者各界大侠详细的总结文档。

 

3      使用注意事项

Ø  绑定实例的VLAN,必须已经创建,并且接口已经加入指定VLAN。通过命令“display stp brief”查看端口状态时,只会显示使能STP且UP的端口。

 

Ø  配置MST域的相关参数后,必须执行“active region-configuration”命令,配置才会生效。

 

Ø  MST域的默认域名是设备的MAC地址,每个设备的MAC地址是不相同的,所以必须手动指定域内,才能使交换机的域信息一致。

 

Ø  盒式交换机需要通过“bpdu enable”使能BPDU报文上送CPU处理的功能,才能使STP报文上送CPU处理,否则STP状态无法收敛。

V100R005及之前版本,在S2700系列设备,检查全局是否配置bpdu enable;其他系列盒式交换机,检查物理端口、Eth-trunk接口下是否配置bpdu enable。

V100R006及后续版本,对应形态设备全局或端口默认使能bpdu enable。

 

Ø  Eth-Trunk接口使能STP时,建议修改Eth-Trunk接口的cost值使其小于物理端口的cost值,使其不易协商为备份端口。一是因为Eth-Trunk接口的开销为单个成员接口的开销除以成员接口数量,当成员口状态变化时Eth-trunk接口的cost值会变化;二是cost值越小说明链路质量越高。

 

4      配置举例

4.1      组网需求

如图所示,当前网络中SwitchA、SwitchB、SwitchC和SwitchD通过环形组网备份链路,同时对两个用户的流量进行负载分担。希望通过运行MSTP协议阻塞特定端口,将环形网络结构修剪成无环路的树形网络结构。

Ø  部门1和部门2的流量进行负载分担。

Ø  SwitchA和SwitchB分别作为两个部门的根桥和备份根桥。

Ø  SwitchC和SwitchD连接用户的接口GE1/0/3不要参与STP计算。

 

4.2      配置思路

采用如下的思路配置MSTP:

1.         创建VLAN,并把接口加入VLAN。

2.         配置模式是MSTP模式。

3.         配置域名为RG1,并配置域内VLAN和实例的映射关系。

4.         配置SwitchA和SwitchB分别作为两个部门的根桥和备份根桥。

5.         统一使用默认路径开销。华为交换机默认的路径开销计算标准使用的是标准的dot1t。GE接口默认路径开销是20000,而Ethernet接口默认路径开销是200000。注意:eNSP模拟器中,STP的路径开销默认是1。

6.         SwitchC和SwitchD的GE1/0/3端口去使能STP协议。

7.         SwitchA、SwitchB、SwitchC和SwitchD使能STP协议。

 

4.3      操作步骤
步骤1:创建VLAN,并把接口加入VLAN。
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 2 to 4094
[SwitchA] interface gigabitethernet0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type trunk
[SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 4094
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA] interface gigabitethernet0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type trunk
[SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SwitchA-GigabitEthernet0/0/2] quit
  
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] vlan batch 2 to 4094
[SwitchB] interface gigabitethernet0/0/1
[SwitchB-GigabitEthernet0/0/1] port link-type trunk
[SwitchB-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 4094
[SwitchB-GigabitEthernet0/0/1] quit
[SwitchB] interface gigabitethernet0/0/2
[SwitchB-GigabitEthernet0/0/2] port link-type trunk
[SwitchB-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SwitchB-GigabitEthernet0/0/2] quit
  
<HUAWEI> system-view
[HUAWEI] sysname SwitchC
[SwitchC] vlan batch 2 to 4094
[SwitchC] interface gigabitethernet0/0/1
[SwitchC-GigabitEthernet0/0/1] port link-type trunk
[SwitchC-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 4094
[SwitchC-GigabitEthernet0/0/1] quit
[SwitchC] interface gigabitethernet0/0/2
[SwitchC-GigabitEthernet0/0/2] port link-type trunk
[SwitchC-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SwitchC-GigabitEthernet0/0/2] quit
  
<HUAWEI> system-view
[HUAWEI] sysname SwitchD
[SwitchD] vlan batch 2 to 4094
[SwitchD] interface gigabitethernet0/0/1
[SwitchD-GigabitEthernet0/0/1] port link-type trunk
[SwitchD-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 4094
[SwitchD-GigabitEthernet0/0/1] quit
[SwitchD] interface gigabitethernet0/0/2
[SwitchD-GigabitEthernet0/0/2] port link-type trunk
[SwitchD-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SwitchD-GigabitEthernet0/0/2] quit
  
步骤2:配置模式为MSTP模式。
华为交换机默认是MSTP模式,该步骤可以省略。
 [SwitchA] stp mode mstp
  
 [SwitchB] stp mode mstp
  
 [SwitchC] stp mode mstp
  
 [SwitchD] stp mode mstp
  
步骤3:配置域名为RG1,并配置域内VLAN和实例的映射关系。
注意4台设备的域配置需要完全一致,才可以正确破环。
[SwitchA] stp region-configuration
[SwitchA-mst-region] region-name RG1   //配置域名为RG1
[SwitchA-mst-region] instance 1 vlan 1 to 200  //默认所有VLAN都属于实例0,这里把VLAN1~200映射为实例1,其他VLAN201~4094还是属于实例0
[SwitchA-mst-region] active region-configuration  //域内的配置,需要激活才能生效
[SwitchA-mst-region] quit  
  
[SwitchB] stp region-configuration
[SwitchB-mst-region] region-name RG1
[SwitchB-mst-region] instance 1 vlan 1 to 200
[SwitchB-mst-region] active region-configuration
[SwitchB-mst-region] quit 
  
[SwitchC] stp region-configuration
[SwitchC-mst-region] region-name RG1
[SwitchC-mst-region] instance 1 vlan 1 to 200
[SwitchC-mst-region] active region-configuration
[SwitchC-mst-region] quit 
  
[SwitchD] stp region-configuration
[SwitchD-mst-region] region-name RG1
[SwitchD-mst-region] instance 1 vlan 1 to 200
[SwitchD-mst-region] active region-configuration
[SwitchD-mst-region] quit 
  
步骤4:配置根桥和备份根桥。
配置在实例0中SwitchA为根桥,SwitchB为备份根桥。在实例1中SwitchA为备份根桥,SwitchB为根桥。
[SwitchA] stp instance 0 root primary   //也可以使用命令stp priority 0 配置优先级为0,和stp root primary的作用是一样的。
[SwitchA] stp instance 1 root secondary  //也可以使用命令stp priority 4096 配置优先级为4096,和stp root secondary的作用是一样的。
  
[SwitchB] stp instance 0 root secondary
[SwitchB] stp instance 1 root primary
  
步骤5:去使能SwitchC和SwitchD设备GE0/0/3端口的STP功能。
[SwitchC] interface gigabitethernet0/0/3
[SwitchC-GigabitEthernet0/0/3] stp disable
[SwitchC-GigabitEthernet0/0/3] quit
  
[SwitchD] interface gigabitethernet 0/0/3
[SwitchD-GigabitEthernet0/0/3] stp disable
[SwitchD-GigabitEthernet0/0/3] quit
  
步骤6:全局使能STP功能。
华为X7系列交换机默认是使能,该步骤可以省略。
[SwitchA] stp enable
  
[SwitchB] stp enable
  
[SwitchC] stp enable
  
[SwitchD] stp enable
  
步骤7:验证配置结果
查看MSTP简要信息,通过MSTP简要信息可以快速的看出端口的角色和状态。
  
4.4      配置文件
SwitchA的配置文件
#
sysname SwitchA
#
vlan batch 2 to 4094
#
stp instance 0 root primary
stp instance 1 root secondary
stp enable
#
stp region-configuration
 region-name RG1
 instance 1 vlan 1 to 200
 active region-configuration
#
interface GigabitEthernet0/0/1
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/2
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
return
SwitchB的配置文件
#
sysname SwitchB
#
vlan batch 2 to 4094
#
stp instance 0 root secondary
stp instance 1 root primary
stp enable
# 
stp region-configuration
 region-name RG1
 instance 1 vlan 1 to 200
 active region-configuration
#
interface GigabitEthernet0/0/1
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/2
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
return 
SwitchC的配置文件
#
sysname SwitchC 
# 
vlan batch 2 to 4094
#
stp enable
#
stp region-configuration
 region-name RG1
 instance 1 vlan 1 to 200
 active region-configuration
# 
interface GigabitEthernet0/0/1
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/2
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/3
 stp disable
# 
return 
SwitchD的配置文件
#
sysname SwitchD
#
vlan batch 2 to 4094
#
stp mode stp
# 
interface GigabitEthernet0/0/1
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/2
port link-type trunk
 port trunk allow-pass vlan 2 to 4094
# 
interface GigabitEthernet0/0/3
 stp disable
# 
return