aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c39
-rw-r--r--example/reader_util.h3
2 files changed, 42 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 56eb9c7d7..f18dd3361 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -2453,6 +2453,7 @@ static void node_print_known_proto_walker(const void *node,
static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int depth, void *user_data) {
struct ndpi_flow_info *flow = *(struct ndpi_flow_info **) node;
u_int16_t thread_id = *((u_int16_t *) user_data), proto, fpc_proto;
+ ndpi_protocol_category_t category;
(void)depth;
@@ -2478,6 +2479,8 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
fpc_proto = flow->fpc.proto.app_protocol ? flow->fpc.proto.app_protocol : flow->fpc.proto.master_protocol;
fpc_proto = ndpi_map_user_proto_id_to_ndpi_id(ndpi_thread_info[thread_id].workflow->ndpi_struct, fpc_proto);
+ category = flow->detected_protocol.category;
+
ndpi_thread_info[thread_id].workflow->stats.protocol_counter[proto] += flow->src2dst_packets + flow->dst2src_packets;
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]++;
@@ -2487,6 +2490,9 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
ndpi_thread_info[thread_id].workflow->stats.fpc_protocol_counter_bytes[fpc_proto] += flow->src2dst_bytes + flow->dst2src_bytes;
ndpi_thread_info[thread_id].workflow->stats.fpc_protocol_flows[fpc_proto]++;
ndpi_thread_info[thread_id].workflow->stats.fpc_flow_confidence[flow->fpc.confidence]++;
+ ndpi_thread_info[thread_id].workflow->stats.category_counter[category] += flow->src2dst_packets + flow->dst2src_packets;
+ ndpi_thread_info[thread_id].workflow->stats.category_counter_bytes[category] += flow->src2dst_bytes + flow->dst2src_bytes;
+ ndpi_thread_info[thread_id].workflow->stats.category_flows[category]++;
}
}
@@ -4072,6 +4078,12 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
cumulative_stats.fpc_protocol_flows[i] += ndpi_thread_info[thread_id].workflow->stats.fpc_protocol_flows[i];
}
+ for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
+ cumulative_stats.category_counter[i] += ndpi_thread_info[thread_id].workflow->stats.category_counter[i];
+ cumulative_stats.category_counter_bytes[i] += ndpi_thread_info[thread_id].workflow->stats.category_counter_bytes[i];
+ cumulative_stats.category_flows[i] += ndpi_thread_info[thread_id].workflow->stats.category_flows[i];
+ }
+
cumulative_stats.ndpi_flow_count += ndpi_thread_info[thread_id].workflow->stats.ndpi_flow_count;
cumulative_stats.flow_count[0] += ndpi_thread_info[thread_id].workflow->stats.flow_count[0];
cumulative_stats.flow_count[1] += ndpi_thread_info[thread_id].workflow->stats.flow_count[1];
@@ -4519,6 +4531,33 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
}
}
+ if(!quiet_mode) {
+ printf("\n\nCategory statistics:\n");
+
+ for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
+ if(cumulative_stats.category_counter[i] > 0) {
+ printf("\t%-20s packets: %-13llu bytes: %-13llu "
+ "flows: %-13llu\n",
+ ndpi_category_get_name(ndpi_thread_info[0].workflow->ndpi_struct, i),
+ (long long unsigned int)cumulative_stats.category_counter[i],
+ (long long unsigned int)cumulative_stats.category_counter_bytes[i],
+ (long long unsigned int)cumulative_stats.category_flows[i]);
+ }
+ }
+ }
+ if(results_file) {
+ fprintf(results_file, "\n");
+ for(i = 0; i < NDPI_PROTOCOL_NUM_CATEGORIES; i++) {
+ if(cumulative_stats.category_counter[i] > 0) {
+ fprintf(results_file, "%-20s %13llu %-13llu %-13llu\n",
+ ndpi_category_get_name(ndpi_thread_info[0].workflow->ndpi_struct, i),
+ (long long unsigned int)cumulative_stats.category_counter[i],
+ (long long unsigned int)cumulative_stats.category_counter_bytes[i],
+ (long long unsigned int)cumulative_stats.category_flows[i]);
+ }
+ }
+ }
+
printRiskStats();
printFlowsStats();
diff --git a/example/reader_util.h b/example/reader_util.h
index b755d3ab6..bbd1ac949 100644
--- a/example/reader_util.h
+++ b/example/reader_util.h
@@ -378,6 +378,9 @@ typedef struct ndpi_stats {
u_int64_t *fpc_protocol_counter;
u_int64_t *fpc_protocol_counter_bytes;
u_int32_t *fpc_protocol_flows;
+ u_int64_t category_counter[NDPI_PROTOCOL_NUM_CATEGORIES];
+ u_int64_t category_counter_bytes[NDPI_PROTOCOL_NUM_CATEGORIES];
+ u_int32_t category_flows[NDPI_PROTOCOL_NUM_CATEGORIES];
u_int32_t ndpi_flow_count;
u_int32_t flow_count[3];
u_int64_t tcp_count, udp_count;