命令执行结果

假设我们执行display stp命令假设得到如下数据:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
[sw1]display stp
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge :32768.4c1f-ccde-02e8
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-cc2b-47ba / 20000
CIST RegRoot/IRPC :32768.4c1f-ccde-02e8 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :12
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:2m:12s
Number of TC :7
Last TC occurred :GigabitEthernet0/0/2
----[Port1(GigabitEthernet0/0/1)][DISCARDING]----
Port Protocol :Enabled
Port Role :Alternate Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc38-0f51 / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :2
TC or TCN received :7
BPDU Sent :3
TCN: 0, Config: 0, RST: 0, MST: 3
BPDU Received :438
TCN: 0, Config: 0, RST: 0, MST: 438
----[Port2(GigabitEthernet0/0/2)][FORWARDING]----
Port Protocol :Enabled
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc2b-47ba / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :2
TC or TCN received :5
BPDU Sent :4
TCN: 0, Config: 0, RST: 0, MST: 4
BPDU Received :440
TCN: 0, Config: 0, RST: 0, MST: 440 [sw3]display stp
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge :32768.4c1f-cc2b-47ba
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-cc2b-47ba / 0
CIST RegRoot/IRPC :32768.4c1f-cc2b-47ba / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
TC or TCN received :4
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:4m:52s
Number of TC :7
Last TC occurred :GigabitEthernet0/0/1
----[Port1(GigabitEthernet0/0/1)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc2b-47ba / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :1
TC or TCN received :0
BPDU Sent :132
TCN: 0, Config: 0, RST: 0, MST: 132
BPDU Received :1
TCN: 0, Config: 0, RST: 0, MST: 1
----[Port2(GigabitEthernet0/0/2)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc2b-47ba / 128.2
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :2
TC or TCN received :0
BPDU Sent :226
TCN: 0, Config: 0, RST: 0, MST: 226
BPDU Received :1
TCN: 0, Config: 0, RST: 0, MST: 1
<sw2>system-view
Enter system view, return user view with Ctrl+Z.
[sw2]display stp
-------[CIST Global Info][Mode MSTP]-------
CIST Bridge :32768.4c1f-cc38-0f51
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-cc2b-47ba / 20000
CIST RegRoot/IRPC :32768.4c1f-cc38-0f51 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
TC or TCN received :9
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:0m:3s
Number of TC :8
Last TC occurred :GigabitEthernet0/0/2
----[Port1(GigabitEthernet0/0/1)][FORWARDING]----
Port Protocol :Enabled
Port Role :Designated Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc38-0f51 / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :9
TC or TCN received :2
BPDU Sent :545
TCN: 0, Config: 0, RST: 0, MST: 545
BPDU Received :3
TCN: 0, Config: 0, RST: 0, MST: 3
----[Port2(GigabitEthernet0/0/2)][FORWARDING]----
Port Protocol :Enabled
Port Role :Root Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=20000
Designated Bridge/Port :32768.4c1f-cc2b-47ba / 128.2
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=true
Transit Limit :147 packets/hello-time
Protection Type :None
Port STP Mode :MSTP
Port Protocol Type :Config=auto / Active=dot1s
BPDU Encapsulation :Config=stp / Active=stp
PortTimes :Hello 2s MaxAge 20s FwDly 15s RemHop 20
TC or TCN send :2
TC or TCN received :7
BPDU Sent :6
TCN: 0, Config: 0, RST: 0, MST: 6
BPDU Received :549
TCN: 0, Config: 0, RST: 0, MST: 549
```
我们可以按照如下流程解读得到的数据:
这是一份非常完整的STP(生成树协议)信息输出\



## 📌 一、全局信息(Global Info)—— 网络的大局观

这部分描述的是"整个生成树网络"的整体情况。

——-[CIST Global Info][Mode MSTP]——-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

**解释**:CIST 是"公共与内部生成树"的缩写,是 MSTP 中所有实例的"总根"所在的树。`[Mode MSTP]` 表示当前运行的是多生成树协议模式。

| 参数 | 数值(以SW1为例) | 直白翻译 | 作用 |
| :--- | :--- | :--- | :--- |
| **CIST Bridge** | `32768.4c1f-ccde-02e8` | **我(这台交换机)的身份ID**。由"优先级(32768)+MAC地址"组成。 | 在STP选举中,每个交换机都用这个ID标识自己。数值越小越优先。 |
| **Config Times** | `Hello 2s MaxAge 20s FwDly 15s MaxHop 20` | **配置的计时器参数**。 | 这是默认写在配置里的时间参数。Hello=2秒发一次心跳包;MaxAge=20秒收不到心跳就认为链路断了;FwDly=15秒状态切换延迟;MaxHop=20跳最大网络直径。 |
| **Active Times** | `Hello 2s MaxAge 20s FwDly 15s MaxHop 20` | **当前正在生效的计时器参数**。 | 正常情况下与Config一致。如果手动改了配置,这里显示实际生效的值。 |
| **CIST Root/ERPC** | `32768.4c1f-cc2b-47ba / 20000` | **根桥是谁,我到它的开销是多少。** | **这是最关键的信息之一**。根桥ID是`32768.4c1f-cc2b-47ba`,SW1到根桥的累计路径开销是20000。 |
| **CIST RegRoot/IRPC** | `32768.4c1f-ccde-02e8 / 0` | **我所在区域的根桥是谁,我到区域根的开销。** | 在MSTP中,每个区域有自己的根。这里显示区域根就是SW1自己(因为我的ID就是它),到自己开销为0。 |
| **CIST RootPortId** | `128.2` | **我去往根桥的"出口"是哪个端口。** | `128.2` 表示:端口优先级128 + 端口号2(即GigabitEthernet0/0/2)。意思就是:**SW1通过2号口去往根桥。** |
| **BPDU-Protection** | `Disabled` | **BPDU保护功能已关闭。** | 如果开启,当边缘端口收到BPDU时会自动关闭该端口,防止非法交换机接入。 |
| **TC or TCN received** | `12` | **这台交换机一共收到了12次拓扑变化通知。** | TC = Topology Change(拓扑变化)。每发生一次网络变动(比如线断了),这个数字就加1。如果数字疯狂增长,说明网络不稳定。 |
| **TC count per hello** | `0` | **每个Hello周期内收到的TC数量。** | 当前为0,表示最近网络很稳定,没有频繁变动。 |
| **STP Converge Mode** | `Normal` | **收敛模式为普通模式。** | 华为设备还有"Fast"模式,可以加速收敛。Normal是默认的。 |
| **Time since last TC** | `0 days 0h:2m:12s` | **距离上次拓扑变化过去了2分12秒。** | 说明网络在2分钟前刚发生过变化(可能你刚插拔了网线)。 |
| **Number of TC** | `7` | **已经累计发生了7次拓扑变化。** | 这是自从交换机开机以来的总次数。 |
| **Last TC occurred** | `GigabitEthernet0/0/2` | **最后一次拓扑变化发生在2号口。** | 说明最后一次网络变动是2号口引起的(可能拔插了2号口的线)。 |

---

## 📌 二、端口信息(Port Info)—— 每个接口的"体检报告"

这部分针对每个物理端口,详细描述它在STP中的角色和状态。

### 🔹 Port1(GigabitEthernet0/0/1)—— 被阻塞的备用端口

—-[Port1(GigabitEthernet0/0/1)][DISCARDING]—-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

| 参数 | 数值 | 直白翻译 | 作用 |
| :--- | :--- | :--- | :--- |
| **Port Protocol** | `Enabled` | 这个端口启用了STP协议。 | 如果Disabled,这个口不参与STP计算,可能造成环路。 |
| **Port Role** | `Alternate Port` | **端口角色:替代端口(备用)** | 这是被阻塞的端口,平时不转发数据,只监听BPDU。如果根端口(ROOT)挂了,它会上位。 |
| **Port Priority** | `128` | 端口优先级为128。 | 默认值。在选举时,数值越小越优先。 |
| **Port Cost(Dot1T)** | `Config=auto / Active=20000` | 配置为自动计算,实际生效开销为20000。 | 端口开销表示"通过这个口出去要花多大代价"。越大说明路径越差。Active=20000是因为这是千兆口(默认开销值)。 |
| **Designated Bridge/Port** | `32768.4c1f-cc38-0f51 / 128.1` | **这条链路对面的交换机ID和对面的端口号。** | 对面是SW2(MAC `...38-0f51`),它用1号口连接我。这说明了"谁在对岸"。 |
| **Port Edged** | `Config=default / Active=disabled` | 配置默认,实际未启用边缘端口。 | 边缘端口是专门接PC的,能快速收敛。这里Disabled说明接的是交换机。 |
| **Point-to-point** | `Config=auto / Active=true` | 自动检测,实际为点对点链路。 | 说明这个口接的是另一台交换机(而不是集线器),全双工。 |
| **Transit Limit** | `147 packets/hello-time` | 每个Hello周期内最多发送147个BPDU。 | 防止BPDU风暴的限速机制。 |
| **Protection Type** | `None` | 未开启任何端口保护。 | 常见保护类型有:Root(根保护)、Loop(环路保护)、BPDU(BPDU保护)。 |
| **Port STP Mode** | `MSTP` | 这个端口运行的是MSTP协议。 | 与全局一致。 |
| **Port Protocol Type** | `Config=auto / Active=dot1s` | 协议类型自动,实际为dot1s(MSTP标准)。 | dot1s是IEEE关于MSTP的标准编号。 |
| **BPDU Encapsulation** | `Config=stp / Active=stp` | BPDU封装格式为STP标准格式。 | 华为设备默认使用标准格式,保持兼容性。 |
| **PortTimes** | `Hello 2s MaxAge 20s FwDly 15s RemHop 20` | 这个端口的计时器参数。 | RemHop=剩余跳数,每经过一台设备减1。到达0时BPDU被丢弃,控制网络直径。 |
| **TC or TCN send** | `2` | 这个端口发送了2次拓扑变化通知。 | 通知邻居网络发生了变化。 |
| **TC or TCN received** | `7` | 这个端口收到了7次拓扑变化通知。 | 说明邻居那边发生过7次网络变动。 |
| **BPDU Sent** | `3` | 总共发送了3个BPDU报文。 | 其中:TCN=0(拓扑变化通知包),Config=0(STP配置包),RST=0(RSTP包),MST=3(MSTP包)。**说明邻居之间只发了MSTP格式的BPDU。** |
| **BPDU Received** | `438` | 总共收到了438个BPDU报文。 | 全部是MSTP格式(438个)。说明对端设备也是MSTP模式,协商顺利。 |

---

### 🔹 Port2(GigabitEthernet0/0/2)—— 转发数据的主端口

—-[Port2(GigabitEthernet0/0/2)][FORWARDING]—-


与Port1类似,但这里有几个关键差异:

| 参数 | 数值 | 解读 |
| :--- | :--- | :--- |
| **Port Role** | `Root Port` | **这是根端口!** 这个口是SW1去往根桥(SW3)的通道,正在转发数据。 |
| **Designated Bridge/Port** | `32768.4c1f-cc2b-47ba / 128.1` | 对端是根桥SW3(MAC `...2b-47ba`),它用1号口连接我。**这说明SW1的2号口直接连到了根桥SW3的1号口!** |

---

## 🧠 三、综合"案件分析"—— 三台交换机的关系网

根据你提供的三台交换机的输出,我们可以还原出整个拓扑:

| 交换机 | CIST Bridge(自己ID) | 根桥是谁? | 根端口是哪个? | 端口角色总结 |
| :--- | :--- | :--- | :--- | :--- |
| **SW1** | `32768.4c1f-ccde-02e8` | SW3 | Port2(G0/0/2) | Port1=ALTE(阻塞),Port2=ROOT(转发) |
| **SW2** | `32768.4c1f-cc38-0f51` | SW3 | Port2(G0/0/2) | Port1=DESI(转发),Port2=ROOT(转发) |
| **SW3** | `32768.4c1f-cc2b-47ba` | 自己(根桥) | 无 | Port1=DESI(转发),Port2=DESI(转发) |

### 🎯 结论:

1. **根桥是 SW3**(因为它的 `CIST Root/ERPC` 中,根桥ID就是它自己,且 ERPC = 0)。
2. **SW1 的 2 号口连到了 SW3 的 1 号口**(从 `Designated Bridge/Port` 可以确认)。
3. **SW1 的 1 号口连到了 SW2 的 1 号口**(因为对面是 `...38-0f51`,即SW2)。
4. **SW2 的 2 号口连到了 SW3 的 2 号口**(因为对面是 `...2b-47ba`,即SW3)。
5. **环路被切断的位置**:SW1 的 1 号口被阻塞(`DISCARDING` / `Alternate Port`),因为 SW2 在链路竞争中获胜。

---

## 💎 快速记忆口诀(背下来,面试有用)

- **CIST Bridge** = 我的身份证。
- **CIST Root/ERPC** = 老大是谁,我到老大有多远。
- **Root Port** = 我的耳朵(听老大的)。
- **Designated Port** = 我的嘴巴(对下发言)。
- **Alternate Port** = 我的备用耳朵(平时堵着,老大失聪了才用)。
- **TC count** = 网络波动计数器,数字乱跳就说明网络不稳。

这份笔记覆盖了华为交换机 `display stp` 输出的全部核心字段。