This guide will help you build and run the DPI Engine on Windows. Follow these steps exactly.
-
Download Visual Studio 2022 Community (free):
- Go to: https://visualstudio.microsoft.com/downloads/
- Click "Free download" under Community
-
Run the installer
-
When asked "What workloads to install", select:
- ✅ Desktop development with C++
-
Click "Install" and wait (this takes 10-20 minutes)
-
Open Visual Studio 2022
-
Click "Open a local folder"
-
Navigate to the
packet_analyzerfolder and click "Select Folder" -
Wait for Visual Studio to scan the files (bottom status bar shows progress)
-
In Solution Explorer (right side), right-click on the folder name
-
Click "Add" → "New Item"
-
Select "C++ File (.cpp)" and name it
CMakeSettings.json -
Replace the content with:
{
"configurations": [
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": ["msvc_x64_x64"],
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}- Save the file (Ctrl+S)
Method A: Using CMake (if CMakeLists.txt works)
- Visual Studio should detect CMakeLists.txt automatically
- Select "Build" → "Build All" from the menu
- The executable will be in
build\x64-Release\
Method B: Manual Build (Recommended)
-
Open "View" → "Terminal" (or press Ctrl+`)
-
In the terminal, type:
cd packet_analyzer
cl /EHsc /std:c++17 /O2 /I include /Fe:dpi_engine.exe ^
src\dpi_mt.cpp ^
src\pcap_reader.cpp ^
src\packet_parser.cpp ^
src\sni_extractor.cpp ^
src\types.cpp- If successful, you'll see
dpi_engine.exein the folder
dpi_engine.exe test_dpi.pcap output.pcap-
Download MSYS2 from: https://www.msys2.org/
- Click the download button for
msys2-x86_64-xxxxxxxx.exe
- Click the download button for
-
Run the installer:
- Install to
C:\msys64(default) - Keep "Run MSYS2 now" checked
- Click Finish
- Install to
-
A terminal window opens. Run these commands:
# Update package database
pacman -Syu-
The window will close. Open "MSYS2 MINGW64" from Start Menu (NOT the regular MSYS2!)
-
Install the compiler:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make- Type
Yand press Enter when asked
-
Press
Win + R, typesysdm.cpl, press Enter -
Click "Advanced" tab → "Environment Variables"
-
Under "System variables", find "Path", click "Edit"
-
Click "New" and add:
C:\msys64\mingw64\bin -
Click OK on all windows
-
Restart your computer (important!)
-
Open Command Prompt (cmd) or PowerShell
-
Navigate to the project:
cd C:\path\to\packet_analyzer -
Build:
g++ -std=c++17 -O2 -I include -o dpi_engine.exe ^ src/dpi_mt.cpp ^ src/pcap_reader.cpp ^ src/packet_parser.cpp ^ src/sni_extractor.cpp ^ src/types.cpp
-
If successful, you'll see
dpi_engine.exe
dpi_engine.exe test_dpi.pcap output.pcapWSL lets you run Linux inside Windows - easiest if you're comfortable with Linux.
-
Open PowerShell as Administrator:
- Press
Win, type "PowerShell" - Right-click → "Run as administrator"
- Press
-
Run:
wsl --install -
Restart your computer when prompted
-
After restart, Ubuntu will open automatically
- Create a username and password when asked
In the Ubuntu terminal:
sudo apt update
sudo apt install -y build-essential g++Your Windows files are accessible at /mnt/c/:
# If your project is at C:\Users\YourName\Downloads\packet_analyzer
cd /mnt/c/Users/YourName/Downloads/packet_analyzerg++ -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./dpi_engine test_dpi.pcap output.pcap- Download from: https://code.visualstudio.com/
- Install with default options
- Open VS Code
- Click Extensions icon (left sidebar) or press
Ctrl+Shift+X - Search and install:
- C/C++ (by Microsoft)
- C/C++ Extension Pack (by Microsoft)
Follow Option 2 above to install MinGW-w64, then continue here.
- File → Open Folder
- Select the
packet_analyzerfolder
- Press
Ctrl+Shift+P - Type "Tasks: Configure Task" and select it
- Select "Create tasks.json file from template"
- Select "Others"
- Replace content with:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build DPI Engine",
"type": "shell",
"command": "g++",
"args": [
"-std=c++17",
"-O2",
"-I", "include",
"-o", "dpi_engine.exe",
"src/dpi_mt.cpp",
"src/pcap_reader.cpp",
"src/packet_parser.cpp",
"src/sni_extractor.cpp",
"src/types.cpp"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"]
}
]
}- Save the file
Press Ctrl+Shift+B to build
Open terminal in VS Code (`Ctrl+``) and run:
.\dpi_engine.exe test_dpi.pcap output.pcapCause: MinGW not installed or not in PATH
Fix:
- Make sure you installed MinGW-w64 (Option 2, Step 1)
- Make sure you added to PATH (Option 2, Step 2)
- Restart your computer
- Open NEW terminal and try again
Cause: Visual Studio compiler not in PATH
Fix:
- Open "Developer Command Prompt for VS 2022" (search in Start Menu)
- Navigate to project folder
- Run the build command from there
Cause: Wrong directory or missing -I flag
Fix:
Make sure you're in the packet_analyzer folder:
cd C:\full\path\to\packet_analyzer
dir includeYou should see the .h files listed.
Cause: Threading library not linked (MinGW)
Fix: Add -pthread flag:
g++ -std=c++17 -pthread -O2 -I include -o dpi_engine.exe ...Cause: Missing input file
Fix: Make sure test_dpi.pcap exists:
dir test_dpi.pcapIf missing, create it:
python generate_test_pcap.py(Requires Python installed)
Cause: Permission denied or file in use
Fix:
- Close any program that might have output.pcap open
- Try a different output filename:
dpi_engine.exe test_dpi.pcap result.pcap
| Method | Command |
|---|---|
| Visual Studio (cl) | cl /EHsc /std:c++17 /O2 /I include /Fe:dpi_engine.exe src\dpi_mt.cpp src\pcap_reader.cpp src\packet_parser.cpp src\sni_extractor.cpp src\types.cpp |
| MinGW (g++) | g++ -std=c++17 -O2 -I include -o dpi_engine.exe src/dpi_mt.cpp src/pcap_reader.cpp src/packet_parser.cpp src/sni_extractor.cpp src/types.cpp |
| WSL/Linux | 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 |
# Basic run
dpi_engine.exe input.pcap output.pcap
# With blocking
dpi_engine.exe input.pcap output.pcap --block-app YouTube --block-ip 192.168.1.50
# Custom thread count
dpi_engine.exe input.pcap output.pcap --lbs 4 --fps 4To test with real traffic:
-
Download Wireshark: https://www.wireshark.org/download.html
-
Install and open Wireshark
-
Select your network interface (usually "Wi-Fi" or "Ethernet")
-
Browse some websites for 30 seconds
-
Press the red square to stop capture
-
File → Save As → Choose "Wireshark/tcpdump/... - pcap"
-
Save as
my_capture.pcap -
Run DPI engine on it:
dpi_engine.exe my_capture.pcap filtered.pcap
If you're stuck:
- Make sure you followed EVERY step (don't skip any!)
- Check the Troubleshooting section above
- Try WSL (Option 3) - it's the most reliable
- Google the exact error message
Good luck! 🚀
