aboutsummaryrefslogtreecommitdiff
path: root/example/reader_util.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2021-07-13 12:28:39 +0200
committerGitHub <noreply@github.com>2021-07-13 12:28:39 +0200
commitcccf794265dee24f25e16f21753972b20f7593c5 (patch)
treeeacc03e4e831ff7be5a0372c6e7cbbf386affeb3 /example/reader_util.c
parent96b71def49e46c7fbc7ba5fae3f355eb7d90151b (diff)
ndpiReader: add statistics about nDPI performance (#1240)
The goal is to have a (roughly) idea about how many packets nDPI needs to properly classify a flow. Log this information (and guessed flows number too) during unit tests, to keep track of improvements/regressions across commits.
Diffstat (limited to 'example/reader_util.c')
-rw-r--r--example/reader_util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index a1c11532e..89a3fcfff 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -893,6 +893,12 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
ndpi_tsearch(newflow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp); /* Add */
workflow->stats.ndpi_flow_count++;
+ if(*proto == IPPROTO_TCP)
+ workflow->stats.flow_count[0]++;
+ else if(*proto == IPPROTO_UDP)
+ workflow->stats.flow_count[1]++;
+ else
+ workflow->stats.flow_count[2]++;
*src = newflow->src_id, *dst = newflow->dst_id;
newflow->entropy.src2dst_pkt_len[newflow->entropy.src2dst_pkt_count] = l4_data_len;
@@ -1511,6 +1517,13 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
printf("%s()\n", __FUNCTION__);
#endif
+ if(proto == IPPROTO_TCP)
+ workflow->stats.dpi_packet_count[0]++;
+ else if(proto == IPPROTO_UDP)
+ workflow->stats.dpi_packet_count[1]++;
+ else
+ workflow->stats.dpi_packet_count[2]++;
+
flow->detected_protocol = ndpi_detection_process_packet(workflow->ndpi_struct, ndpi_flow,
iph ? (uint8_t *)iph : (uint8_t *)iph6,
ipsize, time_ms, src, dst);