# pani62172/deep-packet-inspection-engine architecture

> Architecture diagram of the GitHub repository pani62172/deep-packet-inspection-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pani62172/deep-packet-inspection-engine
- Repository: https://github.com/pani62172/deep-packet-inspection-engine

## Overview

This is a PCAP-based, multi-threaded deep-packet-inspection engine. Its main workflow reads captured packets, parses network headers, distributes flow-consistent work to inspection workers, classifies traffic and applies blocking rules, then writes allowed packets and reports statistics. The graph includes documented capabilities such as SNI/domain detection and IP/application/domain blocking. Some subsystem links rely on the README architecture; source excerpts are incomplete, so unverified implementation relationships are omitted.

Main entry points: [`src/dpi_engine.cpp`](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp) (DPI Engine), [`src/fast_path.cpp`](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/fast_path.cpp) (Fast Path Workers), [`src/packet_parser.cpp`](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/packet_parser.cpp) (Packet Parser), [`src/load_balancer.cpp`](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/load_balancer.cpp) (Load Balancers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Capture Input"]
  node_pcap["PCAP Reader<br/>[pcap_reader.cpp]"]
  node_parser["Packet Parser<br/>[packet_parser.cpp]"]
  node_platform["Platform Helpers<br/>[platform.h]"]
end

subgraph group_dispatch["Processing Dispatch"]
  node_mt_entry["Multithreaded Entry<br/>[dpi_mt.cpp]"]
  node_engine["DPI Engine<br/>[dpi_engine.cpp]"]
  node_load_balancer["Load Balancers<br/>[load_balancer.cpp]"]
  node_queue["Thread-Safe Queues"]
  node_simple_entry["Simple Entry Point<br/>[main_working.cpp]"]
  node_dpi_entry["DPI Engine Entry<br/>[main_dpi.cpp]"]
end

subgraph group_inspect["Inspection and Policy"]
  node_fast_path["Fast Path Workers<br/>[fast_path.cpp]"]
  node_sni["SNI and Domain Extraction<br/>[sni_extractor.cpp]"]
  node_rules["Blocking Rules<br/>[rule_manager.cpp]"]
end

subgraph group_state["Flow State and Data"]
  node_tracker[("Connection Tracking")]
  node_types["Packet and Flow Types<br/>[types.cpp]"]
end

subgraph group_output["Output and Reporting"]
  node_output_pcap["Output PCAP"]
  node_statistics["Processing Statistics<br/>[dpi_engine.cpp]"]
end

node_operator(("Operator"))

node_operator -->|"runs capture analysis"| node_mt_entry
node_mt_entry -->|"reads captures"| node_pcap
node_pcap -->|"supplies raw packets"| node_parser
node_parser -->|"parses before distribution"| node_load_balancer
node_mt_entry -->|"distributes packet flows"| node_load_balancer
node_load_balancer -->|"dispatches packets"| node_queue
node_queue -->|"delivers queued packets"| node_fast_path
node_fast_path -->|"extracts domain information"| node_sni
node_fast_path -->|"evaluates blocking rules"| node_rules
node_fast_path -->|"tracks flows"| node_tracker
node_fast_path -->|"processes packet jobs"| node_types
node_engine -->|"initializes rule manager"| node_rules
node_engine -->|"routes parsed jobs"| node_load_balancer
node_engine -->|"writes forwarded packets"| node_output_pcap
node_engine -->|"tracks processing counts"| node_statistics
node_operator -->|"processes input file"| node_engine
node_simple_entry -->|"reads captures"| node_pcap
node_simple_entry -->|"parses packets"| node_parser
node_dpi_entry -->|"starts engine"| node_engine
node_parser -->|"uses platform helpers"| node_platform

click node_pcap "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp"
click node_parser "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/packet_parser.cpp"
click node_platform "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/include/platform.h"
click node_mt_entry "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_mt.cpp"
click node_engine "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp"
click node_load_balancer "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/load_balancer.cpp"
click node_queue "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/include/thread_safe_queue.h"
click node_fast_path "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/fast_path.cpp"
click node_sni "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/sni_extractor.cpp"
click node_rules "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/rule_manager.cpp"
click node_tracker "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/connection_tracker.cpp"
click node_types "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/types.cpp"
click node_simple_entry "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/main_working.cpp"
click node_dpi_entry "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/main_dpi.cpp"
click node_statistics "https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pcap,node_parser,node_platform toneBlue
class node_mt_entry,node_engine,node_load_balancer,node_queue,node_simple_entry,node_dpi_entry toneAmber
class node_fast_path,node_sni,node_rules toneMint
class node_tracker,node_types toneRose
class node_output_pcap,node_statistics,node_operator toneIndigo
```

## Components

### Capture Input

- [PCAP Reader](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp): `src/pcap_reader.cpp`
- [Packet Parser](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/packet_parser.cpp): `src/packet_parser.cpp`
- [Platform Helpers](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/include/platform.h): `include/platform.h`

### Processing Dispatch

- [Multithreaded Entry](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_mt.cpp): `src/dpi_mt.cpp`
- [DPI Engine](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp): `src/dpi_engine.cpp`
- [Load Balancers](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/load_balancer.cpp): `src/load_balancer.cpp`
- [Thread-Safe Queues](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/include/thread_safe_queue.h): `include/thread_safe_queue.h`
- [Simple Entry Point](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/main_working.cpp): `src/main_working.cpp`
- [DPI Engine Entry](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/main_dpi.cpp): `src/main_dpi.cpp`

### Inspection and Policy

- [Fast Path Workers](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/fast_path.cpp): `src/fast_path.cpp`
- [SNI and Domain Extraction](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/sni_extractor.cpp): `src/sni_extractor.cpp`
- [Blocking Rules](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/rule_manager.cpp): `src/rule_manager.cpp`

### Flow State and Data

- [Connection Tracking](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/connection_tracker.cpp): `src/connection_tracker.cpp`
- [Packet and Flow Types](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/types.cpp): `src/types.cpp`

### Output and Reporting

- **Output PCAP**
- [Processing Statistics](https://github.com/pani62172/deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp): `src/dpi_engine.cpp`

### Other components

- **Operator**

## Connections

- Operator → Multithreaded Entry: runs capture analysis (evidence: `README.md`)
- Multithreaded Entry → PCAP Reader: reads captures (evidence: `src/dpi_mt.cpp`)
- PCAP Reader → Packet Parser: supplies raw packets (evidence: `README.md`)
- Packet Parser → Load Balancers: parses before distribution (evidence: `README.md`)
- Multithreaded Entry → Load Balancers: distributes packet flows (evidence: `README.md`)
- Load Balancers → Thread-Safe Queues: dispatches packets
- Thread-Safe Queues → Fast Path Workers: delivers queued packets
- Fast Path Workers → SNI and Domain Extraction: extracts domain information (evidence: `README.md`)
- Fast Path Workers → Blocking Rules: evaluates blocking rules (evidence: `README.md`)
- Fast Path Workers → Connection Tracking: tracks flows
- Fast Path Workers → Packet and Flow Types: processes packet jobs
- DPI Engine → Blocking Rules: initializes rule manager (evidence: `src/dpi_engine.cpp`)
- DPI Engine → Load Balancers: routes parsed jobs (evidence: `src/dpi_engine.cpp`)
- DPI Engine → Output PCAP: writes forwarded packets
- DPI Engine → Processing Statistics: tracks processing counts (evidence: `src/dpi_engine.cpp`)
- Operator → DPI Engine: processes input file
- Simple Entry Point → PCAP Reader: reads captures (evidence: `src/main_working.cpp`)
- Simple Entry Point → Packet Parser: parses packets (evidence: `src/main_working.cpp`)
- DPI Engine Entry → DPI Engine: starts engine (evidence: `src/main_dpi.cpp`)
- Packet Parser → Platform Helpers: uses platform helpers (evidence: `src/packet_parser.cpp`)
