STP 实验

 

 

 

 

stp 网络中 存在一个根桥,其他交换机为分根桥。根桥是stp 网络的逻辑中心,非根桥是根桥的下游设备,当根桥发生故障,费根桥之前交互信息后选举新的根桥,交互的信息称为BPDU。


stp 定义三种端口角色:指定端口,根端口和预备端口

指定端口:是交换机向所连网段转发配置BPDU的端口,每个网段只能有一个指定端口。一般情况下,根桥的每个端口都是指定端口

根端口: 是非根交换机去往根桥路径最优的端口。在一个运行STP协议的交换机上最多只有一个根端口,但根桥上没有根端口

预备端口: 如果个端口既不是指定端口也不是根端口,则此端口为预备端口。预备端口将被阻塞。


根桥选举: 桥ID,有桥优先级和mac地址组成


###开启stp
#stp mode stp
[SW1]stp mode stp 
[SW1]dis stp 

<SW4>dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge         :32768.4c1f-cc49-7893
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-cc49-7893 / 0
CIST RegRoot/IRPC   :32768.4c1f-cc49-7893 / 0
CIST RootPortId     :0.0
BPDU-Protection     :Disabled
TC or TCN received  :5
TC count per hello  :0
STP Converge Mode   :Normal 
Time since last TC  :0 days 0h:1m:10s
Number of TC        :10
Last TC occurred    :GigabitEthernet0/0/3

-------[CIST Global Info][Mode STP]-------
CIST Bridge         :32768.4c1f-cc6d-4399
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-cc49-7893 / 20000
CIST RegRoot/IRPC   :32768.4c1f-cc6d-4399 / 0
CIST RootPortId     :128.4
BPDU-Protection     :Disabled
TC or TCN received  :62
TC count per hello  :0
STP Converge Mode   :Normal 
Time since last TC  :0 days 0h:2m:7s
Number of TC        :18
Last TC occurred    :GigabitEthernet0/0/4

<SW2>dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge         :32768.4c1f-ccfb-2981
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-cc49-7893 / 20000
CIST RegRoot/IRPC   :32768.4c1f-ccfb-2981 / 0
CIST RootPortId     :128.4
BPDU-Protection     :Disabled
TC or TCN received  :289
TC count per hello  :0
STP Converge Mode   :Normal 
Time since last TC  :0 days 0h:2m:37s
Number of TC        :21
Last TC occurred    :GigabitEthernet0/0/4


<SW1>dis stp 
-------[CIST Global Info][Mode STP]-------
CIST Bridge         :32768.4c1f-cc9f-5efe
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-cc49-7893 / 20000
CIST RegRoot/IRPC   :32768.4c1f-cc9f-5efe / 0
CIST RootPortId     :128.4
BPDU-Protection     :Disabled
TC or TCN received  :181
TC count per hello  :0
STP Converge Mode   :Normal 
Time since last TC  :0 days 0h:0m:43s
Number of TC        :19
Last TC occurred    :GigabitEthernet0/0/4

###sw1 的角色是非根桥

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

确认SW4 是根桥,因为只有根桥都是指定端口
 
[SW4]dis stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
[SW4]

上述4台交换机 桥ID 比较,优先级数字越小,优先级越高,优先级相同,则比较MAC 地址,mac地址越小,优先级越大


根端口选举

非根交换机在选举根端口分别依据该端口的根路径开销、对端BID(Bridge ID )、对端PID(Port ID) 和本端PID



指定端口选举

首先比较累计路径开销,累计路径开销最小的端口就是指定端口。如果累计路径开销相同,则比较端口所在交换机的桥ID,所在桥ID最小的端口被选举为指定端口。
如果通过累计路径端口和所在桥ID选举不出来,则比较端口ID,端口ID最小的被选定位指定端口。

备注: 只有指定端口和根端口可以转发数据。其他端口为预备端口,被阻塞,不能转发数据。





##指定开销标准
[SW1]stp pathcost-standard ?
  dot1d-1998  IEEE 802.1D-1998
  dot1t       IEEE 802.1T
  legacy      Legacy



[SW1]stp pathcost-standard dot1t 
###disp stp 查看 开销标准 
Port Cost(Dot1T )   :Config=auto / Active=20000


[SW1]inter GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]stp cos	
[SW1-GigabitEthernet0/0/1]stp cost ?
  INTEGER<1-200000000>  Port path cost
###设置端口开销
[SW1-GigabitEthernet0/0/1]stp cost 200000
[SW1-GigabitEthernet0/0/1]di th
#
interface GigabitEthernet0/0/1
 stp instance 0 cost 200000
#
return
[SW1-GigabitEthernet0/0/1]
###确认
 Port Cost(Dot1T )   :Config=200000 / Active=200000
 
 ###设置权限 修改后发现这个变成 根桥 
 [SW1]stp priority 8192
[SW1]
[SW1]di stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge         :8192 .4c1f-cc9f-5efe
Config Times        :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times        :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC      :8192 .4c1f-cc9f-5efe / 0
CIST RegRoot/IRPC   :8192 .4c1f-cc9f-5efe / 0

[SW1]dis stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/2        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/4        DESI  FORWARDING      NONE
   
##修改成值,
 [SW1]stp priority 32768
[SW1]dis stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet0/0/1        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/2        ALTE  DISCARDING      NONE
   0    GigabitEthernet0/0/3        DESI  FORWARDING      NONE
   0    GigabitEthernet0/0/4        ROOT  FORWARDING      NONE
[SW1]  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

石兴稳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值