Skip to content

girish-xd/Deep-Packet-Inspection-Engine

Repository files navigation

🚀 Multi-threaded Deep Packet Inspection (DPI) Engine

Analyze. Classify. Inspect. Understand.

A high-performance Deep Packet Inspection (DPI) Engine built in C++17 for real-world network traffic analysis, application-level traffic classification, TLS inspection, and multi-threaded packet processing.

Real traffic. Real packets. Real protocol parsing.

No simulations. No APIs. Just raw network traffic.


C++ Wireshark Multithreading Networking PCAP Systems Programming


🔥 Why This Project?

Most packet analyzers stop at basic packet parsing. This DPI Engine goes several layers deeper by performing:

  • Deep Packet Inspection (DPI)
  • TLS Server Name Indication (SNI) Extraction
  • Five Tuple Flow Tracking
  • Multi-threaded Packet Processing
  • Application-Level Traffic Classification
  • Rule-Based Packet Filtering
  • Real Internet Traffic Analysis
  • PCAP Traffic Processing
  • Load Balanced Packet Distribution

Unlike conventional packet analyzers, this engine was validated using real-world network traffic captured through Wireshark and processed using a multi-threaded DPI pipeline.


✨ Highlights

✔ 25,520 Real Network Packets Analyzed

✔ 29+ Million Bytes Processed

✔ Multi-threaded Architecture

✔ Application-Level Traffic Classification

✔ TLS SNI & DNS Inspection

✔ Five Tuple Based Flow Tracking

✔ Rule-Based Packet Filtering

✔ Wireshark Integration

✔ Real World Traffic Analysis

✔ Modular Systems Programming Design

🌐 Real World Traffic Capture

Captured actual internet traffic using Wireshark and exported it as a PCAP file for Deep Packet Inspection.


📁 Captured PCAP File

The captured traffic was exported as a PCAP file and processed by the DPI Engine.


🚀 DPI Engine Initialization

The engine initializes Load Balancer and Fast Path threads to efficiently distribute packet workloads.


📊 Traffic Analysis Report

The DPI Engine successfully analyzed real network traffic.

Metric Value
Total Packets 25,520
Total Bytes 29,252,849
TCP Packets 1,988
UDP Packets 23,532
Forwarded Packets 25,520
Dropped Packets 0
Multi-threaded Yes
Real Traffic Tested Yes


🌍 Application-Level Traffic Classification

The DPI Engine identifies applications and services using:

  • TLS Server Name Indication (SNI)
  • HTTP Host Headers
  • DNS Queries
  • Packet Metadata
  • Port-based Classification

Successfully detected traffic from services such as:

GitHub
Google Services
YouTube
Twitter / X
HTTPS Traffic
DNS Traffic
Mozilla Services
TLS Traffic
Various CDN Services


⚙️ System Architecture


                    INPUT PCAP FILE
                             |
                             v
                       PCAP READER
                             |
                             v
                      PACKET PARSER
                             |
                             v
                      LOAD BALANCER
                             |
                             v
                    FAST PATH THREADS
                             |
                             v
                 APPLICATION CLASSIFIER
                             |
                             v
                    RULE BASED FILTERING
                             |
                             v
                      OUTPUT PCAP FILE
                             |
                             v
                       TRAFFIC REPORTS


🧠 Packet Processing Pipeline


Ethernet Frame
      ↓
IPv4 Packet
      ↓
TCP / UDP Parsing
      ↓
Payload Extraction
      ↓
TLS SNI Inspection
      ↓
Application Detection
      ↓
Rule Evaluation
      ↓
Packet Filtering
      ↓
Traffic Statistics Generation
      ↓
Output PCAP File


🏎️ Multi-threaded Architecture

The multi-threaded pipeline uses:

  • Reader Thread
  • Load Balancer Threads
  • Fast Path Threads
  • Thread Safe Queues
  • Output Writer Thread
  • Consistent Hashing for Flow Tracking

                    Reader Thread
                           |
                           v
                     Packet Queue
                           |
                -------------------------
                |                       |
                v                       v
             LB-0                    LB-1
                |                       |
            ----------               ----------
            |        |               |        |
            v        v               v        v
          FP0      FP1             FP2      FP3
            \        |               |      /
             \       |               |     /
                    Output Queue
                          |
                          v
                  Output Writer Thread

This architecture ensures packets belonging to the same connection are processed by the same Fast Path thread, enabling accurate flow tracking and better scalability.


🔒 TLS SNI Extraction

The DPI Engine performs Deep Packet Inspection on TLS Client Hello packets to extract:

  • Server Name Indication (SNI)
  • Domain Names
  • Application Signatures

Example:

TLS Client Hello

↓

SNI Extension

↓

www.youtube.com

↓

Application Classification

↓

YOUTUBE

This allows application-level traffic identification even for HTTPS traffic.


🚀 Key Features

Networking

  • Ethernet Frame Parsing
  • IPv4 Packet Parsing
  • TCP Packet Parsing
  • UDP Packet Parsing

Deep Packet Inspection

  • TLS SNI Inspection
  • HTTP Host Header Inspection
  • DNS Query Inspection

Traffic Classification

  • Application-Level Classification
  • Service Identification
  • Traffic Statistics Generation

Systems Programming

  • Five Tuple Flow Tracking
  • Multi-threaded Processing
  • Load Balancing Architecture
  • Fast Path Packet Processing
  • Thread-safe Queues

Filtering

  • Rule-Based Packet Filtering
  • Application Blocking Support
  • IP Based Blocking Support

🌐 Supported Protocols

Ethernet
IPv4
TCP
UDP
HTTP
HTTPS
DNS
TLS
PCAP

🌍 Supported Traffic Detection

GitHub
Google
YouTube
Twitter / X
HTTPS
DNS
Mozilla
TLS
Various CDN Services

🏗️ Project Structure

Header Files

Source Files

The project follows a modular architecture where packet parsing, traffic classification and packet processing are separated into independent components.


🛠 Tech Stack

Category Technologies
Language C++17
Networking TCP/IP, UDP, IPv4
Packet Capture Wireshark
Packet Format PCAP
Traffic Analysis Deep Packet Inspection
Classification TLS SNI Inspection
Architecture Multi-threaded
Programming Paradigm Systems Programming

📈 Performance Metrics

Real World Traffic Tested          YES

Packets Processed                  25,520

Traffic Processed                  29+ MB

Application Classification         YES

TLS SNI Extraction                 YES

Five Tuple Flow Tracking           YES

Rule Based Filtering               YES

Multi-threaded Architecture        YES

Wireshark Integration              YES

Output PCAP Generation             YES

⚡ Getting Started

Clone the repository:

git clone https://github.com/girish-xd/Deep-Packet-Inspection-Engine.git

Move into the project:

cd Deep-Packet-Inspection-Engine

Compile:

g++ -std=c++17 -pthread -O2 -I include -o dpi_engine \
src/dpi_mt.cpp \
src/pcap_reader.cpp \
src/packet_parser.cpp \
src/sni_extractor.cpp \
src/types.cpp

🚀 Running the Engine

Analyze a PCAP file:

./dpi_engine input.pcap output.pcap

Run the multi-threaded engine:

./dpi_engine test_dpi.pcap output.pcap

Generate sample PCAP data:

python3 generate_test_pcap.py

🔮 Future Improvements

  • Live Packet Capture Support
  • Real-time Traffic Monitoring
  • QUIC / HTTP3 Support
  • Interactive Traffic Dashboard
  • Advanced Application Classifiers
  • Enhanced Protocol Support
  • Performance Optimizations
  • Persistent Rule Management

Built with C++, caffeine and way too many packets.

If you're reading this, your browser has probably already leaked its SNI.

Made with ❤️ and raw packets by Girish Jain.

About

High-performance Multi-threaded Deep Packet Inspection (DPI) Engine built in C++17 for real-world network traffic analysis, TLS SNI extraction, Five Tuple flow tracking, application-level traffic classification, and load-balanced packet processing using a modular systems programming architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages