Benchmarks
To evaluate the performance of PcapPlusPlus, we employed two benchmarking methods: comparing it to similar libraries and using 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. This benchmark compares PcapPlusPlus with libtins 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:
Benchmark #1 - TCP parsing
Library | Time taken (seconds) | Packets per second |
---|---|---|
libpcap | 0.12 | 4166666 |
PcapPlusPlus | 0.197 | 2538071 |
libtins | 0.209 | 2392344 |
Benchmark #2 - TCP + TCP Options parsing
Library | Time taken (seconds) | Packets per second |
---|---|---|
libpcap | 0.124 | 4032258 |
PcapPlusPlus | 0.202 | 2475247 |
libtins | 0.241 | 2074688 |
Benchmark #3 - DNS parsing
Library | Time taken (seconds) | Packets per second |
---|---|---|
libpcap | 0.031 | 16129032 |
PcapPlusPlus | 0.208 | 2403846 |
libtins | 0.263 | 1901140 |
Google Benchmark
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.
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 |