Implemented ndpi_process_partial_detection() API call to handle partial matches due to the nDPI specified configuration
This commit is contained in:
+15
-16
@@ -914,11 +914,10 @@ static void node_proto_guess_walker(const void *node, ndpi_VISIT which, int dept
|
||||
struct ndpi_flow_info *flow = *(struct ndpi_flow_info **) node;
|
||||
u_int16_t thread_id = *((u_int16_t *) user_data);
|
||||
|
||||
if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
|
||||
if((!flow->detection_completed) && flow->ndpi_flow) {
|
||||
if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */
|
||||
if((!flow->detection_completed) && flow->ndpi_flow)
|
||||
flow->detected_protocol = ndpi_detection_giveup(ndpi_thread_info[0].workflow->ndpi_struct, flow->ndpi_flow, enable_protocol_guess);
|
||||
}
|
||||
|
||||
|
||||
process_ndpi_collected_info(ndpi_thread_info[thread_id].workflow, flow);
|
||||
|
||||
ndpi_thread_info[thread_id].workflow->stats.protocol_counter[flow->detected_protocol.app_protocol] += flow->src2dst_packets + flow->dst2src_packets;
|
||||
@@ -1956,7 +1955,7 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
|
||||
printf("\tPeak Memory: %-13s\n", formatBytes(max_ndpi_memory, buf, sizeof(buf)));
|
||||
printf("\tSetup Time: %lu msec\n", (unsigned long)(setup_time_usec/1000));
|
||||
printf("\tPacket Processing Time: %lu msec\n", (unsigned long)(processing_time_usec/1000));
|
||||
|
||||
|
||||
if(!json_flag) {
|
||||
printf("\nTraffic statistics:\n");
|
||||
printf("\tEthernet bytes: %-13llu (includes ethernet CRC/IFC/trailer)\n",
|
||||
@@ -1992,10 +1991,10 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
|
||||
float t = (float)(cumulative_stats.ip_packet_count*1000000)/(float)processing_time_usec;
|
||||
float b = (float)(cumulative_stats.total_wire_bytes * 8 *1000000)/(float)processing_time_usec;
|
||||
float traffic_duration;
|
||||
|
||||
|
||||
if(live_capture) traffic_duration = processing_time_usec;
|
||||
else traffic_duration = (pcap_end.tv_sec*1000000 + pcap_end.tv_usec) - (pcap_start.tv_sec*1000000 + pcap_start.tv_usec);
|
||||
|
||||
|
||||
printf("\tnDPI throughput: %s pps / %s/sec\n", formatPackets(t, buf), formatTraffic(b, 1, buf1));
|
||||
t = (float)(cumulative_stats.ip_packet_count*1000000)/(float)traffic_duration;
|
||||
b = (float)(cumulative_stats.total_wire_bytes * 8 *1000000)/(float)traffic_duration;
|
||||
@@ -2005,7 +2004,7 @@ static void printResults(u_int64_t processing_time_usec, u_int64_t setup_time_us
|
||||
strftime(when, sizeof(when), "%d/%b/%Y %H:%M:%S", localtime(&pcap_end.tv_sec));
|
||||
printf("\tAnalysis end: %s\n", when);
|
||||
printf("\tTraffic throughput: %s pps / %s/sec\n", formatPackets(t, buf), formatTraffic(b, 1, buf1));
|
||||
printf("\tTraffic duration: %.3f sec\n", traffic_duration/1000000);
|
||||
printf("\tTraffic duration: %.3f sec\n", traffic_duration/1000000);
|
||||
}
|
||||
|
||||
if(enable_protocol_guess)
|
||||
@@ -2490,7 +2489,7 @@ static void ndpi_process_packet(u_char *args,
|
||||
if(memcmp(packet, packet_checked, header->caplen) != 0)
|
||||
printf("INTERNAL ERROR: ingress packet was modified by nDPI: this should not happen [thread_id=%u, packetId=%lu, caplen=%u]\n",
|
||||
thread_id, (unsigned long)ndpi_thread_info[thread_id].workflow->stats.raw_packet_count, header->caplen);
|
||||
|
||||
|
||||
if((pcap_end.tv_sec-pcap_start.tv_sec) > pcap_analysis_duration) {
|
||||
int i;
|
||||
u_int64_t processing_time_usec, setup_time_usec;
|
||||
@@ -2498,7 +2497,7 @@ static void ndpi_process_packet(u_char *args,
|
||||
gettimeofday(&end, NULL);
|
||||
processing_time_usec = end.tv_sec*1000000 + end.tv_usec - (begin.tv_sec*1000000 + begin.tv_usec);
|
||||
setup_time_usec = begin.tv_sec*1000000 + begin.tv_usec - (startup_time.tv_sec*1000000 + startup_time.tv_usec);
|
||||
|
||||
|
||||
printResults(processing_time_usec, setup_time_usec);
|
||||
|
||||
for(i=0; i<ndpi_thread_info[thread_id].workflow->prefs.num_roots; i++) {
|
||||
@@ -2515,7 +2514,7 @@ static void ndpi_process_packet(u_char *args,
|
||||
memcpy(&pcap_start, &pcap_end, sizeof(pcap_start));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Leave the free as last statement to avoid crashes when ndpi_detection_giveup()
|
||||
is called above by printResults()
|
||||
*/
|
||||
@@ -2541,7 +2540,7 @@ void * processing_thread(void *_thread_id) {
|
||||
#if defined(linux) && defined(HAVE_PTHREAD_SETAFFINITY_NP)
|
||||
if(core_affinity[thread_id] >= 0) {
|
||||
cpu_set_t cpuset;
|
||||
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(core_affinity[thread_id], &cpuset);
|
||||
|
||||
@@ -2559,7 +2558,7 @@ void * processing_thread(void *_thread_id) {
|
||||
struct rte_mbuf *bufs[BURST_SIZE];
|
||||
u_int16_t num = rte_eth_rx_burst(dpdk_port_id, 0, bufs, BURST_SIZE);
|
||||
u_int i;
|
||||
|
||||
|
||||
if(num == 0) {
|
||||
usleep(1);
|
||||
continue;
|
||||
@@ -3273,8 +3272,8 @@ int orginal_main(int argc, char **argv) {
|
||||
#else
|
||||
int main(int argc, char **argv) {
|
||||
#endif
|
||||
int i;
|
||||
|
||||
int i;
|
||||
|
||||
if(ndpi_get_api_version() != NDPI_API_VERSION) {
|
||||
printf("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n");
|
||||
return(-1);
|
||||
@@ -3284,7 +3283,7 @@ int orginal_main(int argc, char **argv) {
|
||||
|
||||
gettimeofday(&startup_time, NULL);
|
||||
ndpi_info_mod = ndpi_init_detection_module();
|
||||
|
||||
|
||||
if(ndpi_info_mod == NULL) return -1;
|
||||
|
||||
memset(ndpi_thread_info, 0, sizeof(ndpi_thread_info));
|
||||
|
||||
Reference in New Issue
Block a user