MCPcopy Create free account
hub / github.com/caesar0301/pkt2flow

github.com/caesar0301/pkt2flow @v1.4.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.4.1 ↗ · + Follow
111 symbols 213 edges 14 files 11 documented · 10% updated 11mo agov1.4.1 · 2025-08-12★ 1778 open issues

Browse by type

Functions 56 Types & classes 55
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pkt2flow

Build Status License: MIT Platform

A simple, cross-platform utility to classify packets into flows using only the essential 4-tuple (src_ip, dst_ip, src_port, dst_port). Each flow is saved as a separate pcap file, named with its 4-tuple and the timestamp of its first packet. No payload reassembly or extra processing is performed—just pure flow separation for your analysis needs.

Why pkt2flow?

Existing tools like tcpflow, tcpslice, and tcpsplit either reduce trace volume or reassemble payloads, which may not fit all research or analysis needs. pkt2flow fills the gap by simply splitting packets into flows, making it ideal for deep packet inspection, flow classification, and traffic research.

Installation & Build

Prerequisites

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install -y libpcap-dev libgoogle-glog-dev libgtest-dev cmake build-essential

macOS (Intel/Apple Silicon):

brew install libpcap glog googletest cmake

Note for Apple Silicon (M1/M2): If you encounter issues with libpcap not being found, set: bash export PKG_CONFIG_PATH="/opt/homebrew/opt/libpcap/lib/pkgconfig"

Build Steps

  1. Clone the repository: bash git clone https://github.com/caesar0301/pkt2flow.git cd pkt2flow
  2. Configure and build: bash mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make
  3. (Optional) Run tests: bash ctest --verbose
  4. (Optional) Install: bash sudo make install

Build Options

  • BUILD_TESTS: Enable/disable unit tests (default: ON)
  • CMAKE_BUILD_TYPE: Set build type (Debug, Release, etc.)

Example:

cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON

Usage

./pkt2flow [-huvx] [-o outdir] pcapfile

Options:
  -h    Print this help and exit
  -u    Also dump (U)DP flows
  -v    Also dump in(v)alid TCP flows without the SYN option
  -x    Also dump non-UDP/non-TCP IP flows
  -o    (O)utput directory

Example

./pkt2flow -u -o output_flows/ input.pcap

This will split all TCP and UDP flows from input.pcap into separate files in the output_flows/ directory.

Troubleshooting

  • libpcap not found on macOS (Apple Silicon): Set the PKG_CONFIG_PATH before running cmake: bash export PKG_CONFIG_PATH="/opt/homebrew/opt/libpcap/lib/pkgconfig"

  • Linker warnings about /usr/local/opt/llvm/lib: These are harmless if you are not using a custom LLVM install. You can ignore them or remove the path from your environment.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with appropriate tests
  4. Ensure all tests pass and code follows the style guide
  5. Submit a pull request

Contributors

Contributors

Core symbols most depended-on inside this repo

Shape

Class 52
Function 34
Method 22
Enum 3

Languages

C++59%
C41%

Modules by API surface

src/pkt2flow.c26 symbols
tests/test_pkt2flow_base.cpp13 symbols
include/pkt2flow.h13 symbols
tests/test_pkt2flow_integration.cpp11 symbols
src/flow_db.c11 symbols
tests/test_flow_db.cpp8 symbols
tests/test_utilities.cpp5 symbols
tests/test_pkt2flow_udplite_integration.cpp5 symbols
tests/test_pkt2flow_udp_integration.cpp5 symbols
tests/test_pkt2flow_tcp_integration.cpp5 symbols
src/main.c3 symbols
examples/example_pkt2flow.c3 symbols

For agents

$ claude mcp add pkt2flow \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page