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

stp.protocol_version

Protocol Version Identifier

3

24

stp.type

BPDU Type

4

32

stp.flags

CIST Flags

5

40

stp.cist_root_id

CIST Root Identifier

13

104

stp.cist_external_root_path_cost

CIST External Root Path Cost

17

136

stp.cist_regional_root_id

CIST Regional Root Identifier

25

200

stp.cist_port_id

CIST Port Identifier

27

216

stp.message_age

Message Age

29

232

stp.max_age

Max Age

31

248

stp.hello_time

Hello Time

33

264

stp.forward_delay

Forward Delay

35

280

stp.version_1_length

Version 1 Length, zero

36

288

stp.version_3_length

Version 3 Length

38

304

stp.config_id

MST Configuration Identifier

89

712

stp.cist_internal_root_path_cost

CIST Internal Root Path Cost

93

744

stp.cist_bridge_id

CIST Bridge Identifier

101

808

stp.cist_remaining_hops

CIST Remaining Hops

102

816

stp.msti

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]

Bases: STP[MSTP, MSTP]

This class implements the Multiple Spanning Tree Protocol, its MST BPDU.

Added in version 1.9.0.

Properties

property name: Literal['Multiple Spanning Tree Protocol']

Name of current protocol.

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

classmethod id()[source]

Index ID of the protocol.

Return type:

tuple[Literal['MSTP']]

Returns:

Index ID of the protocol, narrowed to this member.

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:
  • length (int | None) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

MSTP

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.

  • flags (Flags | int) – CIST Flags, or the octet.

  • 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 of msti.

  • 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:

MSTP

Returns:

Constructed packet data.

Raises:

ProtocolError – If protocol_version is not 3; if msti holds more than 64 messages, or version_3_length counts 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

__length_hint__()[source]

Return an estimated length for the object.

Return type:

Literal[102]

Utilities

classmethod _make_data(data)[source]

Create key-value pairs from data for protocol construction.

Parameters:

data (MSTP) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

_read_msti(message)[source]

Read an MSTI Configuration Message.

Parameters:

message (MSTIMessage) – Its header schema.

Return type:

MSTIMessage

Returns:

Parsed message.

_make_msti(message)[source]

Make an MSTI Configuration Message.

Parameters:

message (MSTIMessage | bytes) – The message, or its 16 octets.

Return type:

MSTIMessage

Returns:

Its header schema.

Raises:

ProtocolError – If message is neither, or a value does not fit its field: a Bridge Priority not a multiple of 4096 in 0..61440, or a Port Priority not a multiple of 16 in 0..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: Schema

Header 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.

pid: int = <UInt16Field pid>

Protocol Identifier, zero.

version: ProtocolVersion = <EnumField version>

Protocol Version Identifier.

type: BPDUType = <EnumField type>

BPDU Type.

flags: int = <UInt8Field flags>

CIST Flags.

cist_root_id: bytes = <BytesField cist_root_id>

CIST Root Identifier.

cist_external_root_path_cost: int = <UInt32Field cist_external_root_path_cost>

CIST External Root Path Cost.

cist_regional_root_id: bytes = <BytesField cist_regional_root_id>

CIST Regional Root Identifier.

cist_port_id: int = <UInt16Field cist_port_id>

CIST Port Identifier.

message_age: int = <UInt16Field message_age>

Message Age, in units of 1/256 of a second.

max_age: int = <UInt16Field max_age>

Max Age, in units of 1/256 of a second.

hello_time: int = <UInt16Field hello_time>

Hello Time, in units of 1/256 of a second.

forward_delay: int = <UInt16Field forward_delay>

Forward Delay, in units of 1/256 of a second.

version_1_length: int = <UInt8Field version_1_length>

Version 1 Length, zero.

version_3_length: int = <UInt16Field version_3_length>

Version 3 Length.

format_selector: int = <UInt8Field format_selector>

Configuration Identifier Format Selector, of the MST Configuration Identifier.

config_name: bytes = <BytesField config_name>

Configuration Name.

revision_level: int = <UInt16Field revision_level>

Revision Level.

config_digest: bytes = <BytesField config_digest>

Configuration Digest.

cist_internal_root_path_cost: int = <UInt32Field cist_internal_root_path_cost>

CIST Internal Root Path Cost.

cist_bridge_id: bytes = <BytesField cist_bridge_id>

CIST Bridge Identifier.

cist_remaining_hops: int = <UInt8Field cist_remaining_hops>

CIST Remaining Hops.

msti: list[MSTIMessage] = <ListField msti>

MSTI Configuration Messages.

payload: bytes = <PayloadField payload>

Octets past the BPDU, which it does not define.

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: Schema

Header schema for an MSTI Configuration Message, 16 octets (IEEE Std 802.1Q-2022 clause 14).

Added in version 1.9.0.

flags: int = <UInt8Field flags>

MSTI Flags.

regional_root_id: bytes = <BytesField regional_root_id>

MSTI Regional Root Identifier.

internal_root_path_cost: int = <UInt32Field internal_root_path_cost>

MSTI Internal Root Path Cost.

bridge_priority: int = <UInt8Field bridge_priority>

MSTI Bridge Priority, its bits 5 to 8.

port_priority: int = <UInt8Field port_priority>

MSTI Port Priority, its bits 5 to 8.

remaining_hops: int = <UInt8Field remaining_hops>

MSTI Remaining Hops.

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:

int

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: Protocol

Data 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.

type: BPDUType

BPDU Type.

flags: Flags

CIST Flags.

cist_root_id: BridgeID

CIST Root Identifier.

cist_external_root_path_cost: int

CIST External Root Path Cost.

cist_regional_root_id: BridgeID

CIST Regional Root Identifier.

cist_port_id: PortID

CIST Port Identifier.

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

Version 1 Length, zero.

version_3_length: int

Version 3 Length.

config_id: ConfigID

MST Configuration Identifier.

cist_internal_root_path_cost: int

CIST Internal Root Path Cost.

cist_bridge_id: BridgeID

CIST Bridge Identifier.

cist_remaining_hops: int

CIST Remaining Hops.

msti: tuple[MSTIMessage, ...]

MSTI Configuration Messages.

class pcapkit.protocols.application.mstp.data.ConfigID(format_selector, name, revision_level, digest)[source]

Bases: Data

Data model for an MST Configuration Identifier, 51 octets.

format_selector: int

Configuration Identifier Format Selector.

name: bytes

Configuration Name, its 32 octets as captured.

revision_level: int

Revision Level.

digest: bytes

Configuration Digest, 16 octets.

class pcapkit.protocols.application.mstp.data.MSTIFlags(tc, proposal, role, learning, forwarding, agreement, master)[source]

Bases: Data

Data 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.

tc: bool

Topology Change flag, bit 1.

proposal: bool

Proposal flag, bit 2.

role: PortRole

Port Role, bits 3 and 4; its 0 is the Master Port.

learning: bool

Learning flag, bit 5.

forwarding: bool

Forwarding flag, bit 6.

agreement: bool

Agreement flag, bit 7.

master: bool

Master flag, bit 8.

class pcapkit.protocols.application.mstp.data.MSTIMessage(flags, regional_root_id, internal_root_path_cost, bridge_priority, bridge_reserved, port_priority, port_reserved, remaining_hops)[source]

Bases: Data

Data model for an MSTI Configuration Message, 16 octets.

flags: MSTIFlags

MSTI Flags.

regional_root_id: BridgeID

MSTI Regional Root Identifier, whose System ID Extension is the MSTID.

internal_root_path_cost: int

MSTI Internal Root Path Cost.

bridge_priority: int

MSTI Bridge Priority, bits 5 to 8 of its octet, a multiple of 4096.

bridge_reserved: int

Bits 1 to 4 of the MSTI Bridge Priority octet, sent as zero.

port_priority: int

MSTI Port Priority, bits 5 to 8 of its octet, a multiple of 16.

port_reserved: int

Bits 1 to 4 of the MSTI Port Priority octet, sent as zero.

remaining_hops: int

MSTI Remaining Hops.