MSTP - Multiple Spanning Tree Protocol¶
pcapkit.protocols.application.mstp.protocol holds
MSTP, the extractor for the
MST BPDU of the Multiple Spanning Tree Protocol (MSTP) [IEEE Std 802.1Q-2022 clause 14],
an RST BPDU of the Common and Internal Spanning Tree (CIST) extended by the MST
Configuration Identifier, the CIST’s regional fields and an MSTI Configuration
Message for each Multiple Spanning Tree Instance (MSTI):
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
Protocol Identifier, zero, not kept |
|
2 |
16 |
|
Protocol Version Identifier |
3 |
24 |
|
BPDU Type |
4 |
32 |
|
CIST Flags |
5 |
40 |
|
CIST Root Identifier |
13 |
104 |
|
CIST External Root Path Cost |
17 |
136 |
|
CIST Regional Root Identifier |
25 |
200 |
|
CIST Port Identifier |
27 |
216 |
|
Message Age |
29 |
232 |
|
Max Age |
31 |
248 |
|
Hello Time |
33 |
264 |
|
Forward Delay |
35 |
280 |
|
Version 1 Length, zero |
36 |
288 |
|
Version 3 Length |
38 |
304 |
|
MST Configuration Identifier |
89 |
712 |
|
CIST Internal Root Path Cost |
93 |
744 |
|
CIST Bridge Identifier |
101 |
808 |
|
CIST Remaining Hops |
102 |
816 |
|
MSTI Configuration Messages |
IEEE Std 802.1Q-2022 clause 14.4 decodes a BPDU of BPDU Type 0x02 and version 3 or
more as an MST BPDU where it holds 102 octets or more, a Version 1 Length of zero
and a Version 3 Length counting 0 to 64 MSTI Configuration Messages after the 64
octets every MST BPDU has there; anything else of that type is an RST BPDU. Only
version 3 is read and built here: a later version holding all that is the SPT BPDU
of Shortest Path Bridging, version 4, which extends the MST BPDU past its messages
and which pcapkit does not dissect. Octets past the messages of an MST BPDU
are kept undissected.
Added in version 1.9.0.
- class pcapkit.protocols.application.mstp.protocol.MSTP(file, length=None, /, *, version=None, layer=None, protocol=None, context=None)[source]¶
-
This class implements the Multiple Spanning Tree Protocol, its MST BPDU.
Added in version 1.9.0.
Properties
- property version: Literal[3]¶
Version of the member, the Protocol Version Identifier its BPDUs take.
- property length: int¶
Header length of current protocol, 102 octets and 16 for each MSTI Configuration Message.
Methods
- read(length=None, **kwargs)[source]¶
Read an MST BPDU.
Structure of an MST BPDU [IEEE Std 802.1Q-2022 clause 14], from its Version 1 Length on, the octets before it laid out as an RST BPDU’s:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version 1 Len | Version 3 Length |Format Selector| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Configuration Name (32 octets) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Revision Level | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Configuration Digest (16 octets) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | CIST Internal Root Path Cost | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | CIST Bridge Identifier (8 octets) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | CIST Hops | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | MSTI Configuration Messages (16 octets each) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- 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 not 3; or if the BPDU does not hold what an MST BPDU does, which makes it RSTP’s.
- make(*, protocol_version=ProtocolVersion.MSTP, flags=0, cist_root_id=bytes(8), cist_external_root_path_cost=0, cist_regional_root_id=bytes(8), cist_port_id=0, message_age=0, max_age=0, hello_time=0, forward_delay=0, version_3_length=None, config_id=bytes(51), cist_internal_root_path_cost=0, cist_bridge_id=bytes(8), cist_remaining_hops=0, msti=(), payload=b'', **kwargs)[source]¶
Make (construct) packet data.
The Version 1 Length is written as zero, as an MST BPDU’s must be.
- Parameters:
protocol_version (
ProtocolVersion|int) – Protocol Version Identifier, 3: a later version is an SPT BPDU’s, which extends this one.cist_root_id (
BridgeID|bytes) – CIST Root Identifier, or its eight octets.cist_external_root_path_cost (
int) – CIST External Root Path Cost.cist_regional_root_id (
BridgeID|bytes) – CIST Regional Root Identifier, or its eight octets.cist_port_id (
PortID|int) – CIST 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_3_length (
int|None) – Version 3 Length. If not given, it is computed as 64 plus 16 for each ofmsti.config_id (
ConfigID|bytes) – MST Configuration Identifier, or its 51 octets.cist_internal_root_path_cost (
int) – CIST Internal Root Path Cost.cist_bridge_id (
BridgeID|bytes) – CIST Bridge Identifier, or its eight octets.cist_remaining_hops (
int) – CIST Remaining Hops.msti (
Iterable[MSTIMessage|bytes]) – MSTI Configuration Messages, each a data model or its 16 octets.payload (
bytes|ProtocolBase|Schema) – Octets past the BPDU.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
protocol_versionis not 3; ifmstiholds more than 64 messages, orversion_3_lengthcounts no whole number of 0 to 64, either of which makes the BPDU RSTP’s; or if a value does not fit its field.
Data Models
Utilities
- _read_msti(message)[source]¶
Read an MSTI Configuration Message.
- Parameters:
message (
MSTIMessage) – Its header schema.- Return type:
- Returns:
Parsed message.
- _make_msti(message)[source]¶
Make an MSTI Configuration Message.
- Parameters:
message (
MSTIMessage|bytes) – The message, or its 16 octets.- Return type:
- Returns:
Its header schema.
- Raises:
ProtocolError – If
messageis neither, or a value does not fit its field: a Bridge Priority not a multiple of 4096 in0..61440, or a Port Priority not a multiple of 16 in0..240.
Header Schemas¶
- class pcapkit.protocols.application.mstp.schema.MSTP(pid=NO_VALUE, version=NO_VALUE, type=NO_VALUE, flags=NO_VALUE, cist_root_id=NO_VALUE, cist_external_root_path_cost=NO_VALUE, cist_regional_root_id=NO_VALUE, cist_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, version_3_length=NO_VALUE, format_selector=NO_VALUE, config_name=NO_VALUE, revision_level=NO_VALUE, config_digest=NO_VALUE, cist_internal_root_path_cost=NO_VALUE, cist_bridge_id=NO_VALUE, cist_remaining_hops=NO_VALUE, msti=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for an MST BPDU, 102 octets and its MSTI Configuration Messages (IEEE Std 802.1Q-2022 clause 14).
Added in version 1.9.0.
- version: ProtocolVersion = <EnumField version>¶
Protocol Version Identifier.
- cist_external_root_path_cost: int = <UInt32Field cist_external_root_path_cost>¶
CIST External Root Path Cost.
- format_selector: int = <UInt8Field format_selector>¶
Configuration Identifier Format Selector, of the MST Configuration Identifier.
- cist_internal_root_path_cost: int = <UInt32Field cist_internal_root_path_cost>¶
CIST Internal Root Path Cost.
- msti: list[MSTIMessage] = <ListField msti>¶
MSTI Configuration Messages.
- class pcapkit.protocols.application.mstp.schema.MSTIMessage(flags=NO_VALUE, regional_root_id=NO_VALUE, internal_root_path_cost=NO_VALUE, bridge_priority=NO_VALUE, port_priority=NO_VALUE, remaining_hops=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for an MSTI Configuration Message, 16 octets (IEEE Std 802.1Q-2022 clause 14).
Added in version 1.9.0.
Auxiliary Functions¶
- pcapkit.protocols.application.mstp.schema.mstp_msti_length(packet)[source]¶
The octets of the MSTI Configuration Messages the Version 3 Length counts.
- Parameters:
packet (
dict[str,Any]) – The BPDU’s fields unpacked so far.- Return type:
- Returns:
Its Version 3 Length past the 64 octets every MST BPDU has there, in whole messages of 16 octets and at most 64 of them, as IEEE Std 802.1Q-2022 clause 14.4 bounds it; zero for a length below 64.
Data Models¶
- class pcapkit.protocols.application.mstp.data.MSTP(protocol_version, type, flags, cist_root_id, cist_external_root_path_cost, cist_regional_root_id, cist_port_id, message_age, max_age, hello_time, forward_delay, version_1_length, version_3_length, config_id, cist_internal_root_path_cost, cist_bridge_id, cist_remaining_hops, msti)[source]¶
Bases:
ProtocolData model for an MST BPDU (IEEE Std 802.1Q-2022 clause 14).
Added in version 1.9.0.
- protocol_version: ProtocolVersion¶
Protocol Version Identifier, 3.
- msti: tuple[MSTIMessage, ...]¶
MSTI Configuration Messages.
- class pcapkit.protocols.application.mstp.data.ConfigID(format_selector, name, revision_level, digest)[source]¶
Bases:
DataData model for an MST Configuration Identifier, 51 octets.
- class pcapkit.protocols.application.mstp.data.MSTIFlags(tc, proposal, role, learning, forwarding, agreement, master)[source]¶
Bases:
DataData model for the MSTI Flags of an MSTI Configuration Message.
Bit 1 is the least significant bit of the octet; bit 8 is the Master flag where the CIST Flags carry the Topology Change Acknowledgment flag.