PRAT: Protocol Representation and Analysis Toolkit
Northeastern University
PRAT (Protocol Representation and Analysis Toolkit) is the open-source research artifact accompanying our ACM TOSEM 2021 paper, Guided Feature Identification and Removal for Resource-constrained Firmware. It identifies — and can automatically remove — feature-specific code in C/C++/Rust projects using compile-time differential coverage analysis.
PRAT is a mature, actively maintained, fully open-source project: it ships with a documented Python API and CLI, build adapters for five real-world projects, and a suite of Docker demos that reproduce the paper's evaluation end to end.
How it works
Given a target project and a named feature, PRAT builds the target twice — once with the feature enabled and once with it disabled — and compares what code actually runs:
-
Compile with the feature enabled, instrumented with coverage flags.
-
Generate coverage (enabled) —
gcov/llvm-covproduce.gcovfiles. -
Compile with the feature disabled, with the same instrumentation.
-
Generate coverage (disabled) — a second set of
.gcovfiles. -
Diff the coverage files to find lines unique to the feature-enabled build.
-
Extract feature code — lines never executed when the feature is off.
-
Generate reports — an HTML table, a JSON checkpoint, and a DOT graph of the removable code.
Supported build systems
PRAT drives each target through a small build adapter, so the same workflow applies whether a project uses Make, CMake, Autotools, or Cargo:
| Build system | Feature-flag format | Example |
|---|---|---|
| Make | WITH_FEATURE=yes/no | WITH_TLS=yes |
| CMake | -DCONFIG_FEATURE=1/0 | -DCONFIG_TLS=1 |
| Autotools | --enable/--disable-feature | --disable-x264 |
| Cargo | --features feature | --features tls |
Reproducing the paper
PRAT ships seven self-contained Docker demos covering the paper's evaluation
targets. Each demo clones its target at a pinned tag, builds it with the feature
on and off, runs coverage, diffs, and extracts — writing a manifest.json that
records the exact git commit and tool versions used. PRAT reports two figures:
an interleaved count (feature code inside files shared by both builds) and a
paper-aligned combined value that also counts dedicated feature-only files.
| Demo | Target | Feature | Build | Reproduced |
|---|---|---|---|---|
mosquitto-tls | Mosquitto v2.0.15 | TLS | Make | 1,415 |
mosquitto-bridge | Mosquitto v2.0.15 | Bridge | Make | 545 |
uamqp-websockets | azure-uamqp-c v1.2.0 | WebSockets | CMake | 1,282 |
aom-encoder | libaom v3.7.1 | AV1 encoder | CMake | 8,691 |
ffmpeg-x264 | FFmpeg n5.1.4 | DTS decoder | Autotools | 3,728 |
opendds-security | OpenDDS 3.25 | Security | MPC / ACE-TAO | 4,802 |
quiche-ffdhe | quiche 0.20.1 | qlog | Cargo | 420 |
Every target builds and runs in the reference environment, and the extracted counts fall within the paper's acceptance ranges. The full methodology — along with an honest account of where the static analysis diverges from the paper's KLEE-based numbers — lives in the reproducibility report.
Architecture
The toolkit is organized as a pipeline of focused modules under src/prat/:
-
workflow.py— end-to-end orchestration with resumable checkpoints. -
batch.py— multi-feature batch analysis (the paper's Algorithm 1). -
discovery.py— automatic feature-flag discovery from build configuration. -
compilation.py— multi-build-system compilation. -
coverage.py—gcov/llvm-cov/cargo-llvm-covcoverage generation. -
diff.pyandextraction.py— coverage comparison and feature-line extraction. -
removal.pyandverification.py— automated removal plus post-removal correctness checks. -
feature_graph.pyandreporting.py— interactive D3.js dependency graphs and HTML/DOT reports. -
symbolic.py— experimental KLEE-based symbolic test generation. -
adapters/— per-project build adapters (Mosquitto, FFmpeg, azure-uamqp-c, OpenDDS, libaom, generic CMake, and Cargo/Rust).
Using PRAT
Install from the public repository and fetch a target project:
git clone https://github.com/williamsryan/PRAT
cd PRAT
pip install -e ".[dev]"
./scripts/fetch-targets.sh mosquitto
Run an analysis from the command line:
# Analyze a feature
prat App/mosquitto TLS
# List discoverable features
prat App/mosquitto --list
# Preview operations without modifying anything
prat App/mosquitto TLS --dry-run
…or drive the workflow programmatically:
from prat.workflow import run_complete_workflow
result = run_complete_workflow(
project_path="App/mosquitto",
feature="TLS",
run_tests=False,
)
print(f"Removable lines: {result.extraction_result.total_removable_lines}")
Live demo: Mosquitto TLS
The artifacts below come from a pinned PRAT run against the Mosquitto MQTT broker, isolating its TLS feature. They are served statically — running PRAT means building target projects and executing their workloads, so a personal site should publish pinned outputs rather than execute submitted repositories.
-
Target: Mosquitto v2.0.15
-
Feature: TLS
-
Command:
prat App/mosquitto TLS --output results/mosquitto-tls
The largest concentrations of removable TLS code in that run:
| File | Removable lines |
|---|---|
conf.c | 326 |
net_mosq.c | 291 |
net.c | 257 |
security_default.c | 223 |
client_shared.c | 160 |
options.c | 155 |
handle_connect.c | 102 |
password_mosq.c | 77 |
Citation
If you use PRAT or build on this work, please cite the paper:
@article{williams2021guided,
author = {Williams, Ryan and Ren, Tongwei and De Carli, Lorenzo and Lu, Long and Smith, Gillian},
title = {Guided Feature Identification and Removal for Resource-constrained Firmware},
journal = {ACM Transactions on Software Engineering and Methodology},
volume = {31},
number = {2},
pages = {1--25},
year = {2021},
doi = {10.1145/3487568}
}
