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格式
+--------------------------------+
| DMAC |
+--------------------------------+
| SMAC |
+--------------------------------+
| Length |
+--------------------------------+
| LLC header |
+--------------------------------+-----------------------
| Protocol Identifier | ^
+--------------------------------+ |
| Protocol Version Identifier | |
+--------------------------------+ |
| BPDU Type | |
+--------------------------------+ |
| Flags | |
+--------------------------------+ |
| Root Identifier | |
+--------------------------------+ |
| Root Path Cost | |
+--------------------------------+ |
| Bridge Identifier | |
+--------------------------------+ |
| Port Identifier | |
+--------------------------------+ |
| Message Age | |
+--------------------------------+ BPDU
| Max Age | payload
+--------------------------------+ |
| Hello Time | |
+--------------------------------+ |
| Forward Delay | |
+--------------------------------+---------- |
| Version 1 Length | RSTP/MSTP |
| | Extension |
+--------------------------------+---------- |
| Version 3 Length | ^ |
+--------------------------------+ | |
| MST Config ID Format Selector | | |
+--------------------------------+ | |
| MST Config Name | | |
+--------------------------------+ | |
| MST Config reversion | | |
+--------------------------------+ | |
| MST Config Digest | MSTP |
+--------------------------------+ Extension |
| CIST Internal Root Path Cost | | |
+--------------------------------+ | |
| CIST Bridge Identifier | | |
+--------------------------------+ | |
| CIST Remaining Hops | | |
+--------------------------------+ | |
| MSTI configuration Messages | | |
| (may be absent) | V V
+--------------------------------+-----------------------
| FCS |
+--------------------------------+
二、STP/RSTP/MSTP的BPDU格式说明
字段 |
长度 |
说明 |
---|---|---|
DMAC |
6字节 |
目的MAC地址,该字段标识帧的接收者。 |
SMAC |
6字节 |
源MAC地址,该字段标识帧的发送者。 |
Length |
2字节 |
指后续数据的字节长度,但不包括FCS字段。 |
Protocol Identifier |
2字节 |
协议ID=“0”。 |
Protocol Version Identifier |
1字节 |
协议版本标识符,STP为0x00,RSTP为0x02,MSTP为0x03。 |
BPDU Type |
1字节 |
BPDU类型:
|
Flags |
1字节 |
标记域。对于STP:第一个bit(左边、高位bit)表示“TCA(拓扑改变响应)”,最后一个bit(右边、低位bit)表示“TC(拓扑改变)”,其他字段预留。 对于RSTP和MSTP:
|
Root Identifier |
8字节 |
网桥ID都是8个字节——前两个字节是网桥优先级,后6个字节是网桥MAC地址。对于MSTP,是指CIST的总根交换机ID。 |
Root Path Cost |
4字节 |
根路径开销,本端口累计到根桥的开销。对于MSTP,是指CIST外部路径开销指从本交换机所属的MST域到CIST根交换机的累计路径开销。CIST外部路径开销根据链路带宽计算。 |
Bridge Identifier |
8字节 |
发送者BID,本交换机的Bridge ID。对于MSTP,是指CIST的域根交换机ID,即IST Master的ID。如果总根在这个域内,那么域根交换机ID就是总根交换机ID。 |
Port Identifier |
2字节 |
发送端口PID,发送该BPDU的端口ID。对于MSTP,是指本端口在IST中的指定端口ID。 |
Message Age |
2字节 |
该BPDU的消息年龄,以秒为单位。 |
Max Age |
2字节 |
消息老化年龄,以秒为单位,超时则认为到根交换机的链路故障。 |
Hello Time |
2字节 |
发送两个相邻BPDU间的时间间隔,以秒为单位。 |
Forward Delay |
2字节 |
控制Listening和Learning状态的持续时间,以秒为单位。 |
Version 1 Length |
1字节 |
Version1 BPDU的长度,值固定为0。只在RSTP和MSTP的BPDU中出现,STP的BPDU没有此字段。 |
Version 3 Length |
2字节 |
Version3 BPDU的长度,只在MSTP的BPDU中出现。 |
MST Config ID Format Selector |
1字节 |
固定为0。 |
MST Config Name |
32字节 |
“域名”,字符串格式。 |
MST Config reversion |
2字节 |
非负整数。 |
MST Config Digest |
16字节 |
利用HMAC-MD5算法将域中VLAN和实例的映射关系加密成16字节的摘要。 |
CIST Internal Root Path Cost |
4字节 |
CIST内部路径开销,指从本端口到IST Master交换机的累计路径开销,只在MSTP的BPDU中出现。CIST内部路径开销根据链路带宽计算。 |
CIST Bridge Identifier |
8字节 |
CIST的指定交换机ID,只在MSTP的BPDU中出现。 |
CIST Remaining Hops |
1字节 |
BPDU报文在CIST中的剩余跳数,只在MSTP的BPDU中出现。 |
MSTI Configuration Messages (may be absent) |
n×16字节 |
MSTI配置信息,只在MSTP的BPDU中出现。每个MSTI的配置信息占16 bytes,如果有n个MSTI就占用n×16bytes。单个MSTI Configuration Messages的字段说明如下:
|
FCS |
4字节 |
帧校验序列FCS(Frame Check Sequence)是为接收网卡提供判断是否传输错误的一种方法,如果发现错误,丢弃此帧。 FCS只是通用叫法,具体的FCS还可以细分多种校验方法。在以太帧中,FCS通常采用循环冗余码校验CRC(Cyclical Redundancy Check)。 |
三、STP帧格式示例
Frame 1: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
Arrival Time: Feb 18, 2013 21:52:38.468966000
Epoch Time: 1361195558.468966000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 60 bytes (480 bits)
Capture Length: 60 bytes (480 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:llc:stp]
[Coloring Rule Name: Broadcast]
[Coloring Rule String: eth[0] & 1]
IEEE 802.3 Ethernet
Destination: Spanning-tree-(for-bridges)_00 (01:80:c2:00:00:00)
Address: Spanning-tree-(for-bridges)_00 (01:80:c2:00:00:00)
.... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
Source: 11:4d:c1 (00:03:6c:11:4d:c1)
Address: 11:4d:c1 (00:03:6c:11:4d:c1)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
Length: 38
Trailer: 0000000000000000
Logical-Link Control
DSAP: Spanning Tree BPDU (0x42)
IG Bit: Individual
SSAP: Spanning Tree BPDU (0x42)
CR Bit: Command
Control field: U, func=UI (0x03)
000. 00.. = Command: Unnumbered Information (0x00)
.... ..11 = Frame type: Unnumbered frame (0x03)
Spanning Tree Protocol
Protocol Identifier: Spanning Tree Protocol (0x0000)
Protocol Version Identifier: Spanning Tree (0)
BPDU Type: Configuration (0x00)
BPDU flags: 0x00
0... .... = Topology Change Acknowledgment: No
.... ...0 = Topology Change: No
Root Identifier: 32768 / 0 / 00:13:5f:b9:20:d1
Root Bridge Priority: 32768
Root Bridge System ID Extension: 0
Root Bridge System ID: 00:13:5f:b9:20:d1
Root Path Cost: 4
Bridge Identifier: 32768 / 0 / 00:d0:03:89:c4:d1
Bridge Priority: 32768
Bridge System ID Extension: 0
Bridge System ID: 00:d0:03:89:c4:d1
Port identifier: 0x80c2
Message Age: 1
Max Age: 20
Hello Time: 2
Forward Delay: 15
四、MSTP帧格式示例
Frame 1: 120 bytes on wire (960 bits), 120 bytes captured (960 bits)
Arrival Time: May 1, 2015 02:09:20.543972000
Epoch Time: 1430417360.543972000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 120 bytes (960 bits)
Capture Length: 120 bytes (960 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:llc:stp]
[Coloring Rule Name: Broadcast]
[Coloring Rule String: eth[0] & 1]
IEEE 802.3 Ethernet
Destination: Spanning-tree-(for-bridges)_00 (01:80:c2:00:00:00)
Address: Spanning-tree-(for-bridges)_00 (01:80:c2:00:00:00)
.... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
Source: 3comEuro_44:33:8f (00:24:73:44:33:8f)
Address: 3comEuro_44:33:8f (00:24:73:44:33:8f)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
Length: 106
Logical-Link Control
DSAP: Spanning Tree BPDU (0x42)
IG Bit: Individual
SSAP: Spanning Tree BPDU (0x42)
CR Bit: Command
Control field: U, func=UI (0x03)
000. 00.. = Command: Unnumbered Information (0x00)
.... ..11 = Frame type: Unnumbered frame (0x03)
Spanning Tree Protocol
Protocol Identifier: Spanning Tree Protocol (0x0000)
Protocol Version Identifier: Multiple Spanning Tree (3)
BPDU Type: Rapid/Multiple Spanning Tree (0x02)
BPDU flags: 0x2c (Forwarding, Port Role: Designated)
0... .... = Topology Change Acknowledgment: No
.1.. .... = Agreement: Yes
..1. .... = Forwarding: Yes
...1 .... = Learning: Yes
.... 11.. = Port Role: Designated (3)
.... ..0. = Proposal: No
.... ...0 = Topology Change: No
Root Identifier: 24576 / 1 / 00:0b:be:10:4c:00
Root Bridge Priority: 24576
Root Bridge System ID Extension: 1
Root Bridge System ID: 00:0b:be:10:4c:00
Root Path Cost: 20019
Bridge Identifier: 32768 / 0 / 00:24:73:44:33:80
Bridge Priority: 32768
Bridge System ID Extension: 0
Bridge System ID: 00:24:73:44:33:80
Port identifier: 0x800d
Message Age: 2
Max Age: 20
Hello Time: 2
Forward Delay: 15
Version 1 Length: 0
Version 3 Length: 0
MST Extension
MST Config ID format selector: 0
MST Config name: 002473443380
MST Config revision: 0
MST Config digest: ac36177f50283cd4b83821d8ab26de62
CIST Bridge Identifier: 32768 / 0 / 00:24:73:44:33:80
CIST Bridge Priority: 32768
CIST Bridge Identifier System ID Extension: 0
CIST Bridge Identifier System ID: 00:24:73:44:33:80
CIST Internal Root Path Cost: 0
CIST Remaining hops: 20
五、STP/RSTP/MSTP网络协议参考标准
标准 |
描述 |
---|---|
IEEE Std 802.1D |
Information technology—Telecommunicationsand information exchange between systems—Local and metropolitan area networks—Common specifications—Part 3:Media Access Control (MAC) Bridges.] |
IEEE Std 802.1W |
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]. |
IEEE Std 802.1S |
Virtual Bridged Local Area Networks—Amendment 3: Multiple Spanning Trees |
发表评论