How nprint/nprintml works
1. nPrintML is a Python command-line package that orchestrates a packet-analysis pipeline rather than implementing the low-level network fingerprinting or ML algorithms itself. Its two main external engines are nPrint for feature generation and AutoGluon for model training.
2. The top-level entry points are nprintml / nml, implemented through src/nprintml/cli.py and __main__.py. manage.py is a separate developer/release entry point used for packaging and maintenance tasks, not for end-user analysis.
3. The core flow is: input PCAPs plus labels in → nPrint feature extraction → label aggregation/alignment → formatted feature datasets → AutoML training and evaluation. The repository is structured to keep these stages separable, which is important for diagramming the boundaries between data ingestion, preprocessing, and learning.
4. The net package is the integration boundary to nPrint itself. net/install.py bootstraps or installs the nPrint executable, while net/execute.py and net/step.py wrap invocation and pipeline-step behavior. In architecture terms, this is the “external process runner” layer that turns the repository into a usable workflow on a local machine or inside Docker.
5. The label package is responsible for turning raw labels into a form that matches the generated packet fingerprints. The presence of aggregator/base.py, aggregator/pcap.py, and aggregator/index.py suggests multiple label sources or grouping strategies, with the package acting as the label-normalization and alignment boundary.
6. The learn package is the training/prediction layer. learn/automl.py integrates AutoGluon, and learn/step.py likely provides pipeline-step orchestration around model fitting, validation, and inference. This layer consumes the feature datasets produced upstream and emits trained models and evaluation outputs downstream.
7. pipeline.py appears to be the composition point tying together the network, label, and learning stages. For an architecture diagram, this is the central workflow coordinator that routes inputs through the appropriate steps depending on whether the user is generating features, training, or running a partial pipeline.
8. The util package holds shared infrastructure used across stages: file-format handling, interface abstractions, I/O, and iteration helpers. util/fileformat.py is especially relevant because the test data shows support for multiple feature representations such as CSV gzip, Parquet, and .fhr, which means format conversion is an architectural concern rather than an implementation detail.
9. The repository is designed as a package under src/, with tests under test/ exercising both the pipeline and CLI behavior. The test/data fixtures include paired PCAPs and labels, plus precomputed feature files, which indicates the intended integration points and expected intermediate artifacts.
10. Docker support is a first-class deployment path but remains an alternate execution environment. image/Dockerfile and the nprintml-docker wrapper script package the same CLI into a container, mainly to simplify setup and isolate dependencies such as nPrint and AutoGluon.
11. CI/CD is lightweight but relevant: GitHub Actions workflows cover test, benchmark, and release. That implies the repo treats reproducibility and command-line behavior as core qualities, with tests centered on end-to-end pipeline execution rather than just isolated library functions.
12. For an architecture diagram, the key boundaries are: user CLI, local orchestration code, external nPrint process, label ingestion/aggregation, dataset formatting, AutoGluon model training, and optional Docker packaging. The project is best understood as a workflow coordinator that glues together existing tools into a no-code traffic-analysis pipeline.
Main entry points: pipeline.py Pipeline · fileformat.py Formats · learn/step.py Learn step · net/step.py Net step
Components 20
Source
Primary package code under src/nprintml.
- CLI · End-user command-line interface for nprintml/nml.
src/nprintml/cli.py - Module entry · Python -m entrypoint for the package.
src/nprintml/__main__.py - Pipeline · Composes network, label, and learning stages into a runnable workflow.
src/nprintml/pipeline.py - Execute · Wraps invocation of the external nPrint process.
src/nprintml/net/execute.py - Install nPrint · Bootstraps or installs the nPrint executable.
src/nprintml/net/install.py - Net step · Step orchestration around network feature generation.
src/nprintml/net/step.py - Label step · Aligns and normalizes labels to generated fingerprints.
src/nprintml/label/step.py - Label base · Shared aggregation and alignment abstractions for labels.
src/nprintml/label/aggregator/base.py - PCAP labels · PCAP-oriented label aggregation strategy.
src/nprintml/label/aggregator/pcap.py - Index labels · Index-based label aggregation strategy.
src/nprintml/label/aggregator/index.py - Learn step · Training and inference orchestration around the ML stage.
src/nprintml/learn/step.py - AutoML · Integrates AutoGluon for model fitting and evaluation.
src/nprintml/learn/automl.py - Formats · Handles feature dataset formats such as CSV gzip, Parquet, and FHR.
src/nprintml/util/fileformat.py - I/O · Shared file and filesystem helpers used across stages.
src/nprintml/util/io.py - Interfaces · Common interfaces and abstractions for pipeline components.
src/nprintml/util/interface.py
Ops
Packaging, container, and release entry points.
- Dockerfile · Container image definition for packaged execution.
image/Dockerfile - Docker wrapper · Shell wrapper for running the packaged CLI in a container.
image/nprintml-docker - Manage · Developer/release entry point for packaging and maintenance tasks.
manage.py
Tests
Integration and fixture-driven verification.
- Pipeline tests · End-to-end pipeline behavior checks.
test/test_pipeline.py - Format tests · Verifies supported feature dataset formats.
test/test_fileformat.py
Connections 21
- Module entry → CLI: invokes · Module entry delegates to the CLI.
- CLI → Pipeline: orchestrates · CLI routes user requests into the main workflow.
- Pipeline → Net step: runs · Pipeline starts with network feature generation.
- Pipeline → Label step: runs · Pipeline aligns labels with generated features.
- Pipeline → Learn step: runs · Pipeline trains or evaluates models downstream.
- Net step → Execute: uses · Network step invokes the nPrint runner.
- Net step → Install nPrint: prepares · Network stage can bootstrap the external dependency.
- Execute → Formats: emits · Execution produces feature datasets in supported formats.
- Label step → Label base: builds on · Label step uses common aggregation abstractions.
- Label base → PCAP labels: specialized by · PCAP label strategy implements the base boundary.
- Label base → Index labels: specialized by · Index label strategy implements the base boundary.
- Label step → Formats: aligns · Label processing depends on dataset format handling.
- Learn step → AutoML: delegates · Learning step hands off training to AutoML integration.
- Learn step → Formats: consumes · Learning consumes formatted feature datasets.
- Learn step → Interfaces: uses · Learning components share common interfaces.
- I/O → Formats: supports · I/O helpers underpin file and dataset handling.
- Docker wrapper → CLI: wraps · Container entry exposes the same user CLI.
- Dockerfile → Docker wrapper: packages · Dockerfile builds the runnable container image.
- Manage → Pipeline: maintains · Developer entry point supports packaging and maintenance workflows.
- Pipeline tests → Pipeline: validates · Tests exercise end-to-end orchestration.
- Format tests → Formats: validates · Tests cover supported file representations.