STP/RSTP/MSTP帧
STP(Spanning Tree Protocol,生成树协议)是一种二层(数据链路层)管理协议,它通过有选择性地阻塞网络冗余链路来达到消除网络二层环路的目的,同时具备链路的备份功能。
最初被广泛应用的是IEEE 802.1D STP,随后以它为基础产生了IEEE 802.1w RSTP (Rapid Spanning Tree Protocol,快速生成树协议)和IEEE 802.1s MSTP(Multiple Spanning Tree Protocol,多生成树协议)。
STP/RSTP/MSTP在网桥之间传递特殊的消息(配置消息),也被称作桥协议数据单元BPDU(Bridge Protocol Data Unit),是一种二层报文,目的MAC是多播地址01-80-C2-00-00-00,所有支持STP协议的网桥都会接收并处理收到的BPDU报文。
RSTP的帧格式,在BPDU的格式上,除了保证和STP格式基本一致之外,RSTP作了一些小的变化。一个是在Type字段,配置BPDU类型不再是0而是2,版本号也变成了2。所以运行STP的交换机收到该类BPDU时会丢弃。另一个变化是在Flag字段,把原来保留的中间6位使用起来。这样改变了的配置BPDU叫做RST BPDU。
MSTP兼容生成树协议STP和快速生成树RSTP协议,并且弥补了两者的缺陷。MSTP的BPDU叫MST BPDU,无论是域内的MST BPDU还是域间的,前35个字节和RST BPDU相同。从第36个字节开始是MSTP专有字段。最后的MSTI配置信息字段由若干MSTI配置信息组连缀而成。
STP/RSTP/MSTP的BPDU格式
Length +--------------------------------+
6 | DMAC |
+--------------------------------+
6 | SMAC |
+--------------------------------+
2 | Length |
+--------------------------------+
| LLC header |
+--------------------------------+-----------------------
2 | Protocol Identifier | ^
+--------------------------------+ |
1 | Protocol Version Identifier | |
+--------------------------------+ |
1 | BPDU Type | |
+--------------------------------+ |
1 | Flags | |
+--------------------------------+ |
8 | Root Identifier | |
+--------------------------------+ |
4 | Root Path Cost | |
+--------------------------------+ |
8 | Bridge Identifier | |
+--------------------------------+ |
2 | Port Identifier | |
+--------------------------------+ |
2 | Message Age | |
+--------------------------------+ BPDU
2 | Max Age | payload
+--------------------------------+ |
2 | Hello Time | |
+--------------------------------+ |
2 | Forward Delay | |
+--------------------------------+---------- |
1 | Version 1 Length | RSTP/MSTP |
| | Extension |
+--------------------------------+---------- |
2 | Version 3 Length | ^ |
+--------------------------------+ | |
1 | MSTI Config ID Format Selector | | |
+--------------------------------+ | |
32 | MSTI Config Name | | |
+--------------------------------+ | |
2 | MSTI Config reversion | | |
+--------------------------------+ | |
16 | MSTI Config Digest | MSTP |
+--------------------------------+ Extension |
4 | CIST Internal Root Path Cost | | |
+--------------------------------+ | |
8 | CIST Bridge Identifier | | |
+--------------------------------+ | |
1 | CIST Remaining Hops | | |
+--------------------------------+ | |
N*16 | MSTI configuration Messages | | |
| (may be absent) | V V
+--------------------------------+-----------------------
4 | FCS |
+--------------------------------+
STP/RSTP/MSTP帧字段解释
| 字段 | 长度 | 说明 |
|---|---|---|
| DMAC | 6B | 目的MAC地址,该字段标识帧的接收者。 |
| SMAC | 6B | 源MAC地址,该字段标识帧的发送者。 |
| Length | 2B | 指后续数据的字节长度,但不包括FCS字段。 |
| Protocol Identifier | 2B | 协议ID=“0”。 |
| Protocol Version Identifier | 1B | 协议版本标识符,STP为0x00,RSTP为0x02,MSTP为0x03。 |
| BPDU Type | 1B | BPDU类型。详见 |
| Flags | 1B | 标记域。详见。 |
| Root Identifier | 8B | 网桥ID都是8个字节——前两个字节是网桥优先级,后6个字节是网桥MAC地址。对于MSTP,是指CIST的总根交换机ID。 |
| Root Path Cost | 4B | 根路径开销,本端口累计到根桥的开销。对于MSTP,是指CIST外部路径开销指从本交换机所属的MST域到CIST根交换机的累计路径开销。CIST外部路径开销根据链路带宽计算。 |
| Bridge Identifier | 8B | 发送者BID,本交换机的Bridge ID。对于MSTP,是指CIST的域根交换机ID,即IST Master的ID。如果总根在这个域内,那么域根交换机ID就是总根交换机ID。 |
| Port Identifier | 2B | 发送端口PID,发送该BPDU的端口ID。对于MSTP,是指本端口在IST中的指定端口ID。 |
| Message Age | 2B | 该BPDU的消息年龄,以秒为单位。 |
| Max Age | 2B | 消息老化年龄,以秒为单位,超时则认为到根交换机的链路故障。 |
| Hello Time | 2B | 发送两个相邻BPDU间的时间间隔,以秒为单位。 |
| Forward Delay | 2B | 控制Listening和Learning状态的持续时间,以秒为单位。 |
| Version 1 Length | 1B | Version1 BPDU的长度,值固定为0。只在RSTP和MSTP的BPDU中出现,STP的BPDU没有此字段。 |
| Version 3 Length | 2B | Version3 BPDU的长度,只在MSTP的BPDU中出现。 |
| MSTI Config ID Format Selector | 1B | 固定为0。 |
| MSTI Config Name | 32B | “域名”,字符串格式。 |
| MSTI Config reversion | 2B | 非负整数。 |
| MSTI Config Digest | 16B | 利用HMAC-MD5算法将域中VLAN和实例的映射关系加密成16字节的摘要。 |
| CIST Internal Root Path Cost | 4B | CIST内部路径开销,指从本端口到IST Master交换机的累计路径开销,只在MSTP的BPDU中出现。CIST内部路径开销根据链路带宽计算。 |
| CIST Bridge Identifier | 8B | CIST的指定交换机ID,只在MSTP的BPDU中出现。 |
| CIST Remaining Hops | 1B | BPDU报文在CIST中的剩余跳数,只在MSTP的BPDU中出现。 |
| MSTI Configuration Messages (may be absent) | n×16B | MSTI配置信息,只在MSTP的BPDU中出现。每个MSTI的配置信息占16 bytes,如果有n个MSTI就占用n×16bytes。单个MSTI Configuration Messages的字段说明参见。 |
| FCS | 4B | 帧校验序列FCS(Frame Check Sequence)是为接收网卡提供判断是否传输错误的一种方法,如果发现错误,丢弃此帧。FCS只是通用叫法,具体的FCS还可以细分多种校验方法。在以太帧中,FCS通常采用循环冗余码校验CRC(Cyclical Redundancy Check)。 |
STP BPDU Type Code
| Code | Type | 说明 |
|---|---|---|
| 0x00 | Configuration BPDU | STP Configuration BPDU |
| 0x80 | TCN BPDU | STP的(Topology Change Notification BPDU) |
| 0x02 | RST or MST BPDU | RST BPDU(Rapid Spanning-Tree BPDU)或者MST BPDU(Multiple Spanning-Tree BPDU) |
生成树Flags格式
+-------------------------------+
|TCA| A | F | L | Rule | P | TC|
+-------------------------------+
标记域。对于STP仅使用了第一个bit(左边、高位bit)表示“TCA(拓扑改变响应)”,最后一个bit(右边、低位bit)表示“TC(拓扑改变)”,其他字段预留。对于RSTP和MSTP使用了全部的标志位。
生成树Flags字段解释
| 标志位 | 说明 | |
|---|---|---|
| bit7 | TAC | |
| bit6 | Agreement | |
| bit5 | Forwarding | |
| bit4 | Learning | |
| bit3&bit2 | Port Rule | |
| bit1 | Proposal | |
| bit0 | TC |
Flags Port Rule
| bit3 | bit2 | 说明 |
|---|---|---|
| 0 | 0 | 未知 |
| 0 | 1 | Alternate/Backup |
| 1 | 0 | Root Port |
| 1 | 1 | DP |
MSTI Configuration Messages格式
Length +--------------------------------+
1 | MSTI Flags |
+--------------------------------+
8 | MSTI Regional Root Identifier |
+--------------------------------+
4 | MSTI Internal Root Path Cost |
+--------------------------------+
1 | MSTI Bridge Priority |
+--------------------------------+
1 | MSTI Port Priority |
+--------------------------------+
1 | MSTI Remaining Hops |
+--------------------------------+
MSTI Configuration Messages字段解释
| 字段 | 长度 | 说明 |
|---|---|---|
| MSTI Flags | 1B | MSTI标志。 |
| MSTI Regional Root Identifier | 8B | MSTI域根交换机ID。 |
| MSTI Internal Root Path Cost | 4B | MSTI内部路径开销指从本端口到MSTI域根交换机的累计路径开销。MSTI内部路径开销根据链路带宽计算。 |
| MSTI Bridge Priority | 1B | 本交换机在MSTI中的指定交换机的优先级。 |
| MSTI Port Priority | 1B | 本交换机在MSTI中的指定端口的优先级。 |
| MSTI Remaining Hops | 1B | BPDU报文在MSTI中的剩余跳数。 |
参考标准
| 标准 | 描述 |
|---|---|
| Information technology—Telecommunicationsand information exchange between systems—Local and metropolitan area networks—Common specifications—Part 3:Media Access Control (MAC) Bridges.] | |
| IEEE Standard for Information technology—Telecommunications and information exchange between systems—Local and metropolitan area networks—Common specifications—Part 3: Media Access Control (MAC) Bridges—Amendment 2: Rapid Reconfiguration. [Amendment to IEEE Std 802.1D, 1998 Edition (ISO/IEC 15802-3:1998) and IEEE Std 802.1t-2001]. | |
| Virtual Bridged Local Area Networks—Amendment 3: Multiple Spanning Trees |
No comments to display
No comments to display