笔记STP-创新互联

STP
-定义
-作用
-类型
1、802.1d - STP :生成树协议 PVST/PVST+(思科)
2、802.1w - RSTP :快速生成树协议 PV-RSTP(思科)
3、802.1s - MSTP :多生成树协议
-报文

成都创新互联专业为企业提供沧源网站建设、沧源做网站、沧源网站设计、沧源网站制作等企业网站建设、网页设计与制作、沧源企业网站模板建站服务,十多年沧源做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

PVST:per-vlan STP,即在每个 VLAN 内部都运行一个 STP (802.1d);

STP的工作过程:
1、确定交换机的角色
根交换机:整个交换网络中,有且只有一个;
非根交换机:剩余的其他交换机,都称之为非根交换机

注意:
        每一个非根交换机都会计算出一条去往根交换机的最短的、
        无环、2层数据转发路径,并且最终该路径是“转发”状态;

        选举原则:
              比较每个交换机的 BID (bridge ID):优先级+MAC地址
              优先级:默认值为 32768 ; 2个字节;
              MAC地址:使用的是交换机的主板MAC;6个字节;
                 比较原则 - 
                       首先比较优先级,越小越好;
                       其次比较MAC地址,越小越好;

2、确定端口的角色
        根端口:在每一个非根交换机上,有且只有一个;
                距离根交换机最近的端口;

        指定端口:在每一个"网段/segment"中,有且只有一个;
                距离根交换机最近的端口;

        非指定端口:其他所有端口,都叫做“非指定端口”

3、确定端口的状态
        down       -关闭(指的是当前端口没有启动STP)

        listening  -侦听,此时侦听的是网络中的所有的BPDU
                          目的是为了确定交换机和端口的角色;
                          端口在该状态停留15s;

        learning   -学习,该阶段主要是学习端口上收到的数据帧
                           的源MAC地址,从而形成 MAC地址表;
                           端口在该状态停留15s;

        forwarding -转发(最终状态),该状态实现数据包的发送和接收

        blocking   -阻塞(最终状态),该状态不能发送和接收数据包;
                                    只能接收 BPDU。

BPDU类型:
1、配置BPDU
用于创建和维护 STP 无环转发路径树
2、TCN BPDU
只有当 STP 无环转发路径树(拓扑)变化的时候,才会
产生并发送。
并且是:感知到该变化的交换机,产生 TCN BPDU ,只
发送给根交换机,然后再由根交换机转发给其他的所有
非根交换机;

STP计时器:
hello:交换机周期性发送 BPDU 的时间间隔,默认是 2s ;
forward-delay : 转发延迟,默认时间为15s ;
max-age:大老化时间,默认时间为 20s ;


STP参数修改(思科):
1、修改交换机的 STP 优先级 (确保网络中有主根交换机和辅根交换机)
spanning-tree vlan x priority {value} , value 是4096的倍数

2、修改交换机的 STP 模式 (必须确保网络的所有交换机的STP模式相同)
        spanning-tree mode  {pvst | rapid-pvst | mstp }

3、修改交换机的 端口  cost 
        interface fas0/22 (该链路指的是 trunk 链路)
           spanning-tree  vlan 3 cost {value} 
4、针对某个 VLAN ,关闭 STP 功能
        no spanning-tree vlan x

STP参数修改(华为):
1、修改交换机的 STP 优先级:
[SW] stp priority {value} -> 必须得是4096的倍数
2、修改交换机的 STP 模式
[SW] stp mode {stp | rstp | mstp }
3、修改交换机的端口的 STP cost :
[SW]interface fas0/13
[sw-fas0/13]stp cost {value}
4、在交换机上关闭/开启 STP :
[sw]stp disable -> 关闭 STP ;
[sw]stp enable -> 开启 STP ,默认是开启的;

验证命令:
show spanning-tree vlan x ->可以查看交换机上关于 VLAN x 的 STP 信息
show spanning-tree ->可以查看交换机上关于所有VLAN的 STP 信息
show spanning-tree summary ->可以查看交换机运行的 STP 的模式;
show version -> 可以查看交换机的 base mac ;

display  stp  
display  stp brief

注意:
交换机上的 STP 功能,默认都是开启的;可以人工关闭;

=============================================================
MSTP的配置:

  • MST域(region),同一个域中,可以同时包含多个实例;
  • MSTI(instance),即MST 实例,一个MSTI 可以同时关联多个 VLAN ;

    配置 MST region
    [SW]stp region-configuration
    [sw-mstp-region]region-name {string} //配置 region 的名字;
    [sw-mstp-region]instance {id} vlan x y z m n //配置关联的VLAN
    [sw-mstp-region]active region-configuration
    [sw-mstp-region]display this
    配置 MSTI
    [sw1]stp instance {id} priority {value} <-将 SW1设置为 实例id 的根;

    验证命令:
    display stp instance {id}
    display stp brief
    注意:
    默认情况下,所有的 VLAN 都是属于 instance 0 ; (系统的默认instance)
    一个MSTP网络中,可以同时包含多个 region ;
    每个MST Region 中,可以包含多个 instance (MSTI)
    属于相同 region 的交换机上,以下参数必须相同:
    #region-name
    #实例与vlan的映射关系必须相同

    属于同一个 region 中的多个交换机之间,可以基于 instance 进行
    流量的负载均衡和备份;

=====================================================================

STP 收敛速度比较慢 :30-50s

RSTP收敛速度要比 STP 快,因为做了以下改进:
1、发现问题比较快

2、反应/传输问题比较快
发现拓扑变更的交换机,会产生TCN BPDU,直接发送给与自己相连
的其他所有交换机;

3、解决问题比较快

端口角色细化:

根端口(root port ) 
指定端口 (designated port )  
替代端口(alternative port ):是根端口的备胎;
备份端口(bakcup port ):是指定端口的备胎

(边缘端口:一般都建议关闭 STP ;或者将连接非交换机的端口,设置非边缘端口)


端口状态精简化:
learning :学习
forwarding :转发
discarding :丢弃,相当于之前 STP 中的 down / blocking / listening


案例:

1 案例1:STP算法
1.1 问题
选择出根网桥、根端口、指定端口、被阻塞的端口。

1.2 方案
如图-1所示:

笔记  STP

1.3 步骤
实现此案例需要按照如下步骤进行。

1)每个广播域选择根网桥(Root Bridge)

每个非根网桥选择根端口(Root Ports)
每个网段上选择指定端口(Designated Ports)
2)结果如图-2所示

笔记  STP

2 案例2:配置STP
2.1 问题
首先查看当前根网桥,然后通过修改交换机的优先级来分配根网桥。

2.2 方案
使用eNSP搭建实验环境,如图-3所示。

笔记  STP

2.3 步骤
实现此案例需要按照如下步骤进行。

[A]stp mode stp
[B]stp mode stp
[C]stp mode stp
[D]stp mode stp
[A]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc3b-03cb
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-cc17-3481 / 200000
CIST RegRoot/IRPC :32768.4c1f-cc3b-03cb / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :106
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:8s
Number of TC :12
Last TC occurred :Ethernet0/0/2
[B]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc17-3481
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-cc17-3481 / 0
CIST RegRoot/IRPC :32768.4c1f-cc17-3481 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :23
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:9m:52s
Number of TC :13
Last TC occurred :Ethernet0/0/4
[C]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc50-3d65
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-cc17-3481 / 400000
CIST RegRoot/IRPC :32768.4c1f-cc50-3d65 / 0
CIST RootPortId :128.4
BPDU-Protection :Disabled
TC or TCN received :92
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:10m:26s
Number of TC :11
Last TC occurred :Ethernet0/0/4
[D]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc22-4507
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-cc17-3481 / 200000
CIST RegRoot/IRPC :32768.4c1f-cc22-4507 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :49
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:11m:12s
Number of TC :13
Last TC occurred :Ethernet0/0/2
可以看出,交换机B是根网桥。

[A]stp priority 4096
[A]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-cc3b-03cb
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-cc3b-03cb / 0
CIST RegRoot/IRPC :4096 .4c1f-cc3b-03cb / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :108
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:14s
Number of TC :15
Last TC occurred :Ethernet0/0/3
此时,根网桥已经是交换机A了。

3 案例3:配置MSTP及负载均衡
3.1 问题
配置MSTP实现多生成树效果
配置A成为vlan 10 和 20 的主根,vlan 30 和 40 的次根
配置B成为vlan 30 和 40 的主根,vlan 10 和 20 的次根
查看配置信息
3.2 方案
使用eNSP搭建实验环境,如图-4所示。

笔记  STP

3.3 步骤
实现此案例需要按照如下步骤进行。

[A]vlan batch 10 20 30 40
[A]int e0/0/2
[A-Ethernet0/0/2]port link-type trunk
[A-Ethernet0/0/2]port trunk allow-pass vlan all
[A]int e0/0/3
[A-Ethernet0/0/3]port link-type trunk
[A-Ethernet0/0/3]port trunk allow-pass vlan all
交换机B、C也同样配置。

[A]stp region-configuration
[A-mst-region]region-name tedu
[A-mst-region]instance 1 vlan 10 20
[A-mst-region]instance 2 vlan 30 40
[A-mst-region]active region-configuration
查看配置:

[A-mst-region]dis this
#
stp region-configuration
region-name tedu
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration
#
return
交换机B、C也同样配置。

3)配置主根与次根

[A]stp instance 1 priority 4096
[A]stp instance 2 priority 8192
[B]stp instance 2 priority 4096
[B]stp instance 1 priority 8192
4)验证

[A]dis stp instance 1
-------[MSTI 1 Global Info]-------
MSTI Bridge ID :4096.4c1f-cc87-1de7
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 0
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :5
TC count per hello :0
Time since last TC :0 days 0h:3m:6s
Number of TC :4
Last TC occurred :Ethernet0/0/2
----[Port2(Ethernet0/0/2)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
----[Port3(Ethernet0/0/3)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
[A]dis stp instance 2
-------[MSTI 2 Global Info]-------
MSTI Bridge ID :8192.4c1f-cc87-1de7
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:3m:49s
Number of TC :4
Last TC occurred :Ethernet0/0/2
----[Port2(Ethernet0/0/2)][FORWARDING]----
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :4
TC or TCN received :3
----[Port3(Ethernet0/0/3)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :2
TC or TCN received :1
[B]dis stp instance 1
-------[MSTI 1 Global Info]-------
MSTI Bridge ID :8192.4c1f-cc0d-76bc
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:5m:26s
Number of TC :4
Last TC occurred :Ethernet0/0/3
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.2
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
----[Port3(Ethernet0/0/3)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :0
[B]dis stp instance 2
-------[MSTI 2 Global Info]-------
MSTI Bridge ID :4096.4c1f-cc0d-76bc
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 0
MSTI RootPortId :0.0
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :0
TC received :6
TC count per hello :0
Time since last TC :0 days 0h:6m:4s
Number of TC :5
Last TC occurred :Ethernet0/0/3
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.1
Port Times :RemHops 20
TC or TCN send :3
TC or TCN received :4
----[Port3(Ethernet0/0/3)][FORWARDING]----
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
[C]dis stp instance 1
-------[MSTI 1 Global Info]-------
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc87-1de7 / 200000
MSTI RootPortId :128.1
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :3
TC count per hello :0
Time since last TC :0 days 0h:6m:58s
Number of TC :3
Last TC occurred :Ethernet0/0/1
----[Port1(Ethernet0/0/1)][FORWARDING]----
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
----[Port2(Ethernet0/0/2)][DISCARDING]----
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 19
TC or TCN send :0
TC or TCN received :1
[C]dis stp instance 2
-------[MSTI 2 Global Info]-------
MSTI Bridge ID :32768.4c1f-ccb8-32b8
MSTI RegRoot/IRPC :4096.4c1f-cc0d-76bc / 200000
MSTI RootPortId :128.2
Master Bridge :32768.4c1f-cc0d-76bc
Cost to Master :200000
TC received :4
TC count per hello :0
Time since last TC :0 days 0h:7m:32s
Number of TC :4
Last TC occurred :Ethernet0/0/2
----[Port1(Ethernet0/0/1)][DISCARDING]----
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :8192.4c1f-cc87-1de7 / 128.3
Port Times :RemHops 19
TC or TCN send :1
TC or TCN received :2
----[Port2(Ethernet0/0/2)][FORWARDING]----
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000
Designated Bridge/Port :4096.4c1f-cc0d-76bc / 128.3
Port Times :RemHops 20
TC or TCN send :2
TC or TCN received :2
查看负载均衡:

[A]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/2 ROOT FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/2 DESI FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE
[B]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 DESI FORWARDING NONE
0 Ethernet0/0/3 DESI FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/3 DESI FORWARDING NONE
2 Ethernet0/0/1 DESI FORWARDING NONE
2 Ethernet0/0/3 DESI FORWARDING NONE
[C]dis stp bri
MSTID Port Role STP State Protection
0 Ethernet0/0/1 ALTE DISCARDING NONE
0 Ethernet0/0/2 ROOT FORWARDING NONE
1 Ethernet0/0/1 ROOT FORWARDING NONE
1 Ethernet0/0/2 ALTE DISCARDING NONE
2 Ethernet0/0/1 ALTE DISCARDING NONE
2 Ethernet0/0/2 ROOT FORWARDING NONE
C上VLAN 10 20的流量通过Ethernet0/0/1口到A,VLAN 30 40的流量通过Ethernet0/0/2口到B,实现了链路的负载均衡。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站名称:笔记STP-创新互联
浏览地址:http://bzwzjz.com/article/dshcjj.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 手机网站建设 网站设计制作 网站建设开发 营销型网站建设 响应式网站设计 成都网站制作 网站建设 重庆网站建设 成都网站建设公司 成都网站建设推广 企业网站设计 成都网站制作 成都网站建设 重庆网站制作 成都网站建设 成都网站设计公司 网站建设公司 成都网站建设 成都商城网站制作 重庆手机网站建设 古蔺网站建设 营销网站建设