diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiReader.c | 19 | ||||
-rw-r--r-- | example/reader_util.c | 1 | ||||
-rw-r--r-- | example/reader_util.h | 2 |
3 files changed, 22 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index f8e55c484..de1c9325f 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1398,6 +1398,12 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa flow->detected_protocol) ? "Encrypted" : "ClearText"); fprintf(out, "[Confidence: %s]", ndpi_confidence_get_name(flow->confidence)); + /* If someone wants to have the num_dissector_calls variable per flow, he can print it here. + Disabled by default to avoid too many diffs in the unit tests... + */ +#if 0 + fprintf(out, "[Num calls: %d]", flow->num_dissector_calls); +#endif if(flow->detected_protocol.category != 0) fprintf(out, "[cat: %s/%u]", @@ -1977,6 +1983,7 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept ndpi_thread_info[thread_id].workflow->stats.protocol_counter_bytes[proto] += flow->src2dst_bytes + flow->dst2src_bytes; ndpi_thread_info[thread_id].workflow->stats.protocol_flows[proto]++; ndpi_thread_info[thread_id].workflow->stats.flow_confidence[flow->confidence]++; + ndpi_thread_info[thread_id].workflow->stats.num_dissector_calls += flow->num_dissector_calls; } } @@ -3482,6 +3489,8 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us for(i = 0; i < sizeof(cumulative_stats.flow_confidence)/sizeof(cumulative_stats.flow_confidence[0]); i++) cumulative_stats.flow_confidence[i] += ndpi_thread_info[thread_id].workflow->stats.flow_confidence[i]; + + cumulative_stats.num_dissector_calls += ndpi_thread_info[thread_id].workflow->stats.num_dissector_calls; } if(cumulative_stats.total_wire_bytes == 0) @@ -3589,6 +3598,11 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us printf("\tConfidence: %-10s %-13llu (flows)\n", ndpi_confidence_get_name(i), (long long unsigned int)cumulative_stats.flow_confidence[i]); } + + if(cumulative_stats.ndpi_flow_count) + printf("\tNum dissector calls: %-13llu (%.2f diss/flow)\n", + (long long unsigned int)cumulative_stats.num_dissector_calls, + cumulative_stats.num_dissector_calls / (float)cumulative_stats.ndpi_flow_count); } if(results_file) { @@ -3615,6 +3629,11 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us (long long unsigned int)cumulative_stats.flow_confidence[i]); } + if(cumulative_stats.ndpi_flow_count) + fprintf(results_file, "Num dissector calls: %llu (%.2f diss/flow)\n", + (long long unsigned int)cumulative_stats.num_dissector_calls, + cumulative_stats.num_dissector_calls / (float)cumulative_stats.ndpi_flow_count); + fprintf(results_file, "\n"); } diff --git a/example/reader_util.c b/example/reader_util.c index a81f87f6b..91eeb0775 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1050,6 +1050,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl flow->risk_str = ndpi_strdup(s); flow->confidence = flow->ndpi_flow->confidence; + flow->num_dissector_calls = flow->ndpi_flow->num_dissector_calls; ndpi_snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s", flow->ndpi_flow->host_server_name); diff --git a/example/reader_util.h b/example/reader_util.h index c2a152d38..4f4ef68fe 100644 --- a/example/reader_util.h +++ b/example/reader_util.h @@ -203,6 +203,7 @@ typedef struct ndpi_flow_info { // result only, not used for flow identification ndpi_protocol detected_protocol; ndpi_confidence_t confidence; + u_int16_t num_dissector_calls; // Flow data analysis pkt_timeval src2dst_last_pkt_time, dst2src_last_pkt_time, flow_last_pkt_time; @@ -296,6 +297,7 @@ typedef struct ndpi_stats { u_int16_t max_packet_len; u_int64_t dpi_packet_count[3]; u_int64_t flow_confidence[NDPI_CONFIDENCE_MAX]; + u_int64_t num_dissector_calls; } ndpi_stats_t; |