stp生成树协议

拓扑

在这里插入图片描述

概念

在这里插入图片描述
在这里插入图片描述

1、 选举根桥:比较优先级,再比较MAC地址(为交换机默认VLAN1的MAC地址),最小MAC地址为根桥。根桥交换机所有接口永远不会出现阻塞状态。根桥的所有端口都是指定端口,指定端口被标记为转发端口。

2、选举根端口:按如下顺序选举,满足条件即停止。A、计算非根交换机到达根桥的链路开销;B、比较非根交换机的上行交换机桥ID(由优先级与MAC地址决定);C、上行交换机的最小端口号所连接的非交换机的端口为根端口。

3、选举指定端口:非根交换机与非根交换机之间连接线的两个端口中必定有一个端口为指定端口,此时比较两个非根交换机的根端口到达根桥的最低链路开销,将最低开销的非根交换机为准,其所在的连接线(为上面非根交换机与非根交换机之间连接线)的端口为指定端口,如果链路开销一样最后比较各自的桥ID即可。指定端口被标记为转发端口。可通过比较发送的BPDU;
4、阻塞其他端口

检查stp

检查生成树协议

ESW1#sh spanning-tree sum
Root bridge for: VLAN1.
PortFast BPDU Guard is disabled
UplinkFast is disabled
BackboneFast is disabled

Name                 Blocking Listening Learning Forwarding STP Active
-------------------- -------- --------- -------- ---------- ----------
VLAN1                0        0         0        1          1         
-------------------- -------- --------- -------- ---------- ----------
              1 VLAN 0        0         0        1          1    

默认是开通的

ESW1#sh spanning-tree bri

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     cc01.3100.0000
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     cc01.3100.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/2      128.3    128    19 FWD     0 32768 cc01.3100.0000 128.3 

打开每个交换机的互联接口
查看,stp效果

ESW1#sh spanning-tree vlan 1

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc01.3100.0000
  Configured hello time 2, max age 20, forward delay 15
  We are the root of the spanning tree
  Topology change flag set, detected flag set
  Number of topology changes 2 last change occurred 00:00:53 ago
          from FastEthernet0/0
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15 
  Timers: hello 1, topology change 9, notification 0, aging 300

 Port 1 (FastEthernet0/0) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.1.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc01.3100.0000
   Designated port id is 128.1, designated path cost 0
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 44, received 2

 Port 3 (FastEthernet0/2) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.3.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc01.3100.0000
   Designated port id is 128.3, designated path cost 0
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 700, received 1
ESW2#sh spanning-tree vlan 1

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc02.165c.0000
  Configured hello time 2, max age 20, forward delay 15
  Current root has priority 32768, address cc01.3100.0000
  Root port is 1 (FastEthernet0/0), cost of root path is 19
  Topology change flag not set, detected flag not set
  Number of topology changes 2 last change occurred 00:00:45 ago
          from FastEthernet0/1
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15 
  Timers: hello 0, topology change 0, notification 0, aging 300

 Port 1 (FastEthernet0/0) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.1.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc01.3100.0000
   Designated port id is 128.1, designated path cost 0
   Timers: message age 2, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 2, received 41

 Port 2 (FastEthernet0/1) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.2.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc02.165c.0000
   Designated port id is 128.2, designated path cost 19
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 39, received 0
ESW3#sh spanning-tree vlan 1

 VLAN1 is executing the ieee compatible Spanning Tree protocol
  Bridge Identifier has priority 32768, address cc03.0ed4.0000
  Configured hello time 2, max age 20, forward delay 15
  Current root has priority 32768, address cc01.3100.0000
  Root port is 3 (FastEthernet0/2), cost of root path is 19
  Topology change flag not set, detected flag not set
  Number of topology changes 0 last change occurred 00:23:36 ago
  Times:  hold 1, topology change 35, notification 2
          hello 2, max age 20, forward delay 15 
  Timers: hello 0, topology change 0, notification 0, aging 300

 Port 2 (FastEthernet0/1) of VLAN1 is blocking
   Port path cost 19, Port priority 128, Port Identifier 128.2.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc02.165c.0000
   Designated port id is 128.2, designated path cost 19
   Timers: message age 3, forward delay 0, hold 0
   Number of transitions to forwarding state: 0
   BPDU: sent 0, received 39

 Port 3 (FastEthernet0/2) of VLAN1 is forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.3.
   Designated root has priority 32768, address cc01.3100.0000
   Designated bridge has priority 32768, address cc01.3100.0000
   Designated port id is 128.3, designated path cost 0
   Timers: message age 2, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   BPDU: sent 1, received 716

ESW3的f0/1被阻塞

抓包

在这里插入图片描述

优先级

ESW1#sh spanning-tree vlan 1 bri 

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     cc01.3100.0000
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     cc01.3100.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0      128.1    128    19 FWD     0 32768 cc01.3100.0000 128.1  
FastEthernet0/2      128.3    128    19 FWD     0 32768 cc01.3100.0000 128.3 

esw1是根桥

ESW2#sh spanning-tree vlan 1 bri

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     cc01.3100.0000
             Cost        19
             Port        1 (FastEthernet0/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     cc02.165c.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/0      128.1    128    19 FWD     0 32768 cc01.3100.0000 128.1  
FastEthernet0/1      128.2    128    19 FWD    19 32768 cc02.165c.0000 128.2
ESW3#sh spanning-tree vlan 1 bri

VLAN1
  Spanning tree enabled protocol ieee
  Root ID    Priority    32768
             Address     cc01.3100.0000
             Cost        19
             Port        3 (FastEthernet0/2)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768
             Address     cc03.0ed4.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface                                   Designated
Name                 Port ID Prio Cost  Sts Cost  Bridge ID            Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet0/1      128.2    128    19 BLK    19 32768 cc02.165c.0000 128.2  
FastEthernet0/2      128.3    128    19 FWD     0 32768 cc01.3100.0000 128.3

缺点

转移时间是50秒,如果线路不稳定会造成网络不可用。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值