链路类型和STP生成树

三种链路类型原理

Access 接入链路

接受数据:

               当接受到无标记帧的时候,打上自己pvid并接受
               当接受到有标记帧的时候,对比自己的pvid,相同接受,不同丢弃

发送数据:

              对比vlsanid是否与自己相同,相同就剥离vlanid,不同就丢弃

Trunk 中继链路

接受数据:

             接受到无标记帧的时候,打上自己的pvid,对比允许列表,没有就丢弃
             接受到有标记帧的时候,对比允许列表,有就接受,没有就丢弃

发送数据:

             对比自己的pvid,相同,就剥离发送,不同,就携带原理的vlanid发送 

Hybrid 混合模式

接受数据:

              当接受到无标记帧的时候,查询允许列表,有就打上自己的pvid接受,无就不接受 
              当接受到有标记帧的时候,有就接受,无就丢弃

发送数据:

            对tag和untag表,如果有,是tag就带标签发送,是untag,就剥掉标签发送,如果不存在两个标准,就直接丢弃

配置命令

[sw1]vlan batch 10 20 30
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]port hybird pvid vlan 10
[sw1-Ethernet0/0/1]port hubird untagged vlan 10 20

STP生成树

1,场景:

提高网络可好性,交换网络中通常会使用冗余链路,然而,冗余链路会交给交换网络带来环路风险,并导致广播风暴以及MAC地址表不稳定等问题,进而会影响到用户的通信质量。生成树协议STP(spanning tree protocol)可以在提高可靠性的同时用能避免环路带来的各种问题。

2,作用:

消除环路,实现链路备份

3,BPDU报文

    STP需要网络设备相互交换消息来检测桥接环路,该消息称为网桥协议数据单元BPDU。STP之所以能够良好的工作并构建一个无环的网络,是依赖于BPDU报文的泛洪,并根据报文中相关字段计算的结果
    root identifier 根id,:发送此配置bpdu的减缓所认为的根交换的交换机表示
    root path cost到根的路径开销:发送此配置bpdu的交换机到达根交换机的最短路径总开销,含交换机根端口的开销
    桥id:发送此配置bpdu的交换机的stp交换机表示
    端口id:发送此配置bpdu的交换机端口的stp端口表示

4,生成树算法的步骤

1、选择根网桥
2、每个非根网桥上选择根端口(RP)
3、在每条链路上都要选择一个指定端口(DP)
4、阻塞既不是根端口又不是指定端口的端口(AP)

一、选择根网桥
依据:网桥ID(BID)
网桥ID=网桥优先级+网桥的MAC地址
网桥优先级的取值范围:0-65535
默认值:32768

优先比较优先级,选最小
当优先级相等的情况下,选MAC地址小的
带宽10M 开销值是100
带宽100,开销值19
带宽1000,开销值4
ng)

二、何选择根端口?
1、到根桥最低的根路径成本
某个网桥到达根网桥的中间所有线路的路径成本之和
用来代表一条线路带宽的大小
2、直连的网桥ID最小的
3、对端端口ID(PID)最小的
端口ID=端口优先级+端口编号
端口优先级:0-255 默认值:128

三、如何选择指定端口?
根网桥上的每个端口都是指定端口,都不会被阻塞
1、比较到达根桥的RPC(Root Path Cost),越小越优。
2、比较BPDU包发送者的BID,越小越优。
3、比较BPDU包发送者的PID,越小越优。
4、比较BPDU包接收者的PID,越小越优。

作业

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

sw1

[sw1]vlan batch 1 2 3 10
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]p h p v 1
[sw1-Ethernet0/0/1]p h u v 1 2
[sw1-Ethernet0/0/1]int e0/0/2
[sw1-Ethernet0/0/2]p h p v 1
[sw1-Ethernet0/0/2]p h u v 1 2
[sw1-Ethernet0/0/2]int e0/0/3
[sw1-Ethernet0/0/3]p h p v 10
[sw1-Ethernet0/0/3]p h u v 3 10
[sw1-Ethernet0/0/3]int e0/0/4
[sw1-Ethernet0/0/4]p h p v 1
[sw1-Ethernet0/0/4]p h u v 1 2
[sw1-Ethernet0/0/4]p h t v 3 10

sw2

[sw2]vlan batch 1 2 3 10
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]p h p v 1
[sw2-Ethernet0/0/1]p h u v 1 2
[sw2-Ethernet0/0/1]p h t v 3 10
[sw2-Ethernet0/0/1]int e0/0/2
[sw2-Ethernet0/0/2]p h p v 2
[sw2-Ethernet0/0/2]p h u v 1 2
[sw2-Ethernet0/0/2]int e0/0/3
[sw2-Ethernet0/0/3]p h o v 3
^
Error:Ambiguous command found at ‘^’ position.
[sw2-Ethernet0/0/3]p h p v 3
[sw2-Ethernet0/0/3]p h u v 3 10
[sw2-Ethernet0/0/3]

pc1可以与pc2和pc4互通,不可与pc3和pc5互通

PC>ping 10.1.1.12

Ping 10.1.1.12: 32 data bytes, Press Ctrl_C to break
From 10.1.1.12: bytes=32 seq=1 ttl=128 time=31 ms
From 10.1.1.12: bytes=32 seq=2 ttl=128 time=47 ms

PC>ping 10.1.1.13

Ping 10.1.1.13: 32 data bytes, Press Ctrl_C to break
From 10.1.1.11: Destination host unreachable
From 10.1.1.11: Destination host unreachable

PC>ping 10.1.1.100

Ping 10.1.1.100: 32 data bytes, Press Ctrl_C to break
From 10.1.1.100: bytes=32 seq=1 ttl=128 time=78 ms
From 10.1.1.100: bytes=32 seq=2 ttl=128 time=63 ms

PC>ping 10.1.1.200

Ping 10.1.1.200: 32 data bytes, Press Ctrl_C to break
From 10.1.1.11: Destination host unreachable
From 10.1.1.11: Destination host unreachable

pc3与pc5互通,不与pc1,pc2,pc5互通

C>ping 10.1.1.200

Ping 10.1.1.200: 32 data bytes, Press Ctrl_C to break
From 10.1.1.200: bytes=32 seq=1 ttl=128 time=62 ms
From 10.1.1.200: bytes=32 seq=2 ttl=128 time=63 ms

PC>ping 10.1.1.100

Ping 10.1.1.100: 32 data bytes, Press Ctrl_C to break
From 10.1.1.13: Destination host unreachable
From 10.1.1.13: Destination host unreachable

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

sw1

[sw1]undo info-center enable
Info: Information center is disabled.
[sw1]vlan b
[sw1]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]p h p v 10
[sw1-Ethernet0/0/1]p h u v 10 30
[sw1-Ethernet0/0/1]int e0/0/2
[sw1-Ethernet0/0/2]p h p v 20
[sw1-Ethernet0/0/2]p h u v 20 30
[sw1-Ethernet0/0/2]int e0/0/3
[sw1-Ethernet0/0/3]p h t 10 20 30
^
Error:Ambiguous command found at ‘^’ position.
[sw1-Ethernet0/0/3]p h t v 10 20 30

sw2

[sw2]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]p h t v 10 20 30
[sw2-Ethernet0/0/1]int e0/0/2
[sw2-Ethernet0/0/2]p h p v 10
[sw2-Ethernet0/0/2]p h u v 10 30
[sw2-Ethernet0/0/2]int e0/0/3
[sw2-Ethernet0/0/3]p h p v 20
[sw2-Ethernet0/0/3]p h u v 20 30
[sw2-Ethernet0/0/3]int e0/0/4
[sw2-Ethernet0/0/4]p h p v 30
[sw2-Ethernet0/0/4]p h u v 10 20 30
[sw2-Ethernet0/0/4]int e0/0/5
[sw2-Ethernet0/0/5]p h p v 30
[sw2-Ethernet0/0/5]p h u v 10 20 30

pc1可以和pc3, pc5,pc6通信,不可以和pc2,pc4通信,即vlan10可以和vlan30通信,不可以和vlan20 通信

PC>ping 10.0.10.30

Ping 10.0.10.30: 32 data bytes, Press Ctrl_C to break
From 10.0.10.30: bytes=32 seq=1 ttl=128 time=63 ms
From 10.0.10.30: bytes=32 seq=2 ttl=128 time=78 ms

PC>ping 10.0.10.20

Ping 10.0.10.20: 32 data bytes, Press Ctrl_C to break
From 10.0.10.10: Destination host unreachable
From 10.0.10.10: Destination host unreachable

PC>ping 10.0.10.40

Ping 10.0.10.40: 32 data bytes, Press Ctrl_C to break
From 10.0.10.10: Destination host unreachable
From 10.0.10.10: Destination host unreachable

PC>ping 10.0.10.50

Ping 10.0.10.50: 32 data bytes, Press Ctrl_C to break
From 10.0.10.50: bytes=32 seq=1 ttl=128 time=62 ms
From 10.0.10.50: bytes=32 seq=2 ttl=128 time=78 ms

PC>ping 10.0.10.60

Ping 10.0.10.60: 32 data bytes, Press Ctrl_C to break
From 10.0.10.60: bytes=32 seq=1 ttl=128 time=63 ms
From 10.0.10.60: bytes=32 seq=2 ttl=128 time=62 ms

pc2可以和pc5,pc6通讯,不可以和pc1,pc3通信,即vlan20可以和vlan30通信,不可以和vlan10通信

PC>ping 10.0.10.50

Ping 10.0.10.50: 32 data bytes, Press Ctrl_C to break
From 10.0.10.50: bytes=32 seq=1 ttl=128 time=63 ms
From 10.0.10.50: bytes=32 seq=2 ttl=128 time=62 ms

PC>ping 10.0.10.10

Ping 10.0.10.10: 32 data bytes, Press Ctrl_C to break
From 10.0.10.20: Destination host unreachable
From 10.0.10.20: Destination host unreachable

PC>ping 10.0.10.60

Ping 10.0.10.60: 32 data bytes, Press Ctrl_C to break
From 10.0.10.60: bytes=32 seq=1 ttl=128 time=62 ms
From 10.0.10.60: bytes=32 seq=2 ttl=128 time=47 ms

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

答:第一步确定根网桥
1,比较pri 都是32168,优先级都一样
2,比较MAC地址,sw1的MAC地址最小
所以sw1是网桥
第二步,选择端口
1,端口优先级都一样,
2,端口的ID也一样
3,sw2的端口1的cost值是19,sw2的端口2的cost值是119,
sw3的端口1的cost值是38,sw3的端口2的cost值 是100,
所以sw2的根端口是sw2的端口1
sw3的根端口是sw的端口1
第三步,确定指定端口
1,网桥上的端口都是指定端口,则,sw1的端口1和端口2都是指定端口
2,比较cost值,根据步骤二中计算的cost值,sw3的端口2的值小于sw2的端口2,则sw3的端口2也是指定端口
第四步,确定阻塞端口
最后还剩下sw2的端口2,则sw2的端口2为阻塞端口

思考题

在这里插入图片描述

sw1

[sw1]vlan b
[sw1]vlan batch 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]p h p v 10
[sw1-GigabitEthernet0/0/1]p h u v 10 20 30
[sw1-GigabitEthernet0/0/1]int e0/0/2
^
Error: Unrecognized command found at ‘^’ position.
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]p h p v 20
[sw1-GigabitEthernet0/0/2]p h u v 10 20 30
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]p h p v 30
[sw1-GigabitEthernet0/0/3]p h u v 10 20 30
[sw1-GigabitEthernet0/0/3]q
[sw1]int vlanif
^
Error:Incomplete command found at ‘^’ position.
[sw1]int vlanif10
[sw1-Vlanif10]ip add 192.168.10.1 24
[sw1-Vlanif10]int vlanif20
[sw1-Vlanif20]ip add 192.168.20.1 24
[sw1-Vlanif20]int vlanif30
[sw1-Vlanif30]ip add 192.168.30.1 24
[sw1-Vlanif30]q
[sw1]int g0/0/4
[sw1-GigabitEthernet0/0/4]p h p v 40
[sw1-GigabitEthernet0/0/4]p h t v 10 20 30 40
[sw1-GigabitEthernet0/0/4]q
[sw1]int vlanif40
[sw1-Vlanif40]ip add 10.0.0.1 8
[sw1-Vlanif40]q
[sw1]int g0/0/4
[sw1-GigabitEthernet0/0/4]p h t v 10 20 30 40 50
[sw1-GigabitEthernet0/0/4]
[sw1-GigabitEthernet0/0/4]int g0/0/1
[sw1-GigabitEthernet0/0/1]p h u v 10 20 30 40 50
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]p h u v 10 20 30 40 50
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]p h u v 10 20 30 40 50
[sw1-GigabitEthernet0/0/3]q
[sw1]ip ro
[sw1]ip route
[sw1]ip route-static 192.168.50.0 24 10.0.0.2

sw2

[sw2]vlan batch 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[sw2]int vlanif40
[sw2-Vlanif40]ip add 10.0.0.2 8
[sw2-Vlanif40]q
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]p h p v 40
[sw2-GigabitEthernet0/0/1]p h t v 10 20 30 40
[sw2-GigabitEthernet0/0/1]q
[sw2]vlan 50
[sw2-vlan50]
[sw2-vlan50]q
[sw2]int vlanif50
[sw2-Vlanif50]ip add 192.168.50.1 24
[sw2-Vlanif50]q
[sw2]int g0/0/2
[sw2-GigabitEthernet0/0/2]p h p v 50
[sw2-GigabitEthernet0/0/2]p h u v 10 20 30 40 50
[sw2-GigabitEthernet0/0/2]int g0/0/1
[sw2-GigabitEthernet0/0/1]p h t v 10 20 30 40 50
[sw2-GigabitEthernet0/0/1]q
[sw2]ip ro
[sw2]ip route
[sw2]ip route-static 0.0.0.0 0 10.0.0.1

全网互通,pc1可以和pc2,pc3,pc4互通

PC>ping 192.168.20.10

Ping 192.168.20.10: 32 data bytes, Press Ctrl_C to break
From 192.168.20.10: bytes=32 seq=1 ttl=127 time=78 ms
From 192.168.20.10: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.20.10: bytes=32 seq=3 ttl=127 time=32 ms

PC>ping 192.168.30.10

Ping 192.168.30.10: 32 data bytes, Press Ctrl_C to break
From 192.168.30.10: bytes=32 seq=1 ttl=127 time=47 ms
From 192.168.30.10: bytes=32 seq=2 ttl=127 time=63 ms
From 192.168.30.10: bytes=32 seq=3 ttl=127 time=31 ms

PC>ping 192.168.50.10

Ping 192.168.50.10: 32 data bytes, Press Ctrl_C to break
From 192.168.50.10: bytes=32 seq=1 ttl=126 time=78 ms
From 192.168.50.10: bytes=32 seq=2 ttl=126 time=94 ms
From 192.168.50.10: bytes=32 seq=3 ttl=126 time=78 ms

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值