How ulbios/bacnet works
Project Identification and Purpose
• This is a BACnet protocol implementation written in pure Golang.
• Its purpose is to provide the encoding/decoding (marshalling/unmarshalling) and service implementations (such as ReadProperty, WriteProperty, WhoIs, etc.) needed to work with the BACnet protocol over IP.
• The project also includes a Command-Line Interface (CLI) in the “examples” directory to demonstrate and test its functionality, as well as integration tests using a C-based BACnet server (included as a submodule).
Analyzing the File Structure and Key Components
• Main directories:
• common/: Contains utility functions and error handling (e.g., error.go, utils.go) used across the project.
• plumbing/: Focuses on lower-level message processing. It includes modules for BVLC, NPDU, APDU, and related constants and interfaces needed for protocol marshalling/unmarshalling.
• objects/: Defines the BACnet objects and related data types (properties, tags, priorities, object identifiers, etc.) that represent the data elements defined by BACnet.
• services/: Implements the higher-level BACnet services (e.g., ReadProperty, WriteProperty, WhoIs, etc.) that utilize the functionality from plumbing and objects.
• examples/: Provides sample applications (client/server examples with CLI) that demonstrate how to invoke services and handle BACnet messages.
• bacnet-stack (submodule): Contains an external C-based BACnet server implementation for testing; represents the server-side reference for interoperability.
• traffcaps/: Holds network packet capture files (PCAPNG) to show example BACnet traffic and support validation/testing against WireShark’s dissector.
• Additional key files:
• encoding.go and parsing.go: Serve as the entry points for constructing new messages and decoding incoming BACnet messages.