Benchmark framework for evaluating MQTT brokers with purpose-based access control and operational request handling.
Designed to test the MQTT-DAP-Mosquitto broker implementation.
This framework tests MQTT brokers with DAP (Data Access and Processing) extensions:
- Purpose-Based Access Control (PBAC): Verifies messages are only delivered to subscribers with permitted purposes
- Operational Requests: Tests GDPR data subject rights (Access, Portability, Erasure, Rectification, Restriction, Objection, Automated Decisions)
- Realistic IoT Workloads: Simulates smart city and industrial scenarios with variable device counts, payload sizes, and publishing rates
- Multiple Purpose Management Methods: Supports baseline (no PM) and four purpose management approaches (PM1-PM4)
- Deterministic event scheduling for reproducible tests
- Variable payloads from small sensor data to large LIDAR scans
- Dynamic purpose changes during runtime
- Client disconnection/reconnection patterns
- Comprehensive metrics: system resources, messaging performance, purpose correctness, operational correctness
- Docker integration with automatic broker restart between tests
- Python 3.8+
- pip
pip install -r benchmark/requirements.txtOr use a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r benchmark/requirements.txtpython3 benchmark/Benchmark.py run <config_file> <broker_address> [options]Arguments:
config_file: Path to YAML test configurationbroker_address: IP address or hostname of MQTT broker-p, --port: Broker port (default: 1883)-o, --logfile: Custom log file path-v, --verbose: Enable verbose logging
Example:
python3 benchmark/Benchmark.py run test-configs/set1_city_static_10p_1subs_pm1.cfg localhost -vProcess a log file to calculate metrics:
python3 benchmark/Benchmark.py analyze <log_file> [-o OUTPUT_FILE]Example:
python3 benchmark/Benchmark.py analyze logs/set1_city_static_10p_1subs_pm1_2024-11-13_15-30-00.logRun all tests across all purpose management methods:
./run_all_broker_tests.shThis builds and runs tests for baseline, PM1, PM2, PM3, and PM4 brokers with automatic broker restart between tests and parallel log analysis.
Run tests for a specific PM method:
./run_pm_tests.sh baseline # PM0: No purpose management
./run_pm_tests.sh pm1 # PM1: Purpose-Encoding Topics
./run_pm_tests.sh pm2 # PM2: Per-Message Declaration
./run_pm_tests.sh pm3 # PM3: Registration by Message
./run_pm_tests.sh pm4 # PM4: Registration by TopicTest configurations are YAML files defining:
- Device instances (publishers/subscribers with device types, purposes, publishing rates)
- Purpose definitions and hierarchy
- Scheduled events (purpose changes, disconnections, operational requests)
- Test parameters (duration, log directory, purpose management method)
See test-configs/ directory for examples.
- CPU and memory usage (min, max, average, variance)
- Latency (min, max, average, variance in milliseconds)
- Throughput (messages per second)
- Header overhead (average MQTT header size in bytes)
Per subscriber:
- False accept rate (messages received without matching purpose)
- False reject rate (expected messages not received due to purpose mismatch)
Per operation type:
- Coverage (percentage of target data successfully retrieved)
- Leakage (unauthorized data included in responses)
- Completion (percentage of requests receiving responses)
- Lost responses (requests with missing/incomplete responses)
- C1_REG: Data registered during test execution
- C2: Historical data from previous connections
- C3: Data from currently connected sessions
All metrics are exported to CSV for comparison across runs.
- ConfigParser (
ConfigParser.py): Parses YAML test configurations - TestExecutor (
TestExecutor.py): Manages test lifecycle, MQTT clients, and event scheduling - LoggingModule (
LoggingModule.py): Asynchronously logs events to disk - MetricsCalculator (
MetricsCalculator.py): Post-processes logs to compute performance metrics
See benchmark/requirements.txt for the complete list. Key dependencies:
- paho-mqtt 2.1.0
- PyYAML 6.0.2
- rich 14.0.0
GNU General Public License v3.0 - See LICENSE