This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pypbald is a Python 2.7 network analysis tool that captures and analyzes ARP (Address Resolution Protocol) and NBD (Network Block Device) packets. The application uses a Singleton pattern for configuration management and includes database storage for both detailed and raw packet data.
Run the application:
cd trunk/src
python main.pyBuild executable (Windows):
cd trunk
./build.bat
# Or manually: cd src && python setup.py py2exeGenerate documentation:
cd trunk
./doc.bat
# Or manually: python c:\Python25\Scripts\pydoctor --add-package srcDatabase setup:
mysql -u username -p database_name < trunk/schema/pba.sqlCore Components (Singleton Pattern):
PBA(trunk/src/PBA.py): Main orchestrator class that inherits from PBASingletonPBASingleton(trunk/src/pypbald/PBASingleton.py): Singleton pattern implementation
Key Modules:
backend/: Database operations and storage (local/remote MySQL)sniffing/: Network packet capture using filtersparsing/: Packet parsing and analysislogging/: Application loggingrecords/: Data structures for ARP and NBDS records
Data Flow:
- PBA reads configuration from
trunk/pypbald.config - Initializes backend (databases), logger, parser, and sniffer
- Sniffer captures packets using configurable filters
- Parser processes packets into structured records
- Backend stores both summary and raw data in MySQL tables
Main config file: trunk/pypbald.config
- Global settings: debug mode, packet filters, log filename
- Local database: MySQL connection details, storage options
- Remote database: Optional remote MySQL storage
Important settings:
filter: Network packet filter (e.g., "broadcast and ((udp and src port 138) or arp)")detail/raw: Control what data gets stored in databases
Core tables (see DATA_MODEL.md):
pba_arp: Summarized ARP data with timestamps and countspba_arp_raw: Raw ARP packet datapba_arp_summary: Aggregated ARP statisticspba_nbds: Network Block Device records
Key fields:
- All tables use
hashfields for linking related data - Automatic timestamp tracking with
first_timestamp/last_timestamp - Count fields track packet frequency
Always work from trunk/src/ when running Python commands. The configuration file is read relative to this location (../pypbald.config).