STP生成树协议

STP生成树协议:

STP选举过程:

1选举根桥(Root Bridge)
2在每个非根桥上选举一个根端口(Root Port)
3选举指定端口(Designated Port)
4阻塞剩余端口(Non-Designated Port)

STP选举依据:

Bridge ID:

2字节(16bit)6字节(48bi’t)
Bridge ID端口优先级(Priority)默认值为32768(16bit的中间十进制数值),步长为4096(16bit最高4bit),后12为vlan id交换机mac地址

路径开销(通过链路速度决定):

COST表:

Bandwidth(Mbps)4101645100155100010000
cost值2501006239191442

Port ID:

端口优先级端口编号
Port ID8bit(默认值1288bit(不可更改)

1.选举根桥(Root Bridge):

比较交换机的Bridge ID,先比较优先级,数值小的胜出,如相同则比较MAC地址,数值小的胜出,作为根桥

2.指定非根网桥上的根端口(Root Port):

比较去往根桥路径开销,数值越小越好,如相同,则比较发送方的Bridge ID,数值小的胜出,如相同则比较Port ID 小的胜出

3.选举指定端口(Designated Port):

比较去往根桥路径开销,数值越小越好,如相同,则比较发送方(发送BPDU的一方,既链路的另一方)的Bridge ID,数值小的胜出,如相同则比较Port ID 小的胜出

4.阻塞剩余端口:

如果既不是Root Port,也不是Designated Port,那么就会被阻塞,不同的stp协议名称不同,PVST(Alternate Port),STP(Blocking Port)

选举原则:

  1. 比较Bridge ID,数值小的胜出(只用在选举Root Bridge时使用)
  2. 比较根路径开销,数值小的胜出
  3. 比较发送方的Bridge ID,数值小的胜出
  4. 比较Port ID,数值小的胜出

选举总结:

  • 根桥上的端口都是指定端口
  • 根端口的对端一定是指定端口
  • 每个非根交换机上只有一个根端口
  • 每条链路上必有一个指定端口

STP生成树版本:

STP实验:

https://s2.loli.net/2022/05/16/JMVW5fE9DUGwu3i.png

https://s2.loli.net/2022/05/16/Dg5jOxPlktcIQb4.png

SW0:

Switch#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769                   #优先级32768 + 1(vlan1)               
             Address     0010.11A5.D287          #MAC地址
             Cost        19                      #根桥cost百兆线   
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p         #f0/1 root port
Fa0/2            Altn BLK 19        128.2    P2p         #f0/2 ALternate port

SW1:

Switch#show spanning-tree 
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769                            
             Address     0010.11A5.D287
             This bridge is the root                #switch1 为根桥
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0010.11A5.D287
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- ------------------spanning-tree vlan 1 root  primary--------------
Fa0/2            Desg FWD 19        128.2    P2p    #f0/2为指定端口
Fa0/1            Desg FWD 19        128.1    P2p    #f0/1为指定端口

改变SW0的优先级,这样SW1就可以作为根桥了,交换机的不同端口的角色也就随之改变:

SW0:
Switch(config)#spanning-tree vlan 1 priority ?
  <0-61440>  bridge priority in increments of 4096   #设置优先级为4096的倍数
Switch(config)#spanning-tree vlan 1 priority 4096     #设置SW0的优先级为4096比SW1小,这样SW1就作为根桥了

也可以把直接把SW0设置为根桥:

SW0:
Switch(config)#spanning-tree vlan 1 root  primary   #设置这个交换机为这个生成树的根桥这个命令
可以将当前交换机的的默认优先级减去8192  32769 - 8192 = 24577

Switch(config)#spanning-tree vlan 1 root primary   
Switch(config)#do show span
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577          #32769 - 8192 = 24577
             Address     0090.0C46.AD25
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    24577  (priority 24576 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg LSN 19        128.2    P2p

Switch(config)#spanning-tree vlan 1 root  secondary  #这个将默认优先级减去4096,这个命令重复执行只减去一次
可以将当前交换机的的默认优先级减去4096  32769 - 4096 = 28673
如果根桥的优先级不是默认值,则设置为根桥优先级减去4096,让非根桥成为根桥,建议手动设置优先级

Switch(config)#spanning-tree vlan 1 root  secondary 
Switch(config)#do show span
Switch(config)#do show span
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    28673                   #32769 - 4096 = 28673
             Address     0090.0C46.AD25
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    28673  (priority 28672 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    P2p
Fa0/2            Desg FWD 19        128.2    P2p

设置完成后,SW0已经作为根桥了:

https://s2.loli.net/2022/05/16/td89OEBU3uYI7iL.png

改变交换机SW0的f0/1的vlan 1 的COST值,就可以实现指定某个端口的角色,如将原来RP的f0/1改变成阻塞端口:

SW0:
**Switch(config)#int f0/1**
Switch(config-if)#spanning-tree vlan 1 cost 40
Switch(config-if)#do show span
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0010.11A5.D287
             Cost        19
             Port        2(FastEthernet0/2)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Altn BLK 40        128.1    P2p
Fa0/2            Root LSN 19        128.2    P2p

等该生成树收敛完成端口f0/1就会变成阻塞端口:

https://s2.loli.net/2022/05/16/VfClHELkoFUg84d.png

改变SW1上f0/1端口优先级,以达到f0/1作为阻塞端口,而f0/2作为RP:

Switch(config-if)#spanning-tree port-priority 64 #修改端口的优先级,改变步长为16,默认为128
改为240最高值,16为最低值,因为端口ID的最高四位为端口优先级

Switch(config-if)#do show span
VLAN0001
  Spanning tree enabled protocol ieee   #协议为PVST协议
  Root ID    Priority    32769
             Address     0010.11A5.D287
             This bridge is the root
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0010.11A5.D287
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Desg FWD 19        128.2    P2p    
Fa0/1            Desg FWD 19        240.1    P2p    #端口的优先级为240

改变stp计时器,不建议修改,会造成网络不稳定,而且所有的交换机都要修改

Switch(config)#spanning-tree vlan 1 hello-time 4   #改变hello-time 为4s
Switch(config)#spanning-tree vlan 1 max-age 26      #改变max-age为26s
Switch(config)#spanning-tree vlan 1 forward-time 20  #改变forward状态改变时间为 20s

另一种改变stp计时器的方法,设定从网络一端到另一端需要经过多少个交换机,switch会按照这个距离去
设定计时器
Switch(config)#spanning-tree vlan 1 root primary diameter ?
   <2-7>  Maximum number of bridges between any two end nodes  #任意两个节点中的最大网桥数

https://s2.loli.net/2022/05/16/EruYCQG3fsWzojU.png

STP版本历史:

协议PVST+RPVST+MST
标准CiscoCisco802.1s 802.1Q
收敛速度SlowRapidRapid
trunk协议支持802.1Q 或者 ISL802.1Q 或者 ISL802.1Q 或者 ISL
IOS系统显示ieeerstpmst

RSTP协议:

STP的后续版本,为了解决生成树的收敛时间过慢的问题,而开发出的后续协议版本,在传统的STP协议中,网络的架构发生改变的话,STP重新计算到收敛的时间需要30分钟以上,而在实际情况中,交换机的拓扑发生变化到STP重新收敛到网络重新变为可用状态的时间,最多可以到3分红以上,在现代网络中,这种收敛速度太慢,所以就有了RSTP和MST这样的为了缩短网络收敛时间而产生的STP协议的后续版本

RSTP的不同之处:

RSTP保留了Root Port和Designated Port的设计,选择方法与STP相同,另外加入了ALternate Port和Backup port,用来加快收敛时间

ALternate Port:

没有成为RP和DP的Port会成为ALternate Port,就是去到根桥的另外一条路,会阻塞端口,处于Blocking状态

Backup port:

在通一个广播域中的没有成为DP和RP的端口,只会出现在HUB上面,但是HUB在现代网络中已经几乎见不到了,也会阻塞端口,处于Blocking状态

端口状态:

STP协议端口状态端口作用RSTP端口状态
Forwarding接收发送数据Forwarding
Learning构建MAC地址表Learning
Listening接收和发送BPDU,并参与stp选举Discarding
Blcoking仅接收BPDUDiscarding
Disabled关闭端口DIscarding

Link Type:

LinkType是在RSTP中新增的概念,RSTP会把Link非为Edge Port,Point to Point Non-edge Port以及Shared Non-edge Port三种。

Edge Port:

Edge Port 由Discarding直接编程forwarding,并不会产生环路或者发生拓扑变动而发送BPDU,从而Swithc不会清空MAC地址,一般接在主机这样的设备中,让主机的端口快速发送数据,Edge Port一般用在access端口:

Switch(config)#spanning-tree portfast ?    #全局模式下设置postfast
  bpduguard  Enable portfast bpdu guard on this switch
  default    Enable portfast by default on all access ports  #默认在所有端口上启用POSTfast

Point to Point:

两个端口工作在全双工的模式下

shared Point:

两个端口工作在半双工的模式下,出现这样的状况,端口可能产生了问题

SW1;
Switch(config)#spanning-tree mode rapid-pvst   #切换stp协议为rstp
Switch(config)#do show span
VLAN0001
  Spanning tree enabled protocol rstp         #显示协议为rstp
  Root ID    Priority    32769
             Address     0010.11A5.D287
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root LSN 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    P2p

Switch(config-if)#spanning-tree ?
Switch(config-if)#spanning-tree portfast   #更改端口为postfast模式
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface  when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION

%Portfast has been configured on FastEthernet0/3 but will only
have effect when the interface is in a non-trunking mode.
Switch(config-if)#spanning-tree portfast ?
  disable  Disable portfast for this interface  #禁用portfast
  trunk    Enable portfast on the interface even in trunk mode #在trunk模式运行portfast
如果在trunk模式中收到bpdu,则这个端口禁用postfast转为完全stp模式

Switch(config-if)#spanning-tree link-type shared   #强制把point to point 改为shared模式,也就是半双工
Switch(config-if)#do show span                           
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0010.11A5.D287
             Cost        19
             Port        1(FastEthernet0/1)
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0090.0C46.AD25
             Hello Time  2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Root FWD 19        128.1    P2p
Fa0/2            Altn BLK 19        128.2    Shr    #状态改为shared,如果不是手动改变的话,自动出现就要考虑端口是否有故障

RSTP负载均衡:

在SW0和SW1中创建vlan1和vlan2,在不同的vlan中配置不同的stp,这样不同的vlan走不同的链路,这样就通过vlan实现了负载均衡:

https://s2.loli.net/2022/05/18/c6UHxw39QmdZWn2.png

SW1:

Switch(config)#vlan 2                         #在SW1中创建vlan2
Switch(config)#int rang f0/1-2        
Switch(config-if-range)#switchport mode trunk   #把f0/1和f0/2设置成trunk模式

SW0:

Switch(config)#vlan 2                         #在SW0中创建vlan2
Switch(config)#int rang f0/1-2        
Switch(config-if-range)#switchport mode trunk   #把f0/1和f0/2设置成trunk模式
Switch(config)#int f0/2
Switch(config-if)#spanning-tree vlan 2 port-priority 64  #把vlan2中的f/2端口的优先级调高
让f0/2在vlan2 中的sw1的f0/2端口作为RP,F0/1阻塞

vlan1和vlan2的流量转发的路径不同,实现stp的负载均衡:

https://s2.loli.net/2022/05/20/8CGJ2OiZ1dtBnIH.png

https://s2.loli.net/2022/05/20/FRLXpuD93VgHlzC.png

MSTP:

Multiple Spanning Tree Protocol (MSTP) 多重生成树协议,MSTP出现是为了解决在PSTP出现的没有区域和RSTP中vlan缺乏vlan分组的管理功能。

MSTP实验:

SW1和SW2,SW3,不同的instance的端口角色不同,在vlan10中,SW1为根桥,而在默认vlan 1中SW2为根桥

https://s2.loli.net/2022/05/18/uV81cOjNhmIWpYf.png

SW1:

SW1(config)#int range g0/1-2
SW1(config)#switchport mode trunk
SW1(config)#spanning-tree mst configuration  #设置MSTP协议
SW1(config-mst)#name lion                   #设置名称
SW1(config-mst)#revision 1                     #设置MSTP协议区域以一
SW1(config-mst)#instance  1 vlan 10-15         #设置vlan和instan 对应表
SW1(config-mst)#
SW1#show spanning-tree mst configuration       #显示MSTP设置,vlan存在时
才会显示instance和vlan对应关系

SW1#show spanning-tree mst configuration 
Name      [lion]
Revision  1     Instances configured 3

Instance  Vlans mapped
--------  ---------------------------------------------------------------------
0         1-9,16-19,26-4094
1         10-15
--------  ---------------------------------------------------------------------

SW1(config)#spanning-tree mode mst  #启动MSTP协议

SW1(config-if)#int range g0/0-1            
SW1(config-if)#switchport access vlan 10  #g0/0,g0/1划分给vlan 10

SW1(config-if-range)#do show span mst 0

##### MST0    vlans mapped:   1-9,16-19,26-4094
Bridge        address 5000.0001.0000  priority      32768 (32768 sysid 0)
Root          this switch for the CIST
Operational   hello time 2 , forward delay 15, max age 20, txholdcount 6 
Configured    hello time 2 , forward delay 15, max age 20, max hops    20

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/0            Desg FWD 20000     128.1    P2p 
Gi0/1            Desg FWD 20000     128.2    P2p 
Gi0/2            Desg FWD 20000     128.3    P2p 
Gi0/3            Desg FWD 20000     128.4    P2p 
Gi1/0            Desg FWD 20000     128.5    P2p 
Gi1/1            Desg FWD 20000     128.6    P2p 
Gi1/2            Desg FWD 20000     128.7    P2p 
Gi1/3            Desg FWD 20000     128.8    P2p

SW1#show span

MST0
  Spanning tree enabled protocol mstp
  Root ID    Priority    24576
             Address     5000.0002.0000
             Cost        0
             Port        1 (GigabitEthernet0/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768  (priority 32768 sys-id-ext 0)
             Address     5000.0001.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Root FWD 20000     128.1    P2p 
Gi0/1               Desg FWD 20000     128.2    P2p 
Gi0/2               Desg FWD 20000     128.3    P2p 
Gi0/3               Desg FWD 20000     128.4    P2p 
Gi1/0               Desg FWD 20000     128.5    P2p 
Gi1/1               Desg FWD 20000     128.6    P2p 
Gi1/2               Desg FWD 20000     128.7    P2p 
Gi1/3               Desg FWD 20000     128.8    P2p 
          
          
          
MST1      
  Spanning tree enabled protocol mstp
  Root ID    Priority    32769
             Address     5000.0001.0000        #在MST1中SW1为根桥,在vlan10-15中
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     5000.0001.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Desg FWD 20000     128.1    P2p 
Gi0/1               Desg FWD 20000     128.2    P2p

SW2:

SW2#show span

MST0
  Spanning tree enabled protocol mstp
  Root ID    Priority    24576
             Address     5000.0002.0000
             This bridge is the root               #在mst0中,也就是vlan1中sw2是根桥
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    24576  (priority 24576 sys-id-ext 0)
             Address     5000.0002.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Desg FWD 20000     128.1    P2p 
Gi0/1               Desg FWD 20000     128.2    P2p 
Gi0/2               Desg FWD 20000     128.3    P2p 
Gi0/3               Desg FWD 20000     128.4    P2p 
Gi1/0               Desg FWD 20000     128.5    P2p 
Gi1/1               Desg FWD 20000     128.6    P2p 
Gi1/2               Desg FWD 20000     128.7    P2p 
Gi1/3               Desg FWD 20000     128.8    P2p 

          
          
MST1      
  Spanning tree enabled protocol mstp
  Root ID    Priority    32769
             Address     5000.0001.0000
             Cost        20000
             Port        2 (GigabitEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     5000.0002.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Desg FWD 20000     128.1    P2p 
Gi0/1               Root FWD 20000     128.2    P2p

SW3:

SW3的mstp配置和端口配置一样

SW3#show spanning-tree
MST0
  Spanning tree enabled protocol mstp
  Root ID    Priority    24576
             Address     5000.0002.0000
             Cost        0
             Port        1 (GigabitEthernet0/0)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32768  (priority 32768 sys-id-ext 0)
             Address     5000.0003.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Root FWD 20000     128.1    P2p 
Gi0/1               Altn BLK 20000     128.2    P2p 
Gi0/2               Desg FWD 20000     128.3    P2p 
Gi0/3               Desg FWD 20000     128.4    P2p 
Gi1/0               Desg FWD 20000     128.5    P2p 
Gi1/1               Desg FWD 20000     128.6    P2p 
Gi1/2               Desg FWD 20000     128.7    P2p 
Gi1/3               Desg FWD 20000     128.8    P2p 
          
          
          
MST1      
  Spanning tree enabled protocol mstp
  Root ID    Priority    32769
             Address     5000.0001.0000
             Cost        20000
             Port        2 (GigabitEthernet0/1)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     5000.0003.0000
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
          
Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Altn BLK 20000     128.1    P2p 
Gi0/1               Root FWD 20000     128.2    P2p

SW2(config)#spanning-tree mst 0 root primary

配置完在mst0中的端口角色:

https://s2.loli.net/2022/05/18/MguO6PQRShfGEK5.png

在创建的mst1中的端口角色:

https://s2.loli.net/2022/05/18/cbzEUVS6WI914JP.png

这样在vlan1中SW3的g0/1进行阻塞,在vlan10-15中SW2的g0/0进行阻塞,实现负载不同vlan的负载均衡

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
STP(Spanning Tree Protocol,生成树协议)是一种用于在以太网网络中防止环路并确保冗余链路可靠性的协议。它的基本原理是通过选择一个根交换机,并在网络中的各个交换机之间建立一棵生成树,从而实现环路的消除。 STP基于以下几个核心概念: 1. 根交换机(Root Switch):在STP网络中,选举一个交换机作为根交换机,该交换机将成为生成树的根节点。根交换机具有最低的桥优先级(Bridge Priority),桥优先级是一个用于选举根交换机的参数。 2. 桥优先级(Bridge Priority):每个交换机都有一个桥优先级,用于确定其在选举根交换机过程中的优先级。较低的桥优先级将使得交换机更有可能成为根交换机。 3. 端口优先级(Port Priority):每个交换机上的端口都有一个端口优先级,用于确定在生成树中的路径选择。较低的端口优先级将使得该端口更有可能成为根交换机到其他交换机之间的路径。 4. 生成树(Spanning Tree):生成树是一棵由交换机和链路组成的树状结构,用于连接网络中的所有交换机,并确保没有环路。生成树中的某些链路被标记为指定端口(Designated Port),用于传输数据;其他链路被标记为阻塞端口(Blocked Port),用于防止环路的发生。 STP的工作原理是通过交换机之间的BPDU(Bridge Protocol Data Unit)交换来实现的。交换机会通过BPDU消息进行根交换机选举、生成树构建和端口状态转换等过程。BPDU消息包含了交换机的标识信息、路径开销和优先级等参数。 总结起来,STP通过选举根交换机、构建生成树和阻塞冗余链路的方式,确保以太网网络中没有环路,并提供冗余链路的可靠性。这样可以提高网络的可用性和稳定性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值