Downloading & Building PcapPlusPlus

Table Of Contents

Download Source Code

Download Compiled Binaries

I'll be releasing compiled binaries for several platforms once in a while. You can find them in the releases section in GitHub project home

Currently the latest release is August 2018 Release (18.08)

Package Content

The PcapPlusPlus package contains several libraries, unit-tests and example utilities:

  • Packet++ - a library for parsing, creating and editing packets of various supported protocols. This library can be used stand-alone and doesn't depend on Pcap++, libpcap/WinPcap, etc.
  • Pcap++ - a library for intercepting and sending packets, providing network and NIC info, stats, etc. This library is actually a C++ wrapper for packet capturing engines such as libpcap, WinPcap, DPDK and PF_RING
  • Common++ - a library containing common code utilities used by both Packet++ and Pcap++
  • Example applications: see Examples page
  • Unit-tests:
    • Packet++Test - a unit-test application for testing Packet++
    • Pcap++Test - a unit-test application for testing Pcap++

Building PcapPlusPlus - Windows (Visual Studio 2015)

Prerequisites

In order to build PcapPlusPlus on Windows with Visual Studio 2015 you need the following components:

  1. Microsoft Visual Studio 2015 (can be downloaded from here: https://www.visualstudio.com/downloads/)
  2. Winpcap developer's pack - containing the wpcap library PcapPlusPlus is linking with plus relevant h files. You can download it from https://www.winpcap.org/devel.htm
  3. pthread-win32 - can be downloaded from here: ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
Configuration and compilation
  1. run the configure-windows-visual-studio.bat batch file from PcapPlusPlus main directory. The script will ask you for the locations of WinPcap developer's pack and pthreads-win32. The script will modify mk\vs2015\PcapPlusPlusPropertySheet.props file with these locations
  2. PcapPlusPlus contains 3 Visual Studio solutions:
    • mk\vs2015\PcapPlusPlus.sln - contains PcapPlusPlus libraries (Common++, Packet++ and Pcap++) and unit-tests projects
    • mk\vs2015\PcapPlusPlus-Examples.sln - contains all PcapPlusPlus examples. Requires PcapPlusPlus.sln to be built
    • mk\vs2015\Tutorials.sln - contains all PcapPlusPlus tutorial examples. Requires PcapPlusPlus.sln to be built
  3. All solutions support both 32-bit (x86) and 64-bit (x64) configurations as well as Debug and Release modes. So actually 4 modes are supported: x86|Debug, x86|Release, x64|Debug, x64|Release

Building PcapPlusPlus - Windows (MinGW32 + MinGW-w64)

Prerequisites

In order to compile PcapPlusPlus on Windows using MinGW32 or MinGW-w64 you need the following components:

  1. MinGW32 or MinGW-w64 environment and compiler
    • Download and installation instructions for MinGW32:
      • The fastest way I found for installing mingw32 was through this link: https://www.mingw.org/wiki/Getting_Started
      • Download "mingw-get-setup.exe", run it and follow the instructions
      • By default the pthreads library is not installed so you need to ask to install it. It can be done during the installation process or afterwards with "mingw-get.exe" (MinGW installation manager)
      • In the MinGW installation manager search for all packages containing "pthreads" and mark them for installation. Make sure the pthreads-win32 version you install is 2.10 or later
      • Choose Installation->Update Catalogue
      • If you prefer to install pthreads manually please follow these steps:
        • Download pthreads for MinGW
        • Extract it with 7-Zip: 7z.exe e pthreads-GC-w32-2.10-mingw32-pre-20160821-1-dev.tar.xz -oC:\pthreads && 7z.exe x C:\pthreads\pthreads-GC-w32-2.10-mingw32-pre-20160821-1-dev.tar -oC:\pthreads
        • Copy the include files to MinGW folder: xcopy /Y C:\pthreads\include\* C:\MinGW\include
        • Copy the lib files to MinGW folder: xcopy /Y C:\pthreads\lib\* C:\MinGW\lib
    • Download and installation instructions for MinGW-w64:
      • Download and run mingw-w64 installer from here: https://sourceforge.net/projects/mingw-w64/
      • Make sure that the installation path doesn't contain spaces (otherwise PcapPlusPlus compilation may fail)
      • Make sure to choose the i686 option (which is 32-bit). PcapPlusPlus doesn't support MinGW-w64 64-bit (x86_64)
      • Make sure to choose POSIX threads and not win32 threads
      • Follow the instruction in the installation wizard
      • Install MSYS or MSYS2. MSYS2 installer can be downloaded from here: https://msys2.github.io/
      • Make sure to download and install the msys2-i686 installer and not the msys2-x86_64 installer
      • Add the following folders to your PATH environment variable:
        • The MinGW-w64 folder that cotains g++.exe, mingw32-make, etc. It should be under [MinGW-w64_install_folder]\mingw32\bin, for example: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
        • The MSYS2 usr\bin folder, for example: C:\msys32\usr\bin
  2. Winpcap developer's pack - containing the wpcap library PcapPlusPlus is linking with plus relevant h files. You can download it from https://www.winpcap.org/devel.htm
Configuration and compilation
  1. Please notice that x64 compilation is not supported (and will not work) on either MinGW32 nor MinGW-w64!
  2. Run the configure-windows-mingw.bat batch file from PcapPlusPlus main directory. The script will ask you for WinPcap developer's pack location and MinGW location. For MinGW-w64 please make sure to set the mingw32\i686-w64-mingw32 folder, for example: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\i686-w64-mingw32
  3. Run mingw32-make.exe all from PcapPlusPlus main directory
  4. This should compile all libraries, unit-tests and examples
  5. After compilation you can find the libraries, examples, header files and helpful makefiles under the Dist\ directory

Building PcapPlusPlus - Linux

Prerequisites

In order to compile PcapPlusPlus on Linux you need the following components:

  1. libpcap developers pack - containing the libpcap library PcapPlusPlus is linking with plus relevant header files. You can download it from https://www.tcpdump.org/#latest-release or through package management engines such as apt-get/yum:
    sudo apt-get install libpcap-dev
    or:
    sudo yum install libpcap-devel
  2. Make sure you have the libstdc++-static package. If not, you can install it via yum or apt-get
Configuration and compilation
  1. Run the configuration script from PcapPlusPlus main directory:
    ./configure-linux.sh
  2. If you'd like to compile it with PF_RING please follow the instructions in DPDK & PF_RING page and press "y" in "Compile PcapPlusPlus with PF_RING?"
  3. If you'd like to compile it with DPDK please follow the instructions in DPDK & PF_RING page and press "y" in "Compile PcapPlusPlus with DPDK?"
  4. If you'd like to enable libpcap immediate mode (supported on libpcap>=1.5) please use the --use-immediate-mode flag:
    ./configure-linux.sh --use-immediate-mode
  5. Build PcapPlusPlus libraries, unit-test and examples:
    make all
  6. Then run the installation script as sudo:
    sudo make install

Building PcapPlusPlus - MacOS

Prerequisites
  1. In order to compile PacpPlusPlus on Mac OS X you need to make sure Xcode is installed. Xcode contains all prerequisites required for PcapPlusPlus:
    1. gcc/g++ compiler
    2. libpcap with all relevant header files
  2. Also make sure you have Xcode Command Line Tools. You can install it by running the following command in Terminal:
    xcode-select --install
Configuration and compilation
  1. Run the configuration script from PcapPlusPlus main directory:
    ./configure-mac_os_x.sh
    To enable libpcap immediate mode (supported on libpcap>=1.5) please use the --use-immediate-mode flag:
    ./configure-linux.sh --use-immediate-mode
  2. Build PcapPlusPlus libraries, unit-test and examples:
    make all
  3. Then run the installation script as sudo:
    sudo make install

Simple Testing

To ensure configuration and compilation went smoothly, you can run the unit-test applications for both Packet++ and Pcap++:

  seladb@seladb:~/home/PcapPlusPlus/Tests/Packet++Test$ Bin/Packet++Test
EthPacketCreation             : PASSED
EthAndArpPacketParsing        : PASSED
ArpPacketCreation             : PASSED
VlanParseAndCreation          : PASSED
Ipv4PacketCreation            : PASSED
Ipv4PacketParsing             : PASSED
Ipv4FragmentationTest         : PASSED
Ipv4UdpChecksum               : PASSED
Ipv6UdpPacketParseAndCreate   : PASSED
TcpPacketNoOptionsParsing     : PASSED
TcpPacketWithOptionsParsing   : PASSED
TcpPacketWithOptionsParsing2  : PASSED
TcpPacketCreation             : PASSED
TcpPacketCreation2            : PASSED
InsertDataToPacket            : PASSED
InsertVlanToPacket            : PASSED
RemoveLayerTest               : PASSED
HttpRequestLayerParsingTest   : PASSED
HttpRequestLayerCreationTest  : PASSED
HttpRequestLayerEditTest      : PASSED
HttpResponseLayerParsingTest  : PASSED
HttpResponseLayerCreationTest : PASSED
HttpResponseLayerEditTest     : PASSED
PPPoESessionLayerParsingTest  : PASSED
PPPoESessionLayerCreationTest : PASSED
PPPoEDiscoveryLayerParsingTest: PASSED
PPPoEDiscoveryLayerCreateTest : PASSED
DnsLayerParsingTest           : PASSED
...
...
ALL TESTS PASSED!!
  seladb@seladb:~/PcapPlusPlus/Tests/Pcap++Test$ sudo Bin/Pcap++Test -i 10.0.0.1
Using ip: 10.0.0.1
Debug mode: off
Starting tests...
TestIPAddress                 : PASSED
TestMacAddress                : PASSED
TestPcapFileReadWrite         : PASSED
TestPcapSllFileReadWrite      : PASSED
TestPcapFileAppend            : PASSED
TestPcapNgFileReadWrite       : PASSED
TestPcapNgFileReadWriteAdv    : PASSED
TestPcapLiveDeviceList        : PASSED
TestPcapLiveDeviceListSearch  : PASSED
TestPcapLiveDevice            : PASSED
TestPcapLiveDeviceNoNetworking: PASSED
TestPcapLiveDeviceStatsMode   : PASSED
TestPcapLiveDeviceBlockingMode: PASSED
TestWinPcapLiveDevice         : PASSED
TestPcapFilters               : PASSED
TestSendPacket                : PASSED
TestSendPackets               : PASSED
TestRemoteCapture             : PASSED
TestHttpRequestParsing        : PASSED
TestHttpResponseParsing       : PASSED
...
...
ALL TESTS PASSED!!