2025-09-24 11:29:45 CST

This commit is contained in:
2025-09-24 11:30:03 +08:00
parent 1277db7f31
commit 324cc2e02a
33 changed files with 36 additions and 23 deletions

BIN
2_stp/lsw1dis.jpg Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
2_stp/lsw2dis.jpg Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 27 KiB

BIN
2_stp/lsw3dis.jpg Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 39 KiB

BIN
2_stp/lsw4dis.jpg Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -71,7 +71,7 @@
]
=== STP算法的步骤
生成树算法有三个步骤,下面以@原始有环拓扑 为例说明STP的工作原理。
#figure(image("原始有环拓扑.jpg",format: "png",fit:"stretch",width: 25%),caption: "原始有环拓扑")<原始有环拓扑>
#figure(image("原始有环拓扑.jpg",format: "jpg",fit:"stretch",width: 25%),caption: "原始有环拓扑")<原始有环拓扑>
+ 选举根交换机
拓扑中BID最小者当选。
@ -103,13 +103,13 @@
caption: "链路带宽的成本"
)
例如一系列千兆网口组成的路径每经过一个设备的成本就是4。成本最小的口就是根端口。
#figure(image("线路成本.jpg", format: "png", fit:"stretch",width: 45%),caption: "链路成本示例")<链路成本>
#figure(image("线路成本.jpg", format: "jpg", fit:"stretch",width: 45%),caption: "链路成本示例")<链路成本>
@链路成本A是根交换机从B、C的G0/1口到A的成本值均为4所以它们都被选为根端口。但是D的G0/1与G0/2口成本值都是4+4=8成本值相同则还需要进行网桥ID的比较。
- 对端的网桥IDBID最小。如上文所述@链路成本 这种情况中D到A的无论哪条路成本都是8则需要继续比较双方中哪个接口的对端BID更小。
#figure(image("对端BID最小.jpg", format: "png", fit:"stretch",width: 80%),caption: "对端BID最小")<对端BID最小>
#figure(image("对端BID最小.jpg", format: "jpg", fit:"stretch",width: 80%),caption: "对端BID最小")<对端BID最小>
B是00-06C是00-05即对端C的BID更小所以D的G0/2被选举为了根端口。
- 对端的端口IDPID最小。在最后如果路径成本和网桥ID都相同则还要比较端口ID的大小。
#figure(image("对端PID最小.jpg",format: "png", fit:"stretch",width: 65%),caption: "对端PID最小")<对端PID最小>
#figure(image("对端PID最小.jpg",format: "jpg", fit:"stretch",width: 65%),caption: "对端PID最小")<对端PID最小>
此处的PID优先级都是默认值为128。而Fa0/1比Fa0/2小所以Fa0/1被选举成为了根端口RP。
+ 选举指定端口并阻塞备用端口AP
@ -134,7 +134,14 @@
= 实验环境
== 实验背景
#para[
网工系的宿舍楼中有一套局域网各个寝室里有一些PC寝室之间有几台交换机PC和交换机之间通过网线连接。网工系学生热爱学习经常开展研讨会研究学术问题。在要求熄灯就寝之后网工系学生不能出寝室门于是他们在寝室的PC上开视频研讨会继续讨论学术问题。为了提高网络的可靠性他们在交换机之间安装了一些了冗余备份链路。但这会形成环路报文可能在环形网络中不断循环设备由于重复接收相同的报文处理能力会下降。所以他们还需要在交换机上配置生成树协议将环形网络结构修剪成无环路的树形网络结构。
某公司购置了 4 台交换机,组建网络。考虑到网络的可靠性,将 4 台交换机如
Figure 6 所示拓扑搭建。由于默认情况下,交换机之间运行 STP 后,根交换机、根端
口、指定端口的选择将基于交换机的 MAC 地址的大小,因此带来了不确定性,极
可能由此产生隐患。公司网络规划,需要 S1 作为主根交换机S2 作为 S1 的备份根
交换机。同时对于 S4 交换机E0/0/1 接口应该作为根端口。对于 S2 S3 之间的
链路,应该保证 S2 E0/0/3 接口作为指定端口。同时在交换机 S3 上,存在两个接
E0/0/10、E0/0/11 连接到测试 PC测试 PC 经常上下线网络,需要将交换机 S3
之相连的对应端口定义为边缘端口,避免测试电脑上下线对网络产生的影响。
]
== 实验设备
#align(center)[#table(
@ -158,57 +165,63 @@
要求在配置好各个端口的路径开销值之后运行STP能将@实验拓扑 中的Blocked Port端口阻塞。
== 按照拓扑图接线
按照拓扑图接线。
#figure(image("接线图.jpg", fit:"stretch",width: 80%),caption: "接线图")
#figure(image("接线图.jpg", format: "jpg" ,fit:"stretch",width: 80%),caption: "接线图")
== 配置PC
#para[
设置319寝室的IP地址为`192.168.3.19`319寝室的IP地址为`192.168.3.12`
设置两台PC的IP地址分别`10.130.81.211``10.130.81.203`
]
== 配置STP
#para[下列许多步骤在LSW1、LSW2、LSW3和LSW4上都有相同的操作这里只列出*LSW2*上的操作步骤。]
=== 配置STP工作模式
配置环网中的设备生成树协议工作在STP模式
#figure(image("step0.png",format: "png",fit:"stretch",width: 100%),caption: "配置STP工作模式")
#figure(image("step0.png",format: "jpg",fit:"stretch",width: 100%),caption: "配置STP工作模式")
=== 配置根桥和备份根桥设备
配置根桥设备为LSW1备份根桥设备为LSW4
#figure(image("step1.png",format: "png",fit:"stretch",width: 35%),caption: "配置根桥LSW1")
#figure(image("step2.png",format: "png",fit:"stretch",width: 60%),caption: "配置备份根桥LSW4")
#figure(image("step1.png",format: "jpg",fit:"stretch",width: 35%),caption: "配置根桥LSW1")
#figure(image("step2.png",format: "jpg",fit:"stretch",width: 60%),caption: "配置备份根桥LSW4")
=== 配置端口路径开销
配置端口的路径开销值:
#figure(image("step3.png",format: "png",fit:"stretch",width: 60%),caption: "配置端口路径开销")
#figure(image("step3.png",format: "jpg",fit:"stretch",width: 60%),caption: "配置端口路径开销")
特别地LSW3的g0/0/1口的路径开销值为20000:
#figure(image("step4.png",format: "png",fit:"stretch",width: 70%),caption: "配置LSW3的g0/0/1口路径开销")
#figure(image("step4.png",format: "jpg",fit:"stretch",width: 70%),caption: "配置LSW3的g0/0/1口路径开销")
=== 使能STP破除环路
- 将与PC机相连的端口设置为边缘端口。配置LSW2
#figure(image("step5.png",format: "png",fit:"stretch",width: 70%),caption: "配置LSW2边缘端口")
- 将与PC机相连的端口设置为边缘端口:
#figure(image("step5.png",format: "jpg",fit:"stretch",width: 70%),caption: "配置LSW3边缘端口")
配置LSW3的g0/0/1口为边缘端口并启用BPDU保护功能
#figure(image("step6.png",format: "png",fit:"stretch",width: 70%),caption: "配置LSW3边缘端口并启用BPDU保护")
#figure(image("step6.png",format: "jpg",fit:"stretch",width: 70%),caption: "配置LSW3边缘端口并启用BPDU保护")
- 设备全局使能STP:
#figure(image("step7.png",format: "png",fit:"stretch",width: 30%),caption: "全局使能STP")
#figure(image("step7-1.png",format: "jpg",fit:"stretch",width: 30%),caption: "全局使能STP")
== 实验结果验证
=== 查看各交换机端口状态
配置完成后,查看各个交换机的端口状态,确认生成树协议已经生效。
在LSW1上执行display stp brief命令查看端口状态和端口的保护类型结果如下
#figure(image("lsw1dis.jpg",format: "jpg",fit:"stretch",width: 75%),caption: "查看LSW1的STP状态")
将LSW1配置为根桥后与LSW2、LSW4相连的端口g0/0/2和g0/0/1在生成树计算中被选举为指定端口。
将LSW1配置为根桥后与LSW2、LSW3相连的端口g0/0/1和g0/0/2在生成树计算中被选举为指定端口。
在LSW2上执行display stp interface g0/0/1 brief命令查看端口g0/0/1状态结果如下
#figure(image("lsw2dis.jpg",format: "jpg",fit:"stretch",width: 80%),caption: "查看LSW2的g0/0/1端口状态")
端口g0/0/1在生成树选举中成为指定端口,处于*FORWARDING*状态。
端口g0/0/3在生成树选举中成为指定端口,处于*FORWARDING*状态。端口g0/0/2在生成树选举中成为Alternate端口处于*DISCARDING*状态。
在LSW3上执行display stp brief命令查看端口状态结果如下
#figure(image("lsw3dis.jpg",format: "jpg",fit:"stretch",width: 80%),caption: "查看LSW3")
端口g0/0/3在生成树选举中成为根端口,处于*FORWARDING*状态端口g0/0/1在生成树选举中成为Alternate端口处于*DISCARDING*状态。此外由于我们配置了BPDU保护g0/0/1状态的Protection字段显示为*BDPU*
端口g0/0/2在生成树选举中成为根端口,处于*FORWARDING*状态。此外由于我们配置了BPDU保护g0/0/10状态的Protection字段显示为*BDPU*
在LSW4上执行display stp brief命令查看端口状态结果如下
#figure(image("lsw4dis.jpg",format: "jpg",fit:"stretch",width: 80%),caption: "查看LSW4")
端口g0/0/1在生成树选举中成为根端口处于*FORWARDING*状态端口g0/0/2在生成树选举中成为 Alternate 端口,处于*DISCARDING*状态;
=== 查看网络连通性
319寝室的PC1上执行ping命令查看与312寝室PC2的网络连通性,结果如下:
#figure(image("319ping312.jpg",format: "jpg",fit:"stretch",width: 70%),caption: "查看网络连通性")
两台PC之间可以正常通信网络连通性正常。至此319与312寝室的学生可以在熄灯后继续通过视频研讨会进行学术讨论。
IP地址为`10.130.81.211`的PC上执行ping命令查看与IP地址为`10.130.81.203`PC的网络连通性结果如下
#figure(image("ping.jpg",format: "jpg",fit:"stretch",width: 70%),caption: "查看网络连通性")
可见两台PC之间可以正常通信网络连通性正常。
=== 实验评测
经过教辅学长亲自测试S2与S3以及S2与S4之间的链路断开后网络依然可以正常通信各交换机`display stp brief`显示结果正常说明STP配置成功网络环路被成功破除。
= 实验总结
#para[
本次实验通过配置生成树协议STP实现了对网络中的环路进行消除保证了网络的稳定性和可靠性。通过实验我掌握了生成树协议的基本概念和工作原理学会了如何在网络设备上配置STP理解了STP的防止环路、优化网络拓扑的功能。实验中我通过实际操作深入理解了STP在现代网络中的应用提升了实践技能为未来的网络工程职业生涯和专业认证考试打下了坚实基础。
]
#show heading: it => box(width: 100%)[
#v(0.50em)
#set text(font: hei)
#set text(font: "Noto Sans CJK SC")
// #counter(heading).display()
// #h(0.5em)
#it.body

View File

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 272 KiB

BIN
2_stp/step0.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 13 KiB

BIN
2_stp/step1.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
2_stp/step2.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
2_stp/step3.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
2_stp/step4.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 91 KiB

BIN
2_stp/step5.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 40 KiB

BIN
2_stp/step6.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
2_stp/step7.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB