RSTP - Rapid Spanning Tree Protocol¶
pcapkit.protocols.application.rstp.protocol holds
RSTP, the extractor for the
RST BPDU of the Rapid Spanning Tree Protocol (RSTP) [IEEE Std 802.1Q-2022 clause 14],
laid out as the Configuration BPDU with a Version 1 Length after it:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
Protocol Identifier, zero, not kept |
|
2 |
16 |
|
Protocol Version Identifier |
3 |
24 |
|
BPDU Type |
4 |
32 |
|
Flags |
5 |
40 |
|
Root Identifier |
13 |
104 |
|
Root Path Cost |
17 |
136 |
|
Bridge Identifier |
25 |
200 |
|
Port Identifier |
27 |
216 |
|
Message Age |
29 |
232 |
|
Max Age |
31 |
248 |
|
Hello Time |
33 |
264 |
|
Forward Delay |
35 |
280 |
|
Version 1 Length, zero |
IEEE Std 802.1Q-2022 clause 14.4 decodes a BPDU of BPDU Type 0x02 and version 2 as
an RST BPDU, and one of version 3 or more too, where it does not hold what an MST
BPDU does; such a BPDU of 35 octets ends before its Version 1 Length. Its
flags carry the Port Role and the Proposal, Learning, Forwarding and Agreement
flags beside the Topology Change ones.
Added in version 1.9.0.
- class pcapkit.protocols.application.rstp.protocol.RSTP(file, length=None, /, *, version=None, layer=None, protocol=None, context=None)[source]¶
-
This class implements the Rapid Spanning Tree Protocol, its RST BPDU.
Added in version 1.9.0.
Properties
- property version: Literal[2]¶
Version of the member, the Protocol Version Identifier its BPDUs take.
- property length: Literal[35, 36]¶
Header length of current protocol, 36 octets or 35 without a Version 1 Length.
Methods
- read(length=None, **kwargs)[source]¶
Read an RST BPDU.
Structure of an RST BPDU [IEEE Std 802.1Q-2022 clause 14]:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Protocol Identifier | Version | BPDU Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Flags | | +-+-+-+-+-+-+-+-+ Root Identifier (8 octets) + | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Root Path Cost | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Bridge Identifier (8 octets) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | Port Identifier | Message Age | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Message Age | Max Age | Hello Time | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Hello Time | Forward Delay | Version 1 Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the Protocol Identifier is not zero, the BPDU Type is not
0x02, or the version is below 2; or if the BPDU holds what an MST BPDU does, as an MST or an SPT BPDU does.
- make(*, protocol_version=ProtocolVersion.RSTP, flags=0, root_id=bytes(8), root_path_cost=0, bridge_id=bytes(8), port_id=0, message_age=0, max_age=0, hello_time=0, forward_delay=0, version_1_length=0, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
protocol_version (
ProtocolVersion|int) – Protocol Version Identifier, 2 or more.root_id (
BridgeID|bytes) – Root Identifier, or its eight octets.root_path_cost (
int) – Root Path Cost.bridge_id (
BridgeID|bytes) – Bridge Identifier, or its eight octets.port_id (
PortID|int) – Port Identifier, or its two octets as an integer.message_age (
float) – Message Age, in seconds.max_age (
float) – Max Age, in seconds.hello_time (
float) – Hello Time, in seconds.forward_delay (
float) – Forward Delay, in seconds.version_1_length (
int|None) – Version 1 Length;Noneto end the BPDU before it, at 35 octets, which only a version of 3 or more may.payload (
bytes|ProtocolBase|Schema) – Octets past the BPDU.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
protocol_versionis below 2, or is 2 without aversion_1_length; if the BPDU andpayloadwould hold what an MST BPDU does; or if a value does not fit its field.
Data Models
Utilities
Header Schemas¶
- class pcapkit.protocols.application.rstp.schema.RSTP(pid=NO_VALUE, version=NO_VALUE, type=NO_VALUE, flags=NO_VALUE, root_id=NO_VALUE, root_path_cost=NO_VALUE, bridge_id=NO_VALUE, port_id=NO_VALUE, message_age=NO_VALUE, max_age=NO_VALUE, hello_time=NO_VALUE, forward_delay=NO_VALUE, version_1_length=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for an RST BPDU, 36 octets (IEEE Std 802.1Q-2022 clause 14).
Added in version 1.9.0.
- version: ProtocolVersion = <EnumField version>¶
Protocol Version Identifier.
Auxiliary Functions¶
- pcapkit.protocols.application.rstp.schema.rstp_version_1_length(packet)[source]¶
Whether the RST BPDU carries its Version 1 Length, the 36th octet.
- Parameters:
packet (
dict[str,Any]) – The BPDU’s fields unpacked so far.- Return type:
- Returns:
Whether its version is 2; else, on packing, whether it is given, and on unpacking, whether octets are left, as IEEE Std 802.1Q-2022 clause 14.4 decodes a BPDU of version 3 or more and 35 octets as an RST BPDU.
Data Models¶
- class pcapkit.protocols.application.rstp.data.RSTP(protocol_version, type, flags, root_id, root_path_cost, bridge_id, port_id, message_age, max_age, hello_time, forward_delay, version_1_length)[source]¶
Bases:
ProtocolData model for an RST BPDU (IEEE Std 802.1Q-2022 clause 14).
Added in version 1.9.0.
- protocol_version: ProtocolVersion¶
Protocol Version Identifier as captured, 2, or 3 or more for a BPDU that IEEE Std 802.1Q-2022 clause 14.4 decodes as an RST BPDU.