# shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine architecture

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

- Interactive diagram: https://gitdiagram.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine
- Repository: https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine

## Overview

PacketAnalyser reads PCAP captures, parses packets, assigns flows across worker threads, identifies applications and domains, applies blocking policy, then writes a deterministic filtered capture and reports results. The principal multi-threaded path is shown; the README also documents DNS-based QUIC attribution and configurable thread pools. Several implementation files were indexed but not excerpted, so those relationships are supported by the README or source-index references rather than detailed call-site inspection.

Main entry points: [`src/dpi_engine.cpp`](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp) (DPI engine), [`src/fast_path.cpp`](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/fast_path.cpp) (Fast-path workers), [`include/cli.h`](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/cli.h) (CLI), [`src/pcap_reader.cpp`](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp) (PCAP reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Capture input"]
  node_cli["CLI<br/>[cli.h]"]
  node_pcap_reader["PCAP reader<br/>[pcap_reader.cpp]"]
  node_parser["Packet parser<br/>[packet_parser.cpp]"]
end

subgraph group_dispatch["Thread dispatch"]
  node_engine["DPI engine<br/>[dpi_engine.cpp]"]
  node_load_balancer["Load balancers<br/>[load_balancer.cpp]"]
  node_queue["Bounded queues"]
end

subgraph group_inspection["Flow inspection"]
  node_fast_path["Fast-path workers<br/>[fast_path.cpp]"]
  node_extractors["Protocol extractors<br/>[sni_extractor.cpp]"]
  node_tracker["Flow tracker"]
  node_dns_cache[("DNS cache<br/>[dns_cache.cpp]")]
end

subgraph group_results["Policy and results"]
  node_rules["Blocking rules<br/>[rule_manager.cpp]"]
  node_writer["PCAP writer<br/>[pcap_reader.cpp]"]
  node_reports["Reports<br/>[report.h]"]
end

node_operator(("Operator"))

node_operator -->|"configures"| node_cli
node_cli -->|"starts"| node_engine
node_engine -->|"reads capture"| node_pcap_reader
node_pcap_reader -->|"passes packets"| node_parser
node_engine -->|"parses packets"| node_parser
node_engine -->|"dispatches flows"| node_load_balancer
node_load_balancer -->|"enqueues packets"| node_queue
node_queue -->|"delivers packets"| node_fast_path
node_fast_path -->|"extracts identities"| node_extractors
node_fast_path -->|"tracks flows"| node_tracker
node_fast_path -->|"correlates names"| node_dns_cache
node_fast_path -->|"checks policy"| node_rules
node_engine -->|"writes filtered capture"| node_writer
node_engine -->|"generates reports"| node_reports

click node_cli "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/cli.h"
click node_pcap_reader "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp"
click node_parser "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/packet_parser.cpp"
click node_engine "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp"
click node_load_balancer "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/load_balancer.cpp"
click node_queue "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/thread_safe_queue.h"
click node_fast_path "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/fast_path.cpp"
click node_extractors "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/sni_extractor.cpp"
click node_tracker "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/connection_tracker.cpp"
click node_dns_cache "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/dns_cache.cpp"
click node_rules "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/rule_manager.cpp"
click node_writer "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp"
click node_reports "https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/report.h"

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_cli,node_pcap_reader,node_parser toneBlue
class node_engine,node_load_balancer,node_queue toneAmber
class node_fast_path,node_extractors,node_tracker,node_dns_cache toneMint
class node_rules,node_writer,node_reports toneRose
class node_operator toneIndigo
```

## Components

### Capture input

- [CLI](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/cli.h): `include/cli.h`
- [PCAP reader](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp): `src/pcap_reader.cpp`
- [Packet parser](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/packet_parser.cpp): `src/packet_parser.cpp`

### Thread dispatch

- [DPI engine](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/dpi_engine.cpp): `src/dpi_engine.cpp`
- [Load balancers](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/load_balancer.cpp): `src/load_balancer.cpp`
- [Bounded queues](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/thread_safe_queue.h): `include/thread_safe_queue.h`

### Flow inspection

- [Fast-path workers](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/fast_path.cpp): `src/fast_path.cpp`
- [Protocol extractors](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/sni_extractor.cpp): `src/sni_extractor.cpp`
- [Flow tracker](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/connection_tracker.cpp): `src/connection_tracker.cpp`
- [DNS cache](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/dns_cache.cpp): `src/dns_cache.cpp`

### Policy and results

- [Blocking rules](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/rule_manager.cpp): `src/rule_manager.cpp`
- [PCAP writer](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/src/pcap_reader.cpp): `src/pcap_reader.cpp`
- [Reports](https://github.com/shreyas-krishnan7/packetanalyser---a-deep-packet-inspection-engine/blob/main/include/report.h): `include/report.h`

### Other components

- **Operator**

## Connections

- Operator → CLI: configures (evidence: `README.md`)
- CLI → DPI engine: starts
- DPI engine → PCAP reader: reads capture (evidence: `README.md`)
- PCAP reader → Packet parser: passes packets (evidence: `README.md`)
- DPI engine → Packet parser: parses packets (evidence: `src/dpi_engine.cpp`)
- DPI engine → Load balancers: dispatches flows (evidence: `README.md`)
- Load balancers → Bounded queues: enqueues packets (evidence: `README.md`)
- Bounded queues → Fast-path workers: delivers packets (evidence: `README.md`)
- Fast-path workers → Protocol extractors: extracts identities (evidence: `src/fast_path.cpp`)
- Fast-path workers → Flow tracker: tracks flows (evidence: `src/fast_path.cpp`)
- Fast-path workers → DNS cache: correlates names (evidence: `README.md`)
- Fast-path workers → Blocking rules: checks policy (evidence: `src/fast_path.cpp`)
- DPI engine → PCAP writer: writes filtered capture (evidence: `README.md`)
- DPI engine → Reports: generates reports (evidence: `src/dpi_engine.cpp`)
