Skip to main content

PCAP Transforming Framework

Python framework for extracting network flows from PCAP files and transforming them into the feature formats used by ToN-IoT, BoT-IoT, UNSW-NB15, and CSE-CIC-IDS2018.

Installation

Python 3.12 or later is required.

python -m pip install pcap-transformer

Install optional Python dependencies for the flow extractor(s) you plan to use:

python -m pip install "pcap-transformer[all]"

Available extras are nfstream, cicflowmeter, ownprep, and nexusflowmeter.

The extractor tools also depend on system programs. Zeek, Argus, editcap, capinfos, tcpdump, and TShark are not installed by pip. CICFlowMeter must be installed separately; configure CICFLOWMETER_BIN to a compatible wrapper that accepts a PCAP path and output directory and creates <pcap-filename>_Flow.csv in that directory. Check each tool's own installation instructions and license. These external tools are generally easiest to run on Linux or WSL.

To install from a source checkout instead:

python -m pip install .

Input data

Place captures under a data directory with this layout:

data/
└── pcap/
    └── ToN_IoT/
        ├── capture1.pcap
        └── capture2.pcap

The framework writes generated flow files and datasets under data/flow/. Pass a different data root with data_dir; paths are relative to the current working directory unless absolute paths are provided.

Usage

Transform PCAPs into a target dataset's feature format:

from transforming_framework import Transform

job = Transform(
    src_dataset="ToN_IoT",
    goal_datasets="ToN_IoT",
    data_dir="./data",
)
job.run()

Or extract flows with one or more flow tools without applying a target feature format:

from transforming_framework import Transform

job = Transform(
    src_dataset="ToN_IoT",
    tools=["zeek", "argus"],
    data_dir="./data",
)
job.run()

tools and goal_datasets are mutually exclusive. Supported tools are zeek, argus, cicflowmeter, nexusflowmeter, ownprep, and nfstream. Supported target datasets are ToN_IoT, BoT_IoT, UNSW_NB15, and CSE_CIC_IDS2018. Dataset labels are inferred from the source dataset and capture filenames; use do_label=False to skip labeling or label_binary=False for multiclass labels.

Large captures are split as needed. The default split size is 1,000,000 packets; configure it with chunk_size_packets. Processed files, merged Parquet output, and a preview sample are written below data/flow/.

License

This project is released under the MIT License. The checked-in CICFlowMeter sources and other third-party extractor tools retain their own licenses and must be used in accordance with those licenses. Third-party source files are not included in the pip distributions.

Metadata

Release files for pcap-transformer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcap-transformer 0.1.0
File Size Uploaded Provenance Actions
pcap_transformer-0.1.0.tar.gz 37.0 kB Without provenance Details for pcap_transformer-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pcap-transformer 0.1.0
File Interpreter ABI Platform Actions
pcap_transformer-0.1.0-py3-none-any.whl Python 3 none any Details for pcap_transformer-0.1.0-py3-none-any.whl

Total release size: 83.4 kB

Release files / pcap_transformer-0.1.0.tar.gz

Download URL pcap_transformer-0.1.0.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
049ef2b42476bf15e4ba4ea551306a739967f06ee014fff1227bc073c6770d04
BLAKE2b-256 checksum
How to use checksums
aa280700fc1f0b0698915ecd5fa0dd3c2500b12578611901ebd8d374986277b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / pcap_transformer-0.1.0-py3-none-any.whl

Download URL pcap_transformer-0.1.0-py3-none-any.whl
Size 46.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd466a1bbccb6c652856a88d2c82cc93d0f134f4ece0477b68e251e41dd27fb7
BLAKE2b-256 checksum
How to use checksums
ee33db6c83fda886d14506e308fc5375363594b1fee10d45881765b15bef3846
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for pcap-transformer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page