aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2022-07-11 09:47:47 +0200
committerGitHub <noreply@github.com>2022-07-11 09:47:47 +0200
commitb4cb14ec1922b16a52c24324792f2bd7819f04a7 (patch)
treeb3b7d8f645c8d6c910f0b3c4f80bc3f891db452a /example/ndpiReader.c
parentdf599e5effaf1a76a89a014a1f488b27fa88cc52 (diff)
Keep track of how many dissectors calls we made for each flow (#1657)
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c19
1 files changed, 19 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");
}