-
Notifications
You must be signed in to change notification settings - Fork 51
Parallel Libtrace HOWTO
Libtrace4 introduces a new parallel API which is designed to easily support using multiple threads to perform packet processing and analysis tasks. Complicated issues relating to concurrency, buffer management, hashing and combining results are handled internally by the libtrace library so developers only need to concentrate on writing code to process packets and report results, while still being able to take advantage of multiple cores and/or pipelines.
The new parallel API introduced in libtrace4 is quite different to (and a bit more complex than) the libtrace3 API. This guide aims to incrementally teach the new concepts and functions that appear in parallel libtrace and will hopefully help make it easier for you to get started. We will assume that you are already familiar with how the current libtrace3 API functions: see the original Libtrace tutorial if you need to get up to speed.
We recommend that you read through the following sections, in order, before starting to write any parallel libtrace code. Apologies for the length of this HOWTO -- this parallel programming stuff can be a bit complex at times, so I'm trying to make sure the documentation covers everything you might need to know.
- Conceptual Overview
- Example Scenario
- Processing Threads
- Start Callback
- Packet Callback
- Stop Callback
- Reporter Thread
- Start Reporter Callback
- Result Callback
- Callback Sets
- Writing a Main Function
- Ticks
- Custom Messages
- Pausing and Resuming Callbacks
- First Packet Callback
- Meta Packet Callback
- Stopping
- Useful Examples