Welcome To PcapPlusPlus Web-site

PcapPlusPlus is a multiplatform 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, DPDK and PF_RING.

Key Features

  • Decoding and forging capabilities for a large variety of network protocols (see the full list here)
  • Capture and send network packets through an easy to use C++ wrapper for libpcap and WinPcap
  • Packet processing in line speed through an efficient and easy to use C++ wrapper for DPDK and PF_RING
  • Read and write network packets to/from files in both PCAP and PCAPNG formats
  • Multiplatform support including Linux, MacOS and Windows
  • Unique implementation of TCP Reassembly logic which includes support of TCP retransmission, out-of-order TCP packets and missing TCP data
  • Implementation of IP Fragmentation and Defragmentation logic to create and reassemble IPv4 and IPv6 fragments
  • Remote packet capture on Windows using RPCAP protocol supported in WinPcap
  • Vast object-oriented packet filtering that makes libpcap's BPF filters a lot more user-friendly
  • Designed to be powerful and efficient

Getting Started

Writing applications with PcapPlusPlus is very easy and intuitive. Here is a simple application that shows how to read a packet from a PCAP file and parse it:

#include "IPv4Layer.h"
#include "Packet.h"
#include "PcapFileDevice.h"

int main(int argc, char* argv[])
{
    // open a pcap file for reading
    pcpp::PcapFileReaderDevice reader("1_packet.pcap");
    if (!reader.open())
    {
        printf("Error opening the pcap file\n");
        return 1;
    }

    // read the first (and only) packet from the file
    pcpp::RawPacket rawPacket;
    if (!reader.getNextPacket(rawPacket))
    {
        printf("Couldn't read the first packet in the file\n");
        return 1;
    }

    // parse the raw packet into a parsed packet
    pcpp::Packet parsedPacket(&rawPacket);

    // verify the packet is IPv4
    if (parsedPacket.isPacketOfType(pcpp::IPv4))
    {
        // extract source and dest IPs
        pcpp::IPv4Address srcIP = parsedPacket.getLayerOfType()->getSrcIpAddress();
        pcpp::IPv4Address destIP = parsedPacket.getLayerOfType()->getDstIpAddress();

        // print source and dest IPs
        printf("Source IP is '%s'; Dest IP is '%s'\n", srcIP.toString().c_str(), destIP.toString().c_str());
    }

    // close the file
    reader.close();

    return 0;
}

You can find much more information in the Tutorials section in PcapPlusPlus web-site. These tutorials will walk you through the main concepts and features of PcapPlusPlus and also provide code examples that you can easily download and run.

Multi Platform Support

PcapPlusPlus is currently supported on Windows, Linux and MacOS. It is being continuously tested on the following platforms:

Windows
  • Microsoft Visual Studio 2015 - x86 (32-bit) & x64 (64-bit) configurations
  • MinGW32 - x86 (32-bit) configuration only
  • MinGW-w64 - x86 (32-bit) configuration only
Linux
  • Ubuntu (12.04 LTS, 14.04 LTS, 16.04 LTS, 18.04 LTS)
  • Fedora 26 & 29
  • CentOS 7
  • It should work on other Linux distributions as well
MacOS
  • El Capitan (10.11)
  • Sierra (10.12)
  • High Sierra (10.13)
  • Mojave (10.14)

Package Content

PcapPlusPlus consists of 3 libraries:

  1. Packet++ - a library for parsing, creating and editing network packets
  2. Pcap++ - a library for intercepting and sending packets, providing network and NIC info, stats, etc. It is actually a C++ wrapper for packet capturing engines such as libpcap, WinPcap, DPDK and PF_RING
  3. Common++ - a library with some common code utilities used by both Packet++ and Pcap++

In addition it contains many examples, tutorials and utilities documented in the Examples and in the Tutorials pages.

Supported Network Protocols

The Packet++ library currently supports parsing, editing and creation of packets of the following protocols:

  • Ethernet
  • SLL (Linux cooked capture)
  • Null/Loopback
  • Raw IP (IPv4 & IPv6)
  • IPv4
  • IPv6
  • ARP
  • VLAN
  • VXLAN
  • MPLS
  • PPPoE
  • GRE
  • TCP
  • UDP
  • ICMP
  • IGMP (IGMPv1, IGMPv2 and IGMPv3 are supported)
  • SIP
  • SDP
  • RADIUS
  • DNS
  • DHCP
  • HTTP headers (request & response)
  • SSL/TLS - parsing only (no editing capabilities)
  • Packet trailer (a.k.a footer or padding)
  • Generic payload

Supported Packet Capture Engines

PcapPlusPlus currently works with the following packet capture engines:

  • libpcap live capture (on Linux and MacOS)
  • WinPcap live capture (on Windows)
  • ntop's Vanilla PF_RING engine (on Linux)
  • Intel DPDK engine (on Linux)
  • WinPcap Remote live capture (on Windows)
  • PCAP and PCAPNG file devices (reading and writing)

Useful Packet And Network Utilities

  • TCP reassembly logic
  • IPv4 reassembly logic (a.k.a IPv4 de-fragmentation)
  • Packet hash key creation (by 5-tuple and 2-tuple)
  • Retrieve remote machine MAC address using ARP protocol
  • Retrieve host IPv4 address by using DNS protocol
  • Checksum calculation

DPDK And PF_RING Support

The Data Plane Development Kit (DPDK) is a set of data plane libraries and network interface controller drivers for fast packet processing.

PF_RING is a new type of network socket that dramatically improves the packet capture speed.

Both frameworks provide very fast packets processing (up to line speed) and are used in many network applications such as routers, firewalls, load balancers, etc. PcapPlusPLus provides a C++ abstraction layer over DPDK & PF_RING. This abstraction layer provides an easy to use interface that removes a lot of the boilerplate involved in using these frameworks. You can learn more by visiting the DPDK & PF_RING support page.

License

PcapPlusPlus is released under the Unlicense license.