-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.html
195 lines (187 loc) · 5.85 KB
/
benchmark.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
title: Benchmarks
layout: default
section: benchmark
---
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(draw_charts);
function find_upper_bound(input) {
maximum = 0;
for(i = 0; i < input.length; ++i) {
if(input[i][0] != "scapy" && input[i][1] > maximum) {
maximum = input[i][1];
}
}
return maximum * 1.05;
}
function convert_to_seconds(input) {
for(i = 0; i < input.length; ++i) {
input[i][1] = (input[i][1] / 1000);
}
return input;
}
function draw_graphic(name, output_div, input) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Library');
data.addColumn('number', 'Seconds');
input.sort(
function(a, b) {
return a[1] > b[1];
}
);
data.addRows(convert_to_seconds(input));
// Set chart options
var options = {
'title' : name,
'width' : 650,
'height' : 450,
'left' : 0,
chartArea: {
left : 0
},
vAxis: {
viewWindowMode: 'explicit',
viewWindow:{
max:find_upper_bound(input),
min:0
}
},
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.ColumnChart(
document.getElementById(output_div)
);
chart.draw(data, options);
}
function draw_charts() {
draw_graphic('Graphic view', 'tcp_no_options', [['libcrafter', 14401],['PcapPlusPlus', 327],['libtins', 385],['libpcap', 201]]);
draw_graphic('Graphic view', 'tcp_with_options', [['libcrafter', 24176],['PcapPlusPlus', 335],['libtins', 508],['libpcap', 154]]);
draw_graphic('Graphic view', 'dns', [['libcrafter', 15923],['PcapPlusPlus', 425],['libtins', 466],['libpcap', 50]]);
}
</script>
<h1>Benchmarks</h1>
<p>I used <a href="https://github.com/mfontanini/packet-capture-benchmarks">Matias Fontanini's packet-capture-benchmarks project</a> to compare the performance of PcapPlusPlus with other similar C++ libraries (libtins and libcrafter)</p>
<h2>Testing environment</h2>
<p>I ran all 3 benchmarks provided in packet-capture-benchmarks on the following environment:</p>
<ul>
<li>Linux Ubuntu 16.04 64-bit running as a VirtualBox VM</li>
<li>Compiler is GCC 5.4.0</li>
<li>Host platform is a dual-core Intel Core i5 760 2.8GHz with 8GB RAM system running Windows 10 64-bit</li>
</ul>
<p>The benchmark application can be found in <a href="examples.html#benchmark">PcapPlusPlus examples</a></p>
<h2>Tested libraries</h2>
<p>I decided to compare PcapPlusPlus only to similar C++ libraries such as <a href="https://libtins.github.io/">libtins</a> and <a href="https://code.google.com/archive/p/libcrafter/">libcrafter</a>. 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):</p>
<ul>
<li>libpcap 1.8.1</li>
<li>PcapPlusPlus - <a href="https://github.com/seladb/PcapPlusPlus/tree/f6e04a747679d3923687fe4c964c230cd46b0e98">commit f6e04a7</a></li>
<li>libtins - <a href="https://github.com/mfontanini/libtins/tree/f4635a696e7f13d946c31e1ff2599e900f804d47">commit f4635a6</a></li>
<li>libcrafter - <a href="https://github.com/pellegre/libcrafter/tree/3db70ab6fd62ade25de7328aaf8e9ba92696c92e">commit 3db70ab</a></li>
</ul>
<h2>Test results</h2>
<h2>Benchmark #1 - Interpretting TCP</h2>
<table>
<thead>
<tr>
<th>Library</th>
<th align="right">Time taken(seconds)</th>
<th align="right">Packets per second</th>
</tr>
</thead>
<tbody>
<tr>
<td>libpcap</td>
<td align="right">0.201</td>
<td align="right">2487562</td>
</tr>
<tr>
<td><strong>PcapPlusPlus</strong></td>
<td align="right"><strong>0.327</strong></td>
<td align="right"><strong>1529051</strong></td>
</tr>
<tr>
<td>libtins</td>
<td align="right">0.385</td>
<td align="right">1298701</td>
</tr>
<tr>
<td>libcrafter</td>
<td align="right">14.401</td>
<td align="right">34719</td>
</tr>
</tbody>
</table>
<div id="tcp_no_options"></div>
<hr>
<p>As you can see PcapPlusPlus is <strong>~15% faster</strong> than libtins and <strong>~x44 faster</strong> than libcrafter</p>
<h2>Benchmark #2 - Interpretting TCP + TCP Options</h2>
<table>
<thead>
<tr>
<th>Library</th>
<th align="right">Time taken(seconds)</th>
<th align="right">Packets per second</th>
</tr>
</thead>
<tbody>
<tr>
<td>libpcap</td>
<td align="right">0.154</td>
<td align="right">3246753</td>
</tr>
<tr>
<td><strong>PcapPlusPlus</strong></td>
<td align="right"><strong>0.335</strong></td>
<td align="right"><strong>1492537</strong></td>
</tr>
<tr>
<td>libtins</td>
<td align="right">0.508</td>
<td align="right">984251</td>
</tr>
<tr>
<td>libcrafter</td>
<td align="right">24.176</td>
<td align="right">20681</td>
</tr>
</tbody>
</table>
<div id="tcp_with_options"></div>
<hr>
<p>As you can see PcapPlusPlus is <strong>~35% faster</strong> than libtins and <strong>~x72 faster</strong> than libcrafter</p>
<h2>Benchmark #3 - Interpretting DNS</h2>
<table>
<thead>
<tr>
<th>Library</th>
<th align="right">Time taken(seconds)</th>
<th align="right">Packets per second</th>
</tr>
</thead>
<tbody>
<tr>
<td>libpcap</td>
<td align="right">0.050</td>
<td align="right">10000000</td>
</tr>
<tr>
<td><strong>PcapPlusPlus</strong></td>
<td align="right"><strong>0.425</strong></td>
<td align="right"><strong>1176470</strong></td>
</tr>
<tr>
<td>libtins</td>
<td align="right">0.466</td>
<td align="right">1072961</td>
</tr>
<tr>
<td>libcrafter</td>
<td align="right">15.923</td>
<td align="right">31401</td>
</tr>
</tbody>
</table>
<div id="dns"></div>
<hr>
<p>As you can see PcapPlusPlus is <strong>~8% faster</strong> than libtins and <strong>~x37 faster</strong> than libcrafter</p>