Skip to content

Bump the version to v25.05 #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions versioned_docs/version-v25.05/api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: API Reference
sidebar_position: 99
---

# API Reference

import ButtonLink from '/src/components/ButtonLink';
import { useActiveVersion } from '@docusaurus/plugin-content-docs/client';
import { ThemedImageWithBaseUrl } from '@site/src/components/ImageWithBaseUrl';

<ButtonLink
text="Go to Doxygen API reference"
link={'pathname:///api-docs/' + useActiveVersion().label.toLowerCase()}
></ButtonLink>
<br />
<br />
PcapPlusPlus consists of 3 libraries:

- **Packet++** - a library for parsing, creating and editing network packets
- **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, Npcap, DPDK and PF_RING
- **Common++** - a library with some common code utilities used by both Packet++ and Pcap++

The dependency model between the libraries is as follows:

<ThemedImageWithBaseUrl
srcLight="/api-docs/libraries-light.svg"
srcDark="/api-docs/libraries-dark.svg"
/>

That means, you can use **Common++** separately from the other libraries, and you can also use **Packet++** without **Pcap++**.

All of PcapPlusPlus APIs including classes for all of these libraries, files, data structures, etc. are documented in details using [Doxygen](http://www.doxygen.nl/).
124 changes: 124 additions & 0 deletions versioned_docs/version-v25.05/benchmark.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: Benchmarks
sidebar_position: 8
---

export const TCP_NO_OPTIONS_PCAPPLUSPLUS_SEC = 0.197;
export const TCP_NO_OPTIONS_LIBTINS_SEC = 0.209;
export const TCP_NO_OPTIONS_LIBPCAP_SEC = 0.12;

export const TCP_NO_OPTIONS_PCAPPLUSPLUS_PPS = 2538071;
export const TCP_NO_OPTIONS_LIBTINS_PPS = 2392344;
export const TCP_NO_OPTIONS_LIBPCAP_PPS = 4166666;

export const TCP_WITH_OPTIONS_PCAPPLUSPLUS_SEC = 0.202;
export const TCP_WITH_OPTIONS_LIBTINS_SEC = 0.241;
export const TCP_WITH_OPTIONS_LIBPCAP_SEC = 0.124;

export const TCP_WITH_OPTIONS_PCAPPLUSPLUS_PPS = 2475247;
export const TCP_WITH_OPTIONS_LIBTINS_PPS = 2074688;
export const TCP_WITH_OPTIONS_LIBPCAP_PPS = 4032258;

export const DNS_PCAPPLUSPLUS_SEC = 0.208;
export const DNS_LIBTINS_SEC = 0.263;
export const DNS_LIBPCAP_SEC = 0.031;

export const DNS_PCAPPLUSPLUS_PPS = 2403846;
export const DNS_LIBTINS_PPS = 1901140;
export const DNS_LIBPCAP_PPS = 16129032;

import Chart from 'react-google-charts';
import ThemedChart from '/src/components/ThemedChart';
import ConstVal from '/src/components/ConstVal';

To evaluate the performance of PcapPlusPlus, we employed two benchmarking methods: comparing it to similar libraries and using [Google Benchmark](https://github.com/google/benchmark) to measure key features. This page presents the results of these tests.

## Testing environment

The benchmarks were conducted on the following system configuration:

- Linux Ubuntu 22.04 64-bit running inside WSL2
- g++ 11.4.0
- The host platform is a Windows machine with Intel Core i7-8700 3.2GHz processor and 16GB RAM running Windows 10

## Project Comparison

To compare PcapPlusPlus with other C++ libraries, we used [Matias Fontanini's packet-capture-benchmarks project](https://github.com/mfontanini/packet-capture-benchmarks). This benchmark compares PcapPlusPlus with [libtins](http://libtins.github.io/) and libpcap.

PcapPlusPlus was only compared to similar C/C++ projects, as libraries written in higher-level languages (such as Python or Java) cannot match the performance of native C++ libraries.

The following versions were used during the benchmark:

- libpcap-dev [v1.10.1](https://www.tcpdump.org/#old-releases)
- PcapPlusPlus [v24.09](https://github.com/seladb/PcapPlusPlus/releases/tag/v24.09)
- libtins [v4.5](https://github.com/mfontanini/libtins/releases/tag/v4.5)

### Benchmark #1 - TCP parsing

| Library | Time taken (seconds) | Packets per second |
| :--------------- | :---------------------------------------------------------------- | :---------------------------------------------------------------- |
| libpcap | <ConstVal value={TCP_NO_OPTIONS_LIBPCAP_SEC}></ConstVal> | <ConstVal value={TCP_NO_OPTIONS_LIBPCAP_PPS}></ConstVal> |
| **PcapPlusPlus** | **<ConstVal value={TCP_NO_OPTIONS_PCAPPLUSPLUS_SEC}></ConstVal>** | **<ConstVal value={TCP_NO_OPTIONS_PCAPPLUSPLUS_PPS}></ConstVal>** |
| libtins | <ConstVal value={TCP_NO_OPTIONS_LIBTINS_SEC}></ConstVal> | <ConstVal value={TCP_NO_OPTIONS_LIBTINS_PPS}></ConstVal> |

<ThemedChart
data={[
['Library', 'Seconds'],
['libpcap', TCP_NO_OPTIONS_LIBPCAP_SEC],
['PcapPlusPlus', TCP_NO_OPTIONS_PCAPPLUSPLUS_SEC],
['libtins', TCP_NO_OPTIONS_LIBTINS_SEC]
]}
/>

### Benchmark #2 - TCP + TCP Options parsing

| Library | Time taken (seconds) | Packets per second |
| :--------------- | :------------------------------------------------------------------ | :------------------------------------------------------------------ |
| libpcap | <ConstVal value={TCP_WITH_OPTIONS_LIBPCAP_SEC}></ConstVal> | <ConstVal value={TCP_WITH_OPTIONS_LIBPCAP_PPS}></ConstVal> |
| **PcapPlusPlus** | **<ConstVal value={TCP_WITH_OPTIONS_PCAPPLUSPLUS_SEC}></ConstVal>** | **<ConstVal value={TCP_WITH_OPTIONS_PCAPPLUSPLUS_PPS}></ConstVal>** |
| libtins | <ConstVal value={TCP_WITH_OPTIONS_LIBTINS_SEC}></ConstVal> | <ConstVal value={TCP_WITH_OPTIONS_LIBTINS_PPS}></ConstVal> |

<ThemedChart
data={[
['Library', 'Seconds'],
['libpcap', TCP_WITH_OPTIONS_LIBPCAP_SEC],
['PcapPlusPlus', TCP_WITH_OPTIONS_PCAPPLUSPLUS_SEC],
['libtins', TCP_WITH_OPTIONS_LIBTINS_SEC]
]}
/>

### Benchmark #3 - DNS parsing

| Library | Time taken (seconds) | Packets per second |
| :--------------- | :----------------------------------------------------- | :----------------------------------------------------- |
| libpcap | <ConstVal value={DNS_LIBPCAP_SEC}></ConstVal> | <ConstVal value={DNS_LIBPCAP_PPS}></ConstVal> |
| **PcapPlusPlus** | **<ConstVal value={DNS_PCAPPLUSPLUS_SEC}></ConstVal>** | **<ConstVal value={DNS_PCAPPLUSPLUS_PPS}></ConstVal>** |
| libtins | <ConstVal value={DNS_LIBTINS_SEC}></ConstVal> | <ConstVal value={DNS_LIBTINS_PPS}></ConstVal> |

<ThemedChart
data={[
['Library', 'Seconds'],
['libpcap', DNS_LIBPCAP_SEC],
['PcapPlusPlus', DNS_PCAPPLUSPLUS_SEC],
['libtins', DNS_LIBTINS_SEC]
]}
/>

## Google Benchmark

[Google Benchmark](https://github.com/google/benchmark) is a library designed for measuring the performance of C++ applications. We utilized it to evaluate several aspects of PcapPlusPlus.
The benchmark code can be found in [PcapPlusPlus Examples - Google Benchmark](https://github.com/seladb/PcapPlusPlus/blob/master/Examples/PcapPlusPlus-benchmark/benchmark-google.cpp).

The benchmark covers the following operations:

- Reading pcap files (`BM_PcapFileRead`)
- Writing pcap files (`BM_PcapFileWrite`)
- Packet parsing (`BM_PacketCrafting`)
- Packet crafting (`BM_PacketCrafting`)

| Benchmark | Time | CPU | Iterations | Bytes Per Second | Items Per Second |
| :---------------- | :------ | :------ | :--------- | :--------------- | :--------------- |
| BM_PcapFileRead | 177 ns | 177 ns | 3828289 | 2.35172Gi/s | 5.63843M/s |
| BM_PcapFileWrite | 79.1 ns | 79.1 ns | 9080461 | 650.828Mi/s | 12.6378M/s |
| BM_PacketParsing | 352 ns | 352 ns | 1994805 | 1.18917Gi/s | 2.84116M/s |
| BM_PacketCrafting | 385 ns | 385 ns | 1799083 | 143.504Mi/s | 2.59444M/s |
Loading