BPDU 中数据字段的字节顺序

网络工程 生成树 IEEE-802.1w
2022-02-21 08:37:30

我正在研究帧/数据包解码器,并且看到关于生成树 BPDU 中 MaxAge/Hello/ForwardDelay 字段的字节顺序的不一致数据。

下面是wireshark STP 解码的图片,当两个八位字节为“14 00”时,MaxAge 为 20。这似乎是小端(最低有效字节优先)。

我相信 Wireshark 解码是正确的,因为如果字节顺序颠倒,MaxAge 将是 5120,这是不合理的。

wireshark stp解码

在 IEEE 802.1d 标准 802.1D-2004 第 9.1.1 节“八位字节的传输和表示”中,它说“当连续八位字节用于表示二进制数时,较低的八位字节数具有最高有效值。”

URL https://ieeexplore.ieee.org/document/1309630(但需要一个免费的 IEEE 帐户)。

所选字节 0x002e 和 0x002f 似乎是正确的。前 4 个字节是端口标识符“80 05”和消息年龄“00 00”。在此之前,我们的桥 ID 以“4c 71 0c 19 e3 0d”结尾

其他字段,例如问候时间和转发延迟,具有相同的行为。

问:我是不是误会了什么?还是 802.1d 字段是小端的,尽管标准说了什么?

作为参考,这里是规范第 9.3.1 节中 BPDU 的八位字节,尽管我的八位字节编号不同,因为我包含了 802.3 标头:

a) The Protocol Identifier is encoded in Octets 1 and 2. It takes the value 0000 0000 0000 0000, which identifies the Rapid Spanning Tree Protocol as specified in Clause 17.
NOTE—This value of the Protocol Identifier also identifies the Spanning Tree Algorithm and Protocol specified in previous editions of this standard.
b) The Protocol Version Identifier is encoded in Octet 3. It takes the value 0000 0000.
c) The BPDU Type is encoded in Octet 4. This field takes the value 0000 0000.
This denotes a Configuration BPDU.
d) The Topology Change Acknowledgment flag is encoded in Bit 8 of Octet 5.
e) The Topology Change flag is encoded in Bit 1 of Octet 5.
f) The remaining flags, Bits 2 through 7 of Octet 5, are unused and take the value 0.
g) The Root Identifier is encoded in Octets 6 through 13.
h) The Root Path Cost is encoded in Octets 14 through 17.
i) The Bridge Identifier is encoded in Octets 18 through 25.
j) The Port Identifier is encoded in Octets 26 and 27.
k) The Message Age timer value is encoded in Octets 28 and 29.
l) The Max Age timer value is encoded in Octets 30 and 31.
m) The Hello Time timer value is encoded in Octets 32 and 33.
n) The Forward Delay timer value is encoded in Octets 34 and 35.
1个回答

计时器字段不编码为整数秒,而是编码为定点数 - 第一个八位字节表示完整秒(更重要),秒代表 1/256 秒(不重要)。14 00表示 20.000,14 80将是 20.500。

这在 IEEE 802.1Q 中被很好地隐藏了——RSTP/MSTP 在 802.1D-2004 之后被移动:

14.2.8 定时器值的编码

定时器值应编码为两个八位字节,表示无符号二进制数乘以 1/256 秒的时间单位。这允许表示 0 到但不包括 256 秒范围内的时间。

PS:在 802.1D 中,这是在第 9.2.8 条中定义的。