static void printResults(u_int64_t tot_usec) { u_int32_t i; printf("\x1b[2K\n"); printf("pcap file contains\n"); printf("\tIP packets: \x1b[33m%-13llu\x1b[0m of %llu packets total\n", (long long unsigned int)ip_packet_count, (long long unsigned int)raw_packet_count); printf("\tIP bytes: \x1b[34m%-13llu\x1b[0m\n", (long long unsigned int)total_bytes); printf("\tUnique flows: \x1b[36m%-13u\x1b[0m\n", ndpi_flow_count); if(tot_usec > 0) { char buf[32], buf1[32]; float t = (float)(ip_packet_count*1000000)/(float)tot_usec; float b = (float)(total_bytes * 8 *1000000)/(float)tot_usec; printf("\tnDPI throughout: \x1b[36m%s pps / %s/sec\x1b[0m\n", formatPackets(t, buf), formatTraffic(b, 1, buf1)); } for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_proto_guess_walker, NULL); if(enable_protocol_guess) printf("\tGuessed flow protocols: \x1b[35m%-13u\x1b[0m\n", guessed_flow_protocols); printf("\n\nDetected protocols:\n"); for (i = 0; i <= ndpi_get_num_supported_protocols(ndpi_struct); i++) { if(protocol_counter[i] > 0) { printf("\t\x1b[31m%-20s\x1b[0m packets: \x1b[33m%-13llu\x1b[0m bytes: \x1b[34m%-13llu\x1b[0m " "flows: \x1b[36m%-13u\x1b[0m\n", ndpi_get_proto_name(ndpi_struct, i), (long long unsigned int)protocol_counter[i], (long long unsigned int)protocol_counter_bytes[i], protocol_flows[i]); } } if(verbose && (protocol_counter[0] > 0)) { printf("\n"); for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_print_known_proto_walker, NULL); printf("\n\nUndetected flows:\n"); for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_print_unknown_proto_walker, NULL); } printf("\n\n"); }
static void printResults(void) { u_int32_t i, j; printf("\x1b[2K\n"); printf("pcap file contains\n"); printf("\tip packets: \x1b[33m%-13llu\x1b[0m of %llu packets total\n", (long long unsigned int)ip_packet_count, (long long unsigned int)raw_packet_count); printf("\tip bytes: \x1b[34m%-13llu\x1b[0m\n", (long long unsigned int)total_bytes); printf("\tunique flows: \x1b[36m%-13u\x1b[0m\n", ndpi_flow_count); ndpi_twalk(ndpi_flows_root, node_proto_guess_walker, NULL); if(enable_protocol_guess) printf("\tguessed flow protocols: \x1b[35m%-13u\x1b[0m\n", guessed_flow_protocols); printf("\n\ndetected protocols:\n"); for (i = 0; i <= ndpi_get_num_supported_protocols(ndpi_struct); i++) { if (protocol_counter[i] > 0) { printf("\t\x1b[31m%-20s\x1b[0m packets: \x1b[33m%-13llu\x1b[0m bytes: \x1b[34m%-13llu\x1b[0m " "flows: \x1b[36m%-13u\x1b[0m\n", ndpi_get_proto_name(ndpi_struct, i), (long long unsigned int)protocol_counter[i], (long long unsigned int)protocol_counter_bytes[i], protocol_flows[i]); } } if(verbose && (protocol_counter[0] > 0)) { printf("\n\nundetected flows:\n"); ndpi_twalk(ndpi_flows_root, node_print_unknown_proto_walker, NULL); } if (1) { flow_info_file = fopen(flow_info_file_name, "wb"); fputs("source_ip source_port dest_ip dest_port first_packet_time l4_proto detect_proto packets bytes\n", flow_info_file); ndpi_twalk(ndpi_flows_root, node_output_flow_info_walker, NULL); fclose(flow_info_file); } printf("\n\n"); }