Benchmarks
I used Matias Fontanini's packet-capture-benchmarks project to compare the performance of PcapPlusPlus with other similar C++ libraries (libtins and libcrafter)
Testing environment
I ran all 3 benchmarks provided in packet-capture-benchmarks on the following environment:
- Linux Ubuntu 16.04 64-bit running as a VirtualBox VM
- Compiler is GCC 5.4.0
- Host platform is a dual-core Intel Core i5 760 2.8GHz with 8GB RAM system running Windows 10 64-bit
The benchmark application can be found in PcapPlusPlus examples
Tested libraries
I decided to compare PcapPlusPlus only to similar C++ libraries such as libtins and libcrafter. That's because Python or Java libraries cannot compete with native code libraries in terms of performance. I used the latest versions available at the time of the test (Nov 25 2017):
- libpcap 1.8.1
- PcapPlusPlus - commit f6e04a7
- libtins - commit f4635a6
- libcrafter - commit 3db70ab
Test results
Benchmark #1 - Interpretting TCP
Library | Time taken(seconds) | Packets per second |
---|---|---|
libpcap | 0.201 | 2487562 |
PcapPlusPlus | 0.327 | 1529051 |
libtins | 0.385 | 1298701 |
libcrafter | 14.401 | 34719 |
As you can see PcapPlusPlus is ~15% faster than libtins and ~x44 faster than libcrafter
Benchmark #2 - Interpretting TCP + TCP Options
Library | Time taken(seconds) | Packets per second |
---|---|---|
libpcap | 0.154 | 3246753 |
PcapPlusPlus | 0.335 | 1492537 |
libtins | 0.508 | 984251 |
libcrafter | 24.176 | 20681 |
As you can see PcapPlusPlus is ~35% faster than libtins and ~x72 faster than libcrafter
Benchmark #3 - Interpretting DNS
Library | Time taken(seconds) | Packets per second |
---|---|---|
libpcap | 0.050 | 10000000 |
PcapPlusPlus | 0.425 | 1176470 |
libtins | 0.466 | 1072961 |
libcrafter | 15.923 | 31401 |
As you can see PcapPlusPlus is ~8% faster than libtins and ~x37 faster than libcrafter