BACstab
A modular Python toolkit for parsing BACnet packets and building small, custom BACnet tools.
BACstab handles the protocol parsing so your scripts can focus on filtering, inspecting, and analyzing traffic. Built to work with Scapy, it returns parsed data as nested Python dictionaries.
Installation
Requires Python 3.10 or newer. Scapy is installed automatically as a dependency.
Clone the repository and install:
git clone https://github.com/smallseacreature/bacstab.git
cd bacstab
python -m pip install .
For development, use an editable installation:
python -m pip install -e .
Changes to the source files will be available without reinstalling. Keep the repository in a stable location when using editable mode.
Quick Start
Parse BACnet bytes
Pass a complete BVLC message to process_bvlc():
from bacstab import process_bvlc, print_dictionary
# BVLC-Result: successful completion
payload = bytes.fromhex("81 00 00 06 00 00")
result = process_bvlc(payload)
if result is not None:
print_dictionary(result)
Read a packet capture
from scapy.all import PcapReader, UDP
from bacstab import process_udp_payload
with PcapReader("capture.pcap") as packets:
for packet in packets:
if UDP not in packet:
continue
result = process_udp_payload(packet[UDP])
if result is None:
continue
print(result["function_name"])
PcapReader processes the capture one packet at a time without loading the entire file into memory.
Inspect the full parsed record
from bacstab import print_dictionary
print_dictionary(result)
For a string you can save or display elsewhere:
from bacstab import format_dictionary
text = format_dictionary(result)
print(text)
Run the included example
python examples/read_pcap.py capture.pcap
Modules
| Module | Purpose |
|---|---|
bacstab.bvlc |
Parse BVLC headers and supported function bodies |
bacstab.npdu |
Parse NPDU headers and routing information |
bacstab.apdu |
Parse APDU headers and service metadata |
bacstab.constants |
Protocol constants and lookup tables |
bacstab.layers |
Extract Scapy layer fields and parse UDP payloads |
bacstab.capture |
Read capture metadata and calculate file hashes |
bacstab.utils |
Format and print nested parser results |
Individual protocol parsers are also available directly:
from bacstab import process_bvlc, process_npdu, process_apdu
Each expects bytes beginning at its corresponding protocol header.
Working With Results
The parsers return dictionaries containing decoded fields, nested protocol records, and retained raw bytes.
For messages carrying an application PDU, you can access the nested layers:
npdu = result.get("npdu")
if npdu is not None:
apdu = npdu.get("apdu")
if apdu is not None:
print(apdu.get("service_name"))
Not every BACnet message contains an NPDU or APDU.
Malformed or unsupported input may return None or a partial record. Check fields such as:
length_validbody_parse_validbody_parse_errorunsupported_reasonnpdu_parse_validapdu_parse_valid
These fields belong to their respective layer records. A returned dictionary—or a valid outer header—does not guarantee that all nested content was decoded successfully.
Current Scope
BACstab currently focuses on decoding BACnet/IP traffic.
It includes:
- IPv4 BVLC header and supported function-body parsing
- Broadcast Distribution Table and Foreign Device Table entry parsing
- NPDU routing-field extraction
- APDU header and service identification
- Scapy UDP payload integration
- Capture metadata and readable result formatting
Current limitations:
- BACnet/IPv6 function-body decoding is not implemented.
- Complete security-wrapper decoding is not implemented.
- Network-message bodies and most application-service data remain raw.
- Segmented APDUs are not reassembled.
- Packet construction, request sending, and response tracking are not implemented.
Validation
The initial package was tested with Python 3.12 and Scapy 2.8.0.
Checks covered basic BVLC parsing, truncated input, a synthetic Who-Is message, and non-BACnet UDP data. A supplied capture containing 24,718 packets produced 13,969 BACnet records without parser exceptions.
These checks do not establish complete protocol conformance. The test environment required disabling Scapy interface discovery for offline testing; live capture was not tested.
Metadata
Release files for bacstab 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bacstab-0.1.0.tar.gz | 18.1 kB | With provenance | Details for bacstab-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bacstab-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bacstab-0.1.0-py3-none-any.whl |
Total release size: 37.2 kB
Release files / bacstab-0.1.0.tar.gz
| Download URL | bacstab-0.1.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f238ebaff4379f786c66713d128d52fe0602cd7776d7ae2f5408fef6ed4edde
|
|
BLAKE2b-256 checksum How to use checksums |
9724902453dda412091d3f382458f3cee5b840c35c13bed884e4ad62aca49f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / bacstab-0.1.0-py3-none-any.whl
| Download URL | bacstab-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64e40d4300e61b385a63f3d9a43720e173ec838a9f656b588f976348b22c496a
|
|
BLAKE2b-256 checksum How to use checksums |
8c995c3d7d5f7214e63232db5dd18feea4f53154bd703bc88aa02aeb42b5f32b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for bacstab 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for bacstab-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.