MSTP协议

RSTP在STP基础上做了改进,实现了网络拓扑快速收敛,但RSTP和STP还存在同一个缺陷,即由于局域网内所有的VLAN共享一颗生成树,链路被阻塞后将不承载任何流量,造成带宽浪费,因此无法在VLAN间实现数据流量的负载均衡,还有可能造成部分VLAN报文无法转发。

通过MSTP把一个交换网络化分成多个域,每个域内形成多颗生成树,生成树之间彼此独立,每个域叫做MSTP域(Multiple Spanning Tree Region MST Region),每棵生成树叫做一个多生成树实例MSTI(Multiple Spanning Tree Instance)

实例内可以包含多个VLAN。通过多个VLAN映射到同一个实例内,可以节省通信开销和资源占用率,MSTP各个实例拓扑的生成树计算相互独立,通过这些实例可以实现负载均衡,把多个相同拓扑结构的VLAN映射到一个实例里,这些VLAN在端口上转发状态取决于端口在对应MSTP实例的状态

MSTP通过设置VLAN映射表(即VLAN和MSTI的对应关系表),把VLAN和MSTI联系起来,每个VLAN只能对应一个MSTI,即同一个VLAN的数据只能在一个MSTI中传输,而一个MSTI可能对应多个VLAN。

 

设备  接口 ip  子网  默认网关
PC1 Ethernet0/0/1 192.168.10.1 255.255.255.255.0  
PC2 Ethernet0/0/1 192.168.20.1 255.255.255.255.0  
PC3 Ethernet0/0/1 192.168.10.2 255.255.255.255.0  
PC4 Ethernet0/0/1 192.168.20.2 255.255.255.255.0  
设备  全局MAC地址
SW1 4c1f-cc92-6fe3
SW2

4c1f-cc11-5ec3

SW3

4c1f-cc46-1924

SW1配置

vlan batch 10 20
interface Ethernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10 20
#

interface Ethernet0/0/3
 port link-type access
 port default vlan 10

SW2配置

vlan batch 10 20
interface Ethernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10 20
#
interface Ethernet0/0/2
 port link-type trunk
 port trunk allow-pass vlan 10 20
#
interface Ethernet0/0/3
 port link-type access
 port default vlan 20

SW3配置

vlan batch 10 20
interface Ethernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10 20
#
interface Ethernet0/0/2
 port link-type trunk
 port trunk allow-pass vlan 10 20
#
interface Ethernet0/0/3
 port link-type access
 port default vlan 10
#
interface Ethernet0/0/4
 port link-type access
 port default vlan 20
[SW1]dis stp 
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge         :32768.4c1f-cc92-6fe3
Config Times        :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times        :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC      :32768.4c1f-cc11-5ec3 / 200000
CIST RegRoot/IRPC   :32768.4c1f-cc92-6fe3 / 0
CIST RootPortId     :128.1
BPDU-Protection     :Disabled
TC or TCN received  :10
TC count per hello  :0
STP Converge Mode   :Normal 
Time since last TC  :0 days 0h:31m:39s
Number of TC        :4
Last TC occurred    :Ethernet0/0/3
----[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   :32768.4c1f-cc11-5ec3 / 128.2
 Port Edged          :Config=default / Active=disabled
 Point-to-point      :Config=auto / Active=true
 Transit Limit       :147 packets/hello-time
 Protection Type     :None
 Port STP Mode       :MSTP 
 Port Protocol Type  :Config=auto / Active=dot1s
 BPDU Encapsulation  :Config=stp / Active=stp
 PortTimes           :Hello 2s MaxAge 20s FwDly 15s RemHop 20
 TC or TCN send      :3
 TC or TCN received  :7
 BPDU Sent           :4             
          TCN: 0, Config: 0, RST: 0, MST: 4
 BPDU Received       :888             
          TCN: 0, Config: 0, RST: 0, MST: 888
[SW1]dis stp brief 
 MSTID  Port                        Role  STP State     Protection
   0    Ethernet0/0/1               ROOT  FORWARDING      NONE
   0    Ethernet0/0/2               ALTE  DISCARDING      NONE
   0    Ethernet0/0/3               DESI  FORWARDING      NONE
[SW1]

[SW2]  dis 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

[SW3]  dis stp brief 
 MSTID  Port                        Role  STP State     Protection
   0    Ethernet0/0/1               DESI  FORWARDING      NONE
   0    Ethernet0/0/2               ROOT  FORWARDING      NONE
   0    Ethernet0/0/3               DESI  FORWARDING      NONE
   0    Ethernet0/0/4               DESI  FORWARDING      NONE

此时SW2交换机的所有端口都为指定端口,又都为转发状态,所以SW2为根交换机。SW1的e/0/02为阻塞口。

PC3pingPC1,PC4pingPC2,在SW2的E0/0/2上抓包。

 

 可以观察到VLAN10、20的数据包都从SW2的E0/0/2转发,在SW1的e0/0/2上什么也抓不到,只抓到周期发送的BPDU

 

 此时SW1和SW3之间的链路处理闲置状态,造成了资源浪费,

配置MSTP多实例。

[SW1]stp region-configuration    进入MSTP域视图
[SW1-mst-region]region-name huawei   配置MSTP域名为huawei
[SW1-mst-region]revision-level 1  配置MSTP修订级别为1
[SW1-mst-region]instance 1 vlan 10
[SW1-mst-region]instance 2 vlan 20
指定VLAN10映射到MSTI1,指定VLAN20映射到MSTI2
[SW1-mst-region]active region-configuration   激话MSTP域配置
[SW1-mst-region]dis this 
#
stp region-configuration
 region-name huawei
 revision-level 1
 instance 1 vlan 10
 instance 2 vlan 20
 active region-configuration
#
return

SW2和SW3配置一样

SW1 SW2 SW3上使用

[SW1]dis stp region-configuration 
 Oper configuration
   Format selector    :0             
   Region name        :huawei             
   Revision level     :1

   Instance   VLANs Mapped
      0       1 to 9, 11 to 19, 21 to 4094
      1       10
      2       20
[SW2]dis stp region-configuration 
 Oper configuration
   Format selector    :0             
   Region name        :huawei             
   Revision level     :1

   Instance   VLANs Mapped
      0       1 to 9, 11 to 19, 21 to 4094
      1       10
      2       20
[SW3]dis stp region-configuration 
 Oper configuration
   Format selector    :0             
   Region name        :huawei             
   Revision level     :1

   Instance   VLANs Mapped
      0       1 to 9, 11 to 19, 21 to 4094
      1       10
      2       20

所有交换机上的MSTP域 名都为huawei,修定版本号都是1,且VLAN与实例的映射相同,VLAN10与20之外,其余VLAN属于实例0.

PC3持续PingPC1,PC4持续pingPC2。在SW2的E0/0/2上抓包。

 

 

 可以观察到VLAN10、20的数据包都从SW2的E0/0/2转发,在SW1的e0/0/2上什么也抓不到,只抓到周期发送的BPDU

 

 在SW1、SW2、SW3上使用

[SW1]dis stp instance 0 brief 
 MSTID  Port                        Role  STP State     Protection
   0    Ethernet0/0/1               ROOT  FORWARDING      NONE
   0    Ethernet0/0/2               ALTE  DISCARDING      NONE
   0    Ethernet0/0/3               DESI  FORWARDING      NONE

[SW2]dis stp instance 0 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

[SW3]dis stp instance 0 brief 
 MSTID  Port                        Role  STP State     Protection
   0    Ethernet0/0/1               DESI  FORWARDING      NONE
   0    Ethernet0/0/2               ROOT  FORWARDING      NONE
   0    Ethernet0/0/3               DESI  FORWARDING      NONE
   0    Ethernet0/0/4               DESI  FORWARDING      NONE
[SW1]dis stp instance 1 brief
 MSTID  Port                        Role  STP State     Protection
   1    Ethernet0/0/1               ROOT  FORWARDING      NONE
   1    Ethernet0/0/3               DESI  FORWARDING      NONE

[SW2]dis stp instance 1 brief
 MSTID  Port                        Role  STP State     Protection
   1    Ethernet0/0/1               DESI  FORWARDING      NONE
   1    Ethernet0/0/2               DESI  FORWARDING      NONE

[SW3]dis stp instance 1 brief
 MSTID  Port                        Role  STP State     Protection
   1    Ethernet0/0/1               DESI  FORWARDING      NONE
   1    Ethernet0/0/2               ROOT  FORWARDING      NONE
   1    Ethernet0/0/3               DESI  FORWARDING      NONE
[SW1]dis stp instance 2 brief
 MSTID  Port                        Role  STP State     Protection
   2    Ethernet0/0/1               ROOT  FORWARDING      NONE

[SW2]dis stp instance 2 brief
 MSTID  Port                        Role  STP State     Protection
   2    Ethernet0/0/1               DESI  FORWARDING      NONE
   2    Ethernet0/0/2               DESI  FORWARDING      NONE
   2    Ethernet0/0/3               DESI  FORWARDING      NONE

[SW3]dis stp instance 2 brief
 MSTID  Port                        Role  STP State     Protection
   2    Ethernet0/0/1               DESI  FORWARDING      NONE
   2    Ethernet0/0/2               ROOT  FORWARDING      NONE
   2    Ethernet0/0/4               DESI  FORWARDING      NONE

以 上三种实例选举结果一致,

手动指定SW1在实例2里为根交换机,

[SW1]stp instance 2 root primary

 

posted @ 2020-05-27 15:04  星火撩原  阅读(1230)  评论(0编辑  收藏  举报