Getting Started
PcapPlusPlus is a multi-platform C++ library for capturing, parsing and crafting of network packets. It is designed to be efficient, powerful and easy to use.
PcapPlusPlus enables decoding and forging capabilities for a large variety of network protocols. It also provides easy to use C++ wrappers for the most popular packet processing engines such as libpcap, WinPcap, Npcap (WinPcap's successor), DPDK, eBPF AF_XDP and PF_RING.
Latest version: v24.09Quick Start
This guide will help you install and build your first PcapPlusPlus application. You can find more information in the Tutorials and in the installation guide.
Please choose your platform:
- Linux
- MacOS
- Windows - MinGW
- Windows - Visual Studio
- Android
- FreeBSD
Step 1 - download PcapPlusPlus
Before downloading PcapPlusPlus make sure you have the prerequisites installed for Linux.
Pre-compiled packages are available for recent versions of Ubuntu, Fedora, RHEL and Alpine. You can find them under the v24.09 release.
Another option is using Homebrew on Linux if you have it installed on your system:
brew install pcapplusplus
If you have another Linux distribution or GCC version you'll need to build PcapPlusPlus from source. Make sure not to skip the installation part.
Step 2 - create your first app
If you downloaded a pre-compiled package go to: /path/to/your/package/example-app
.
If not, download the ExampleApp source files.
Make sure you see the following files:
|-- main.cpp
|-- 1_packet.pcap
|-- CMakeLists.txt
main.cpp
is the example application we'll use.
1_packet.pcap
is a pcap file the app reads from.
CMakeLists.txt
will help us build the app.
Step 3 - build and run your app
Configure CMake:
cmake -S . -B build -DPcapPlusPlus_ROOT=/path/to/your/package
Build the app:
cmake --build build
An executable file will be created which contains the compiled app. You can now run it and should be able to see the following output:
./example-app
Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'
Step 1 - install PcapPlusPlus
Before installing PcapPlusPlus make sure you have the prerequisites installed for MacOS.
The easiest way to get PcapPlusPlus is from Homebrew:
brew install pcapplusplus
If you prefer not to use Homebrew you can also found pre-compiled packages for various versions of Xcode in the v24.09 release.
Another option is to build PcapPlusPlus from source. Make sure not to skip the installation part.
Step 2 - create your first app
If you downloaded a pre-compiled package go to: /path/to/your/package/example-app
.
If you installed PcapPlusPlus using Homebrew or built from source, download the ExampleApp source files.
Make sure you see the following files:
|-- main.cpp
|-- 1_packet.pcap
|-- CMakeLists.txt
main.cpp
is the example application we'll use.
1_packet.pcap
is a pcap file the app reads from.
CMakeLists.txt
will help us build the app.
Step 3 - build and run your app
Configure CMake:
cmake -S . -B build -DPcapPlusPlus_ROOT=/path/to/your/package
Build the app:
cmake --build build
An executable file will be created which contains the compiled app. You can now run it and should be able to see the following output:
./example-app
Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'
Step 1 - install PcapPlusPlus
Before installing PcapPlusPlus make sure you have the prerequisites installed for MinGW-w64.
Pre-compiled packages are available for MinGW-w64. You can find them under the v24.09 release.
Make sure your MinGW-w64 GCC version matches the pre-compiled package. Otherwise you need to build PcapPlusPlus from source.
Step 2 - create your first app
If you downloaded a pre-compiled package go to: Drive:\path\to\your\package\example-app
.
If you built it from source, download the ExampleApp source files.
Make sure you see the following files:
|-- main.cpp
|-- 1_packet.pcap
|-- CMakeLists.txt
main.cpp
is the example application we'll use.
1_packet.pcap
is a pcap file the app reads from.
CMakeLists.txt
will help us build the app.
Step 3 - build and run your app
Configure CMake:
cmake -G "MinGW Makefiles" -S . -B build -DPcapPlusPlus_ROOT=Drive:\path\to\your\package -DPCAP_ROOT=Drive:\path\to\npcap-sdk -DPacket_ROOT=Drive:\path\to\npcap-sdk
Build the app:
cmake --build build
An executable file will be created which contains the compiled app. You can now run it and should be able to see the following output:
example-app.exe
Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'
Step 1 - install PcapPlusPlus
Before installing PcapPlusPlus make sure you have the prerequisites installed for Visual Studio. Please notice that the currently supported versions of Visual Studio are 2019 and 2022.
Download the pre-compiled package for the Visual Studio version you have (VS2019 or VS2022) from the v24.09 release. Please notice there are 4 different configurations for each VS version - x64 / Win32 and Debug / Release. It's important to remember because you'll use them later.
Step 2 - create your first app
Go to: Drive:\path\to\your\package\example-app
.
Make sure you see the following files:
|-- main.cpp
|-- 1_packet.pcap
|-- CMakeLists.txt
main.cpp
is the example application we'll use.
1_packet.pcap
is a pcap file the app reads from.
CMakeLists.txt
will help us build the app.
Step 3 - build and run your app
Configure CMake:
- VS2019 - x64
- VS2019 - Win32
- VS2022 - x64
- VS2022 - Win32
cmake -A x64 -G "Visual Studio 16 2019" -S . -B build -DPcapPlusPlus_ROOT=Drive:\path\to\your\package -DPCAP_ROOT=Drive:\path\to\npcap-sdk -DPacket_ROOT=Drive:\path\to\npcap-sdk
cmake -A Win32 -G "Visual Studio 16 2019" -S . -B build -DPcapPlusPlus_ROOT=Drive:\path\to\your\package -DPCAP_ROOT=Drive:\path\to\npcap-sdk -DPacket_ROOT=Drive:\path\to\npcap-sdk
cmake -A x64 -G "Visual Studio 17 2022" -S . -B build -DPcapPlusPlus_ROOT=Drive:\path\to\your\package -DPCAP_ROOT=Drive:\path\to\npcap-sdk -DPacket_ROOT=Drive:\path\to\npcap-sdk
cmake -A Win32 -G "Visual Studio 17 2022" -S . -B build -DPcapPlusPlus_ROOT=Drive:\path\to\your\package -DPCAP_ROOT=Drive:\path\to\npcap-sdk -DPacket_ROOT=Drive:\path\to\npcap-sdk
Build the app:
- Debug
- Release
cmake --build build --config Debug
cmake --build build --config Release
An executable file will be created which contains the compiled app. You can now run it and should be able to see the following output:
example-app.exe
Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'
ToyVpn-PcapPlusPlus
ToyVpn-PcapPlusPlus is an Android application designed for monitoring and analyzing network traffic on an Android device. It works by creating a VPN tunnel and routing all device traffic through it, allowing access to raw packets for real-time analysis and data storage.
The app is heavily inspired by Google’s ToyVpn example, which demonstrates how to use Android's VPN APIs to implement custom VPN solutions.
For more details, check out the ToyVpn-PcapPlusPlus's README.md
file, including instructions on how to build and install the app.
Pre-compiled PcapPlusPlus libraries for Android are available on the release page: v24.09 release.
Here are a few screenshot of the app:


Do I need a rooted device in order to use PcapPlusPlus in my Android app?
Not at all! Please follow this link
Using PcapPlusPlus in my app
Please follow this link
Step 1 - install PcapPlusPlus
Before installing PcapPlusPlus make sure you have the prerequisites installed for FreeBSD.
Pre-compiled packages are available for recent versions of FreeBSD. You can find them under the v24.09 release.
If you have other versions of FreeBSD you'll need to build PcapPlusPlus from source. Make sure not to skip the installation part.
Step 2 - create your first app
If you downloaded a pre-compiled package go to: /path/to/your/package/example-app
.
If you built it from source download the ExampleApp source files.
Make sure you see the following files:
|-- main.cpp
|-- 1_packet.pcap
|-- CMakeLists.txt
main.cpp
is the example application we'll use.
1_packet.pcap
is a pcap file the app reads from.
CMakeLists.txt
will help us build the app.
Step 3 - build and run your app
Configure CMake:
cmake -S . -B build -DPcapPlusPlus_ROOT=/path/to/your/package
Build the app:
cmake --build build
An executable file will be created which contains the compiled app. You can now run it and should be able to see the following output:
./example-app
Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'