From: Julius Bünger Date: Tue, 10 Mar 2015 12:20:31 +0000 (+0000) Subject: - added malicous round execution primitive X-Git-Tag: initial-import-from-subversion-38251~2213 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4bbe44b460db015f8c784d4b699f6d381d2d96c3;p=oweals%2Fgnunet.git - added malicous round execution primitive --- diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 4e9f795c3..61b090979 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -1404,18 +1404,50 @@ handle_peer_act_malicious (void *cls, return GNUNET_OK; } + + +/** + * Send out PUSHes and PULLs maliciously. + * + * This is executed regylary. + */ +static void +do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously.\n"); + + /* Do stuff */ + + /* Compute random time value between .5 * round_interval and 1.5 *round_interval */ + half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2); + do + { + /* + * Compute random value between (0 and 1) * round_interval + * via multiplying round_interval with a 'fraction' (0 to value)/value + */ + rand_delay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT_MAX/10); + time_next_round = GNUNET_TIME_relative_multiply (round_interval, rand_delay); + time_next_round = GNUNET_TIME_relative_divide (time_next_round, UINT_MAX/10); + time_next_round = GNUNET_TIME_relative_add (time_next_round, half_round_interval); + } while (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == time_next_round.rel_value_us); + + /* Schedule next round */ + do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, NULL); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); +} #endif /* ENABLE_MALICIOUS */ /** - * Send out PUSHes and PULLs. + * Send out PUSHes and PULLs, possibly update #gossip_list, samplers. * * This is executed regylary. */ static void do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round.\n"); uint32_t i; unsigned int *permut; diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf index 411bde5ec..9706bc078 100644 --- a/src/rps/test_rps.conf +++ b/src/rps/test_rps.conf @@ -1,5 +1,5 @@ [rps] -PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p +#PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p #BINARY = gnunet-service-rps UNIXPATH = /tmp/gnunet-service-rps.sock HOME = $SERVICEHOME