pcap-parser
Python tool to parse pcap files and extract flow-related network traffic information. Extracts hostnames from DNS, TLS SNI, DHCP, and reverse DNS lookups, then aggregates packets into flows with statistics.
Features
- Parse
.pcapand.pcapngfiles using tshark - Hostname enrichment from DNS queries, TLS SNI, DHCP, and reverse DNS
- Device metadata extraction (OUI vendor, HTTP user-agent)
- Flow aggregation with packet counts, byte counts, and inter-arrival times
- Domain extraction from hostnames
- Persistent IP-to-hostname cache across runs
Requirements
- Python 3.9+
- tshark (comes with Wireshark)
Installation
pip install git+https://github.com/nyu-mlab/pcap-parser.git
Or for development:
git clone https://github.com/nyu-mlab/pcap-parser.git
cd pcap-parser
pip install -e ".[dev]"
Usage
Parse pcap files
Parse a single file:
pcap-parse output.csv /path/to/capture.pcap
Parse all pcap files in a directory:
pcap-parse output.csv /path/to/pcap_directory/
Aggregate into flows
After parsing, aggregate packets into flows:
pcap-flow output.csv aggregated_flows.csv
Output
pcap-parse produces a CSV with columns including:
| Column | Description |
|---|---|
frame.time_epoch |
Packet timestamp |
ip.src / ip.dst |
Source and destination IPs |
tcp.srcport / tcp.dstport |
TCP ports |
udp.srcport / udp.dstport |
UDP ports |
_ws.col.Protocol |
Protocol (TCP, UDP, DNS, TLS, etc.) |
frame.len |
Packet length in bytes |
src_hostname / dst_hostname |
Resolved hostnames |
dhcp_hostname |
DHCP-advertised hostname |
eth.src.oui_resolved |
Device vendor from MAC OUI |
http.user_agent |
HTTP user-agent string |
pcap-flow aggregates these into flows with start/end timestamps, byte counts, packet counts, and average inter-arrival times.
Running tests
pytest tests/ -v
License
MIT — see LICENSE for details.
Metadata
Release files for pcap-extract 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pcap_extract-0.1.0.tar.gz | 8.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pcap_extract-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / pcap_extract-0.1.0.tar.gz
| Download URL | pcap_extract-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a7cbd00c0ea21d9dd8ed820a396deee0f2d048c8e6232e29202019845bf58e8
|
|
BLAKE2b-256 checksum How to use checksums |
e90d5f86a80d8245dcc10fda1c86b8fad5b0a9b57d3779fba8b8f928a2a0353e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency logRelease files / pcap_extract-0.1.0-py3-none-any.whl
| Download URL | pcap_extract-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db8bb7119bf9419784cf4a14866a9f9d684c3063e70c0cc01c63d1e7ff8baf39
|
|
BLAKE2b-256 checksum How to use checksums |
727abc8057b48a039936bd50183720c3af56f8b7ff1aad70f84dd8e25d90191d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency logSecurity for pcap-extract 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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pcap_extract-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 28, 2026.
Transparency logA 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.