From: Christian Grothoff Date: Sat, 23 Jul 2011 17:48:48 +0000 (+0000) Subject: fix starting stddevs/avgs X-Git-Tag: initial-import-from-subversion-38251~17689 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e5e33fe06042fe6c90f0a755a5c41f8f730c387c;p=oweals%2Fgnunet.git fix starting stddevs/avgs --- diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index cb0216dc6..1d5421acb 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -72,7 +72,7 @@ /** * Interval for sending network size estimation flood requests. */ -#define GNUNET_NSE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) +#define GNUNET_NSE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) /** @@ -208,6 +208,11 @@ static struct GNUNET_NSE_FloodMessage size_estimate_messages[HISTORY_SIZE]; */ static unsigned int estimate_index; +/** + * Number of valid entries in the history. + */ +static unsigned int estimate_count; + /** * Task scheduled to update our flood message for the next round. */ @@ -274,10 +279,10 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) mean = 0.0; sum = 0.0; sumweight = 0.0; - for (i=0; isize_estimate = mean - 0.5; em->std_deviation = std_dev; GNUNET_STATISTICS_set (stats, - "Current network size estimate", + "# nodes in the network (estimate)", (uint64_t) pow (2, mean - 0.5), GNUNET_NO); } @@ -625,6 +630,8 @@ update_flood_message(void *cls, next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, GNUNET_NSE_INTERVAL); estimate_index = (estimate_index + 1) % HISTORY_SIZE; + if (estimate_count < HISTORY_SIZE) + estimate_count++; setup_flood_message (estimate_index, current_timestamp); hop_count_max = 0; for (i=0;i