nemea-common 1.6.3
Data Structures | Macros | Typedefs
real_time_sending.h File Reference

Delaying sending of records according to their original timestamps. More...

#include <sys/time.h>

Go to the source code of this file.

Data Structures

struct  rt_state_s
 State of real-time delaying (for real-time sending). More...
 

Macros

#define RT_PAR_SET_DEFAULT   0
 
#define DEFAULT_POOL_SIZE   10
 
#define DEFAULT_INIT_TS_CNT   1000
 
#define DEFAULT_SAMPLE_RATE   100
 
#define DEFAULT_TS_DIFF_THRESHOLD   3.5
 
#define RT_INIT(rt_state, pool_size, init_timestamp_count, par_sample_rate, timestamp_diff_threshold, err_command)
 Initialization of real-time delaying (sending) state. If some initialization value is equal to RT_PAR_SET_DEFAULT, according parameter is then set to default value. First and last parameter is mandatory.
 
#define RT_DESTROY(rt_state)    free(rt_state.mins);
 Just frees allocated memory.
 
#define RT_CHECK_DELAY(record_counter, actual_timestamp, rt_state)
 Main delaying functionality At first it determines initial timestamp from n first flows. Then it checks after each sample if one second of data was send. If it was, then real-time is checked and sending is corrected by sleep (or not to sleep).
 

Typedefs

typedef struct rt_state_s rt_state_t
 State of real-time delaying (for real-time sending).
 

Detailed Description

Delaying sending of records according to their original timestamps.

Author
Pavel Krobot xkrob.nosp@m.o01@.nosp@m.cesne.nosp@m.t.cz
Date
2014

Definition in file real_time_sending.h.

Macro Definition Documentation

◆ DEFAULT_INIT_TS_CNT

#define DEFAULT_INIT_TS_CNT   1000

Definition at line 51 of file real_time_sending.h.

◆ DEFAULT_POOL_SIZE

#define DEFAULT_POOL_SIZE   10

Definition at line 50 of file real_time_sending.h.

◆ DEFAULT_SAMPLE_RATE

#define DEFAULT_SAMPLE_RATE   100

Definition at line 52 of file real_time_sending.h.

◆ DEFAULT_TS_DIFF_THRESHOLD

#define DEFAULT_TS_DIFF_THRESHOLD   3.5

Definition at line 53 of file real_time_sending.h.

◆ RT_CHECK_DELAY

#define RT_CHECK_DELAY ( record_counter,
actual_timestamp,
rt_state )

Main delaying functionality At first it determines initial timestamp from n first flows. Then it checks after each sample if one second of data was send. If it was, then real-time is checked and sending is corrected by sleep (or not to sleep).

Parameters
[in]record_counterCount of actually send records.
[in]actual_timestampTimestamp of actual record.
[in]Nameof identifier, which holds real-time delaying state structure.

Definition at line 130 of file real_time_sending.h.

◆ RT_DESTROY

#define RT_DESTROY ( rt_state)     free(rt_state.mins);

Just frees allocated memory.

Definition at line 119 of file real_time_sending.h.

◆ RT_INIT

#define RT_INIT ( rt_state,
pool_size,
init_timestamp_count,
par_sample_rate,
timestamp_diff_threshold,
err_command )
Value:
do { \
if (pool_size == RT_PAR_SET_DEFAULT){ \
rt_state.min_pool_size = DEFAULT_POOL_SIZE;\
} else { \
rt_state.min_pool_size = pool_size;\
} \
rt_state.mins = (uint32_t *) malloc (rt_state.min_pool_size * sizeof(uint32_t)); \
if (rt_state.mins == NULL){ \
err_command; \
} \
rt_state.act_min_cnt = 0; \
if (init_timestamp_count == RT_PAR_SET_DEFAULT){ \
rt_state.init_ts_count = DEFAULT_INIT_TS_CNT; \
} else { \
rt_state.init_ts_count = init_timestamp_count; \
} \
if (par_sample_rate == RT_PAR_SET_DEFAULT){ \
rt_state.sample_rate = DEFAULT_SAMPLE_RATE; \
} else { \
rt_state.sample_rate = par_sample_rate; \
} \
if (timestamp_diff_threshold == RT_PAR_SET_DEFAULT){ \
rt_state.ts_diff_threshold = DEFAULT_TS_DIFF_THRESHOLD; \
} else { \
rt_state.ts_diff_threshold = timestamp_diff_threshold; \
} \
rt_state.ts_diff_cnt = 0; \
rt_state.ts_diff_sum = 0; \
rt_state.ts_diff_total = 0; \
} while(0)
#define DEFAULT_INIT_TS_CNT
#define DEFAULT_POOL_SIZE
#define RT_PAR_SET_DEFAULT
#define DEFAULT_SAMPLE_RATE
#define DEFAULT_TS_DIFF_THRESHOLD

Initialization of real-time delaying (sending) state. If some initialization value is equal to RT_PAR_SET_DEFAULT, according parameter is then set to default value. First and last parameter is mandatory.

Parameters
[in]rt_stateName of identifier, which holds real-time delaying state structure.
[in]pool_sizeSize of pool for minimal timestamps to compute average minimal timestamp.
[in]init_timestamp_countFrom how many first flows should be minimal timestamp determined.
[in]par_sample_rateSets initial sample rate - says how offten should be timestamp difference checked.
[in]timestamp_diff_threshold"magic" value which represents change in timestamps of records in real traffic.
[in]err_commandCommand, which should be executed if malloc fails.

Definition at line 85 of file real_time_sending.h.

◆ RT_PAR_SET_DEFAULT

#define RT_PAR_SET_DEFAULT   0

Definition at line 48 of file real_time_sending.h.

Typedef Documentation

◆ rt_state_t

typedef struct rt_state_s rt_state_t

State of real-time delaying (for real-time sending).