diff --git a/include/ec_globals.h b/include/ec_globals.h index a58c8bd15..ffe5feb56 100644 --- a/include/ec_globals.h +++ b/include/ec_globals.h @@ -46,6 +46,7 @@ struct ec_conf { int connection_buffer; int connect_timeout; int sampling_rate; + int packet_update_count; int close_on_eof; int aggressive_dissectors; int skip_forwarded; diff --git a/share/etter.conf.v4 b/share/etter.conf.v4 index b54a702e0..c249e1ca0 100644 --- a/share/etter.conf.v4 +++ b/share/etter.conf.v4 @@ -37,6 +37,7 @@ connect_timeout = 5 # seconds [stats] sampling_rate = 50 # number of packets +packet_update_count = 50 # number of packets [misc] close_on_eof = 1 # boolean value diff --git a/share/etter.conf.v6 b/share/etter.conf.v6 index 770332192..0f576ad81 100644 --- a/share/etter.conf.v6 +++ b/share/etter.conf.v6 @@ -43,6 +43,7 @@ connect_timeout = 5 # seconds [stats] sampling_rate = 50 # number of packets +packet_update_count = 50 # number of packets [misc] close_on_eof = 1 # boolean value diff --git a/src/ec_conf.c b/src/ec_conf.c index ff0b81d8b..86ba7dfe2 100644 --- a/src/ec_conf.c +++ b/src/ec_conf.c @@ -69,6 +69,7 @@ static struct conf_entry connections[] = { static struct conf_entry stats[] = { { "sampling_rate", NULL }, + { "packet_update_count", NULL }, { NULL, NULL }, }; @@ -183,12 +184,12 @@ static void init_structures(void) set_pointer(mitm, "ndp_poison_equal_mac", &GBL_CONF->ndp_poison_equal_mac); set_pointer(mitm, "icmp6_probe_delay", &GBL_CONF->icmp6_probe_delay); #endif - set_pointer(connections, "connection_timeout", &GBL_CONF->connection_timeout); set_pointer(connections, "connection_idle", &GBL_CONF->connection_idle); set_pointer(connections, "connection_buffer", &GBL_CONF->connection_buffer); set_pointer(connections, "connect_timeout", &GBL_CONF->connect_timeout); set_pointer(stats, "sampling_rate", &GBL_CONF->sampling_rate); + set_pointer(stats, "packet_update_count", &GBL_CONF->packet_update_count); set_pointer(misc, "close_on_eof", &GBL_CONF->close_on_eof); set_pointer(misc, "store_profiles", &GBL_CONF->store_profiles); set_pointer(misc, "aggressive_dissectors", &GBL_CONF->aggressive_dissectors); diff --git a/src/ec_decode.c b/src/ec_decode.c index d8aa9d24f..7ba10a444 100644 --- a/src/ec_decode.c +++ b/src/ec_decode.c @@ -39,6 +39,7 @@ /* globals */ +static int count = 0; static struct dec_entry *protocols_table; static unsigned protocols_num; static bool table_sorted = false; @@ -86,9 +87,13 @@ void ec_decode(u_char *param, const struct pcap_pkthdr *pkthdr, const u_char *pk CANCELLATION_POINT(); - /* start the timer for the stats */ - stats_half_start(&GBL_STATS->bh); - + count++; + if(count = 1) + { + /* start the timer for the stats */ + stats_half_start(&GBL_STATS->bh); + } + /* XXX -- remove this */ #if 0 if (!GBL_OPTIONS->quiet) @@ -233,10 +238,13 @@ void ec_decode(u_char *param, const struct pcap_pkthdr *pkthdr, const u_char *pk /* free the structure */ packet_destroy_object(&po); - - /* calculate the stats */ - stats_half_end(&GBL_STATS->bh, pkthdr->caplen); - + if(count == GBL_CONF->packet_update_count) + { + /* calculate the stats */ + stats_half_end(&GBL_STATS->bh, pkthdr->caplen); + count = 0; + } + CANCELLATION_POINT(); return; diff --git a/src/ec_dispatcher.c b/src/ec_dispatcher.c index d747e58ea..c3682cd0b 100644 --- a/src/ec_dispatcher.c +++ b/src/ec_dispatcher.c @@ -25,6 +25,8 @@ #include #include +/* globals */ +static int count = 0; /* this is the PO queue from bottom to top half */ struct po_queue_entry { @@ -97,10 +99,14 @@ EC_THREAD_FUNC(top_half) ec_usleep(1); // 1µs continue; } - - /* start the counter for the TopHalf */ - stats_half_start(&GBL_STATS->th); - + + count++; + if(count = 1) + { + /* start the counter for the TopHalf */ + stats_half_start(&GBL_STATS->th); + } + /* remove the packet form the queue */ STAILQ_REMOVE_HEAD(&po_queue, e, next); @@ -140,9 +146,13 @@ EC_THREAD_FUNC(top_half) packet_destroy_object(e->po); SAFE_FREE(e->po); SAFE_FREE(e); - - /* start the counter for the TopHalf */ - stats_half_end(&GBL_STATS->th, pck_len); + + if(count == GBL_CONF->packet_update_count) + { + /* start the counter for the TopHalf */ + stats_half_end(&GBL_STATS->th, pck_len); + count = 0; + } } return NULL;