43 #ifndef LIBTRACE_PARALLEL_H
44 #define LIBTRACE_PARALLEL_H
95 signed char schars[8];
96 unsigned char uchars[8];
1239 const struct timeval **tv);
1423 #endif // LIBTRACE_PARALLEL_H
void(* fn_cb_usermessage)(libtrace_t *libtrace, libtrace_thread_t *t, void *global, void *tls, int mesg, libtrace_generic_t data, libtrace_thread_t *sender)
Callback for handling any user-defined message types.
Definition: libtrace_parallel.h:547
void(* read)(libtrace_t *, libtrace_combine_t *)
Read as many results as possible from the trace.
Definition: libtrace_parallel.h:355
DLLEXPORT int trace_get_perpkt_threads(libtrace_t *t)
Returns the number of processing threads that have been created for a given trace.
Definition: trace_parallel.c:285
void(* destroy)(libtrace_t *, libtrace_combine_t *)
Called when the trace ends, clean up any memory allocated by the initialise function.
Definition: libtrace_parallel.h:336
This message is sent to each thread when the thread ends and will trigger the stopping callback for t...
Definition: libtrace_parallel.h:154
const libtrace_combine_t combiner_sorted
Like classic Google Map/Reduce, the results are sorted in ascending order based on their key...
Definition: combiner_sorted.c:114
DLLEXPORT int trace_set_reporter_polling(libtrace_t *trace, bool polling)
Enables or disables polling of the reporter result queue.
Definition: trace_parallel.c:2485
DLLEXPORT bool trace_is_parallel(libtrace_t *libtrace)
Check if libtrace is directly reading from multiple queues from within the capture format (such as a ...
Definition: trace_parallel.c:1671
uint64_t last_ts_tick
The last timestamp tick that we saw, so we can avoid duplicating any ticks that are published...
Definition: libtrace_parallel.h:396
DLLEXPORT int trace_ppause(libtrace_t *libtrace)
Pauses a trace previously started with trace_pstart()
Definition: trace_parallel.c:1994
DLLEXPORT int libtrace_thread_try_get_message(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_message_t *message)
Read a message from a thread in a non-blocking fashion.
Definition: trace_parallel.c:2298
result_types
Types of results.
Definition: libtrace_parallel.h:980
Use a hash which is uni-directional across TCP and UDP flows, such that the opposing directions of th...
Definition: libtrace_parallel.h:283
DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t value, int type)
Publish a result to the reporter thread (via the combiner)
Definition: trace_parallel.c:2360
DLLEXPORT int trace_set_reporter_thold(libtrace_t *trace, size_t thold)
Set the number of results that are required in the result queue before a MESSAGE_POST_REPORTER is sen...
Definition: trace_parallel.c:2492
void * queues
Data storage for all the combiner threads.
Definition: libtrace_parallel.h:386
The methods we use to combine the results from multiple processing threads into a single output...
Definition: libtrace_parallel.h:320
DLLEXPORT int trace_set_hasher_polling(libtrace_t *trace, bool polling)
Enables or disables polling of the hasher queue.
Definition: trace_parallel.c:2478
A libtrace result is ready, this will trigger the result callback for the reporter thread...
Definition: libtrace_parallel.h:141
DLLEXPORT int trace_set_burst_size(libtrace_t *trace, size_t size)
The number of packets to batch together for processing internally by libtrace.
Definition: trace_parallel.c:2464
void(* read_final)(libtrace_t *, libtrace_combine_t *)
Called when the trace is finished to flush the final results to the reporter thread.
Definition: libtrace_parallel.h:373
DLLEXPORT int trace_set_tick_interval(libtrace_t *trace, size_t millisec)
Set the interval between tick messages in milliseconds.
Definition: trace_parallel.c:2422
This message is sent to each thread when the thread transitions into a paused state from a running st...
Definition: libtrace_parallel.h:173
Trace file processing library header.
A libtrace input trace.
Definition: libtrace_int.h:306
DLLEXPORT int trace_set_packet_cb(libtrace_callback_set_t *cbset, fn_cb_packet handler)
Registers a packet callback against a callback set.
Definition: trace_parallel.c:1948
DLLEXPORT int trace_set_configuration_file(libtrace_t *trace, FILE *file)
Sets configuration from a file.
Definition: trace_parallel.c:2587
libtrace_thread_t * sender
The thread that sent the message.
Definition: libtrace_parallel.h:112
DLLEXPORT int trace_pstart(libtrace_t *libtrace, void *global_blob, libtrace_callback_set_t *per_packet_cbs, libtrace_callback_set_t *reporter_cbs)
Start or restart an input trace in the parallel libtrace framework.
Definition: trace_parallel.c:1677
DLLEXPORT void libtrace_make_packet_safe(libtrace_packet_t *pkt)
Makes a packet safe, preventing the packet from becoming invalid after a pausing a trace...
Definition: trace_parallel.c:422
const libtrace_combine_t combiner_unordered
Takes unordered (or ordered) input and produces unordered output.
Definition: combiner_unordered.c:95
DLLEXPORT int trace_set_tick_count(libtrace_t *trace, size_t count)
Set the number of packets to be read between tick messages.
Definition: trace_parallel.c:2429
uint64_t key
The unique key for the result.
Definition: libtrace_parallel.h:117
All message codes at or above this value represent custom user-defined messages and will trigger the ...
Definition: libtrace_parallel.h:254
DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet)
Decrements the internal reference counter for a packet.
Definition: trace_parallel.c:2619
DLLEXPORT int trace_set_result_cb(libtrace_callback_set_t *cbset, fn_cb_result handler)
Registers a result callback against a callback set.
Definition: trace_parallel.c:1972
void(* publish)(libtrace_t *, int thread_id, libtrace_combine_t *, libtrace_result_t *)
Receive a result from a processing thread.
Definition: libtrace_parallel.h:344
int code
The message code, as defined in enum libtrace_messages.
Definition: libtrace_parallel.h:110
The result is a tick timestamp.
Definition: libtrace_parallel.h:995
DLLEXPORT int trace_set_hasher(libtrace_t *trace, enum hasher_types type, fn_hasher hasher, void *data)
Set the hasher function for a parallel trace.
Definition: trace_parallel.c:2158
DLLEXPORT int trace_message_perpkts(libtrace_t *libtrace, libtrace_message_t *message)
Send a message to all processing threads.
Definition: trace_parallel.c:2339
DLLEXPORT int trace_get_first_packet(libtrace_t *libtrace, libtrace_thread_t *t, const libtrace_packet_t **packet, const struct timeval **tv)
Returns the first packet read by a processing thread since the source trace was last started or resta...
Definition: trace_parallel.c:1055
DLLEXPORT int trace_post_reporter(libtrace_t *libtrace)
Post a message to the reporter thread requesting that it check for more results.
Definition: trace_parallel.c:2332
DLLEXPORT libtrace_info_t * trace_get_information(libtrace_t *libtrace)
Provides some basic information about a trace based on its input format.
Definition: trace_parallel.c:2630
This message is sent to each thread when the thread transitions from a paused state to a running stat...
Definition: libtrace_parallel.h:163
Definition: libtrace_int.h:289
Sent to per-packet threads periodically after the configured time interval has passed.
Definition: libtrace_parallel.h:228
struct libtrace_message_t libtrace_message_t
Structure describing a message that can be sent to a libtrace thread.
Use a hash which is bi-directional for TCP and UDP flows, such that packets with the same 5-tuple are...
Definition: libtrace_parallel.h:276
DLLEXPORT void trace_packet_set_hash(libtrace_packet_t *packet, uint64_t hash)
Sets the hash of a packet.
Definition: trace_parallel.c:2392
Structure describing a message that can be sent to a libtrace thread.
Definition: libtrace_parallel.h:109
A collection of types for convenience used in place of a simple void* to allow any type of data to be...
Definition: libtrace_parallel.h:62
An internal message for forcing another thread to stop.
Definition: libtrace_parallel.h:183
The result is a tick counter.
Definition: libtrace_parallel.h:1001
DLLEXPORT int trace_set_cache_size(libtrace_t *trace, size_t size)
Sets the maximum size of the freelist used to store empty packets and their memory buffers...
Definition: trace_parallel.c:2443
int max_threads
The maximum number of threads supported by a parallel trace.
Definition: libtrace_parallel.h:306
DLLEXPORT int libtrace_thread_get_message_count(libtrace_t *libtrace, libtrace_thread_t *t)
Check the number of messages waiting in a thread's message queue.
Definition: trace_parallel.c:2273
DLLEXPORT int trace_set_resuming_cb(libtrace_callback_set_t *cbset, fn_cb_dataless handler)
Registers a resuming callback against a callback set.
Definition: trace_parallel.c:1936
libtrace_packet_t *(* fn_cb_packet)(libtrace_t *libtrace, libtrace_thread_t *t, void *global, void *tls, libtrace_packet_t *packet)
A callback function triggered when a processing thread receives a packet.
Definition: libtrace_parallel.h:514
void(* fn_cb_dataless)(libtrace_t *libtrace, libtrace_thread_t *t, void *global, void *tls)
A callback function for any message that does not require any specific data, e.g. ...
Definition: libtrace_parallel.h:466
DLLEXPORT int trace_set_tracetime(libtrace_t *trace, bool tracetime)
Delays packets so they are played back in trace-time rather than as fast as possible (real-time)...
Definition: trace_parallel.c:2436
DLLEXPORT void trace_packet_set_order(libtrace_packet_t *packet, uint64_t order)
Sets the order of a packet.
Definition: trace_parallel.c:2388
This message is sent to each thread when it first starts and will trigger the starting callback for t...
Definition: libtrace_parallel.h:148
int type
Describes the type of result, see enum result_types.
Definition: libtrace_parallel.h:119
Any user-defined result codes should be at or above this value.
Definition: libtrace_parallel.h:1006
An internal message for forcing another thread to pause.
Definition: libtrace_parallel.h:178
uint64_t last_count_tick
The last counter tick that we saw, so we can avoid duplicating any ticks that are published...
Definition: libtrace_parallel.h:391
DLLEXPORT int trace_set_pausing_cb(libtrace_callback_set_t *cbset, fn_cb_dataless handler)
Registers a pausing callback against a callback set.
Definition: trace_parallel.c:1930
DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet)
Increments the internal reference counter for a packet.
Definition: trace_parallel.c:2609
This value indicates that the hasher is a custom user-defined function.
Definition: libtrace_parallel.h:289
libtrace_generic_t data
Additional data related to the message.
Definition: libtrace_parallel.h:111
DLLEXPORT int trace_set_tick_count_cb(libtrace_callback_set_t *cbset, fn_cb_tick handler)
Registers a tick counter callback against a callback set.
Definition: trace_parallel.c:1960
The libtrace packet structure.
Definition: libtrace.h:543
The result contains a pointer to a libtrace_packet_t.
Definition: libtrace_parallel.h:990
Information of this thread.
Definition: libtrace_int.h:198
void(* fn_cb_tick)(libtrace_t *libtrace, libtrace_thread_t *t, void *global, void *tls, uint64_t order)
A callback function for handling a tick message within a processing thread.
Definition: libtrace_parallel.h:495
DLLEXPORT int trace_set_user_message_cb(libtrace_callback_set_t *cbset, fn_cb_usermessage handler)
Registers a callback for custom user messages against a callback set.
Definition: trace_parallel.c:1978
An internal message for notifying the reporter thread that more results are available.
Definition: libtrace_parallel.h:205
const libtrace_combine_t combiner_ordered
Takes ordered input and produces ordered output.
Definition: combiner_ordered.c:262
Structure holding information about a result.
Definition: libtrace_parallel.h:116
void(* fn_cb_first_packet)(libtrace_t *libtrace, libtrace_thread_t *t, void *global, void *tls, libtrace_thread_t *sender)
A callback function for a first packet message seen by a processing thread.
Definition: libtrace_parallel.h:479
DLLEXPORT int trace_set_debug_state(libtrace_t *trace, bool debug_state)
Enable or disable debug output for parallel libtrace.
Definition: trace_parallel.c:2499
DLLEXPORT int trace_set_first_packet_cb(libtrace_callback_set_t *cbset, fn_cb_first_packet handler)
Registers a first packet callback against a callback set.
Definition: trace_parallel.c:1954
DLLEXPORT uint64_t trace_packet_get_order(libtrace_packet_t *packet)
Returns either the sequence number or erf timestamp of a packet.
Definition: trace_parallel.c:2380
DLLEXPORT libtrace_callback_set_t * trace_create_callback_set(void)
Create a callback set that can be used to define callbacks for parallel libtrace threads.
Definition: trace_parallel.c:254
Balance load across per-packet threads as best as possible, i.e the program does not care which threa...
Definition: libtrace_parallel.h:266
DLLEXPORT void libtrace_make_result_safe(libtrace_result_t *res)
Makes a result safe, preventing the result from becoming invalid after pausing a trace.
Definition: trace_parallel.c:442
DLLEXPORT int trace_set_tick_interval_cb(libtrace_callback_set_t *cbset, fn_cb_tick handler)
Registers a tick interval callback against a callback set.
Definition: trace_parallel.c:1966
Sent to per-packet threads once the configured number of packets are read from a trace.
Definition: libtrace_parallel.h:248
DLLEXPORT int trace_set_perpkt_threads(libtrace_t *trace, int nb)
Set the maximum number of perpkt threads to use in a trace.
Definition: trace_parallel.c:2408
DLLEXPORT int trace_set_thread_cache_size(libtrace_t *trace, size_t size)
This sets the maximum size of the freelist cache owned by each thread used to provide faster access t...
Definition: trace_parallel.c:2450
DLLEXPORT uint64_t trace_packet_get_hash(libtrace_packet_t *packet)
Returns the hash of a packet.
Definition: trace_parallel.c:2384
DLLEXPORT int trace_set_configuration(libtrace_t *trace, const char *str)
Sets the configuration of a trace based upon a comma separated list of key value pairs.
Definition: trace_parallel.c:2561
DLLEXPORT bool trace_has_dedicated_hasher(libtrace_t *libtrace)
Check if a dedicated hasher thread is being used.
Definition: trace_parallel.c:266
libtrace_generic_t value
The result value itself.
Definition: libtrace_parallel.h:118
A libtrace packet is ready, this will trigger the packet callback for the processing threads...
Definition: libtrace_parallel.h:136
DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t config)
Sets a combiner function for an input trace.
Definition: trace_parallel.c:2370
DLLEXPORT int trace_set_hasher_queue_size(libtrace_t *trace, size_t size)
Sets the maximum size of the buffer used between the single hasher thread and the packet processing t...
Definition: trace_parallel.c:2471
uint64_t(* fn_hasher)(const libtrace_packet_t *packet, void *data)
The definition for a hasher function, allowing matching packets to be directed to the correct thread ...
Definition: libtrace_parallel.h:415
DLLEXPORT int libtrace_thread_get_message(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_message_t *message)
Read a message from a thread in a blocking fashion.
Definition: trace_parallel.c:2285
This message is sent to each processing thread as soon as the first packet has been seen by any of th...
Definition: libtrace_parallel.h:197
void *(* fn_cb_starting)(libtrace_t *libtrace, libtrace_thread_t *t, void *global)
The starting callback for a processing or reporting thread.
Definition: libtrace_parallel.h:453
DLLEXPORT int trace_pstop(libtrace_t *libtrace)
Stops a parallel trace, causing all threads to exit as if an EOF has occurred.
Definition: trace_parallel.c:2127
hasher_types
The hasher types that are available to libtrace applications.
Definition: libtrace_parallel.h:260
DLLEXPORT int trace_get_perpkt_thread_id(libtrace_thread_t *thread)
Returns the internal unique ID for a packet processing thread.
Definition: trace_parallel.c:289
DLLEXPORT int trace_message_thread(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_message_t *message)
Send a message to a specific thread.
Definition: trace_parallel.c:2312
DLLEXPORT bool trace_has_reporter(libtrace_t *libtrace)
Checks if a trace is using a reporter thread.
Definition: trace_parallel.c:271
bool live
True if a live format (i.e.
Definition: libtrace_parallel.h:298
libtrace_messages
The libtrace_messages enum All libtrace messages are defined and documented here. ...
Definition: libtrace_parallel.h:132
DLLEXPORT int trace_set_stopping_cb(libtrace_callback_set_t *cbset, fn_cb_dataless handler)
Registers a stopping callback against a callback set.
Definition: trace_parallel.c:1942
int(* initialise)(libtrace_t *, libtrace_combine_t *)
Called at the start of the trace to allow data-structures to be initialised and allow functions to be...
Definition: libtrace_parallel.h:330
DLLEXPORT int trace_set_starting_cb(libtrace_callback_set_t *cbset, fn_cb_starting handler)
Registers a starting callback against a callback set.
Definition: trace_parallel.c:1924
DLLEXPORT void trace_free_packet(libtrace_t *libtrace, libtrace_packet_t *packet)
In a parallel trace, free a packet back to libtrace.
Definition: trace_parallel.c:2602
DLLEXPORT int trace_set_fixed_count(libtrace_t *trace, bool fixed)
Determines whether a trace is allowed to create additional packets beyond the cache size...
Definition: trace_parallel.c:2457
Definition: libtrace_parallel.h:292
libtrace_generic_t configuration
Configuration options, what this does is up to the combiner chosen.
Definition: libtrace_parallel.h:402
void(* fn_cb_result)(libtrace_t *libtrace, libtrace_thread_t *sender, void *global, void *tls, libtrace_result_t *result)
Callback for handling a result message.
Definition: libtrace_parallel.h:531
void(* pause)(libtrace_t *, libtrace_combine_t *)
Pause must make sure any queued results that contain packets are safe.
Definition: libtrace_parallel.h:381
DLLEXPORT int trace_message_reporter(libtrace_t *libtrace, libtrace_message_t *message)
Send a message to the reporter thread.
Definition: trace_parallel.c:2322
DLLEXPORT bool trace_has_finished(libtrace_t *libtrace)
Checks if a parallel trace has finished reading packets.
Definition: trace_parallel.c:2396
DLLEXPORT void trace_destroy_callback_set(libtrace_callback_set_t *cbset)
Destroys a callback set, freeing up any resources it was using.
Definition: trace_parallel.c:250
DLLEXPORT void trace_join(libtrace_t *trace)
Waits for a trace to finish and all threads to join.
Definition: trace_parallel.c:2219