diff options
author | Luca <deri@ntop.org> | 2019-08-27 12:56:15 +0200 |
---|---|---|
committer | Luca <deri@ntop.org> | 2019-08-27 12:56:15 +0200 |
commit | 2acffb41638233f6576663b77bfdd7574014fd1d (patch) | |
tree | 797ee5b4e550a15f4d7d4299c9dccf929aec1cf6 /example/ndpiReader.c | |
parent | b837f3753d247b0653b22383eabe8525f684ab29 (diff) |
Initial work towards traffic classification
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index aad1f9eb9..22af8cfa7 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -3353,6 +3353,32 @@ void serializerUnitTest() { /* *********************************************** */ +void analyzeUnitTest() { + struct ndpi_analyze_struct *s = ndpi_init_data_analysis(32); + u_int32_t i; + + for(i=0; i<256; i++) { + ndpi_data_add_value(s, rand()*i); + // ndpi_data_add_value(s, i+1); + } + + // ndpi_data_print_window_values(s); + +#ifdef RUN_DATA_ANALYSIS_THEN_QUIT + printf("Average: [all: %f][window: %f]\n", + ndpi_data_average(s), ndpi_data_window_average(s)); + printf("Entropy: %f\n", ndpi_entropy(s)); +#endif + + ndpi_free_data_analysis(s); + +#ifdef RUN_DATA_ANALYSIS_THEN_QUIT + exit(0); +#endif +} + +/* *********************************************** */ + /** * @brief Produce bpf filter to filter ports and hosts * in order to remove a peak in terms of number of packets @@ -3929,7 +3955,8 @@ int orginal_main(int argc, char **argv) { /* Internal checks */ automataUnitTest(); serializerUnitTest(); - + // analyzeUnitTest(); + gettimeofday(&startup_time, NULL); ndpi_info_mod = ndpi_init_detection_module(); |