# bogdann29/dpdkcap architecture

> Architecture diagram of the GitHub repository bogdann29/dpdkcap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bogdann29/dpdkcap
- Repository: https://github.com/bogdann29/dpdkcap

## Overview

##### Project type and purpose
- DPDKCap is a high-speed packet capture tool built on top of DPDK (Data Plane Development Kit).
- It leverages multi-port, multi-core CPU parallelism and on-the-fly LZO compression to record network traffic into PCAP files.
- This is an open-source network utility rather than a web app or microservice. It operates entirely at the OS/hardware interface level.

##### File structure
- Top-level:
- Makefile, .travis.yml, Doxyfile, LICENSE, README.md – project build, CI, docs, and licensing.
- src/ – all C source and headers.
- src/ contains modules by functional area:
- core_capture.*   – logic to grab packets from DPDK RX queues.
- core_write.*     – logic to dequeue packets, compress (LZO), and write PCAP.
- pcap.*, parse.*, parser.* – building and parsing PCAP headers.
- lzo/minilzo/     – LZO compression library.
- crc32.*, sha256.* – checksum routines for PCAP integrity.
- hash_map.*       – internal data structures (e.g., statistics, port mapping).
- numa.*           – NUMA‐aware memory allocation.
- timestamp.*, statistics.* – time-stamping and runtime statistics.
- utils.*          – common helpers (configuration parsing, ring buffers).
- tasks.*          – assignment of capture vs write tasks to lcores.
- net_headers.h   – definitions of Ethernet/IP/TCP/UDP headers.
- No “frontend” or “backend” folders – rather a pipeline of DPDK initialization → capture tasks → write tasks → output files.

##### README for additional insights
- Describes use of DPDK EAL arguments, huge pages, port binding.
- Explains two task types: capturing cores enqueue packets into a main buffer; writing cores dequeue, compress, write.
- Mentions core allocation options (-c, -w), file rotation, compression toggle, rx_desc, mbufs tuning.

##### Elements
- Clear labels for each component (e.g., “Capture Core #0”, “Ring Buffer”, “Write Core #1”).
- Packet flow from NIC → capture cores → ring → write cores → disk.
- Control and stats flow from cores to logging module.
- Blue for Capture tasks.
- Orange for Write tasks + Compression module.
- Gray for Utilities (checksum, parser, NUMA).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration
    Config["Configuration\n(EAL args, file rotation, mbufs)"]:::config

    %% Startup and Initialization
    EAL["DPDK EAL Initialization"]:::dpdk
    PortSetup["Port Binding & RX Queue Setup"]:::dpdk

    %% Main Pipeline
    subgraph "Task Pools"
        direction TB
        CapturePool["Capture Task Pool\n(multiple lcores)"]:::capture
        RingBuffer["Central Ring Buffer\n(lock-free queue)"]:::utils
        WritePool["Write Task Pool\n(multiple lcores)"]:::write
    end

    Compressor["LZO Compression Module"]:::write
    PCAPWriter["PCAP File Writer & Header Construction"]:::write
    Storage(("PCAP File Storage")):::storage

    %% Utilities & Helpers
    subgraph "Utilities & Helpers"
        direction TB
        Parser["Packet Parsing & Header Helpers"]:::utils
        Checksum["Checksum Routines\n(crc32 & sha256)"]:::utils
        Numa["NUMA-aware Memory Allocation"]:::utils
        Utils["Common Utilities\n(config parsing, rings)"]:::utils
    end

    %% Statistics & Logging
    StatsCore["Statistics & Logging Core"]:::stats

    %% External Libraries
    extLibs["libnuma, libpcap, minilzo"]:::external

    %% Flows
    Config --> EAL
    EAL --> PortSetup
    PortSetup --> CapturePool
    CapturePool --> RingBuffer
    RingBuffer --> WritePool
    WritePool --> Compressor
    Compressor --> PCAPWriter
    PCAPWriter --> Storage

    CapturePool --> StatsCore
    RingBuffer --> StatsCore
    WritePool --> StatsCore
    StatsCore -->|"logs & stats"| Config

    Parser --> PCAPWriter
    Checksum --> PCAPWriter
    Utils --> CapturePool
    Utils --> WritePool
    Numa --> CapturePool
    Numa --> WritePool

    extLibs -.-> EAL
    extLibs -.-> Compressor
    extLibs -.-> PCAPWriter
    extLibs -.-> Numa

    %% Click Events
    click EAL "https://github.com/bogdann29/dpdkcap/blob/master/src/dpdkcap.c"
    click PortSetup "https://github.com/bogdann29/dpdkcap/blob/master/src/core_capture.c"
    click CapturePool "https://github.com/bogdann29/dpdkcap/blob/master/src/tasks.c"
    click RingBuffer "https://github.com/bogdann29/dpdkcap/blob/master/src/utils.c"
    click WritePool "https://github.com/bogdann29/dpdkcap/blob/master/src/tasks.c"
    click Compressor "https://github.com/bogdann29/dpdkcap/blob/master/src/lzo/lzowrite.c"
    click PCAPWriter "https://github.com/bogdann29/dpdkcap/blob/master/src/pcap.c"
    click Parser "https://github.com/bogdann29/dpdkcap/blob/master/src/parse.c"
    click Checksum "https://github.com/bogdann29/dpdkcap/blob/master/src/crc32.c"
    click Numa "https://github.com/bogdann29/dpdkcap/blob/master/src/numa.c"
    click StatsCore "https://github.com/bogdann29/dpdkcap/blob/master/src/statistics.c"
    click Utils "https://github.com/bogdann29/dpdkcap/blob/master/src/utils.c"

    %% Styling
    classDef dpdk fill:#a3be8c,stroke:#2e3440,color:#2e3440;
    classDef capture fill:#81a1c1,stroke:#2e3440,color:#2e3440;
    classDef write fill:#ebcb8b,stroke:#2e3440,color:#2e3440;
    classDef utils fill:#4c566a,stroke:#2e3440,color:#eceff4;
    classDef storage fill:#d08770,stroke:#2e3440,color:#2e3440,stroke-width:2px;
    classDef stats fill:#bf616a,stroke:#2e3440,color:#eceff4;
    classDef external fill:#88c0d0,stroke-dasharray: 5 5,stroke:#2e3440,color:#2e3440;
    classDef config fill:none,stroke-dasharray: 5 5,stroke:#2e3440,color:#2e3440;
```
