aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-03-10 12:20:31 +0000
committerJulius Bünger <buenger@mytum.de>2015-03-10 12:20:31 +0000
commit4bbe44b460db015f8c784d4b699f6d381d2d96c3 (patch)
treebdc1efaee69e7100123b5adcfaa06641b1347537 /src/rps
parentf1dd87281c36abbbe6a5e133637fe563b8c5a926 (diff)
downloadgnunet-4bbe44b460db015f8c784d4b699f6d381d2d96c3.tar.gz
gnunet-4bbe44b460db015f8c784d4b699f6d381d2d96c3.zip
- added malicous round execution primitive
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c36
-rw-r--r--src/rps/test_rps.conf2
2 files changed, 35 insertions, 3 deletions
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,
1404 1404
1405 return GNUNET_OK; 1405 return GNUNET_OK;
1406} 1406}
1407
1408
1409/**
1410 * Send out PUSHes and PULLs maliciously.
1411 *
1412 * This is executed regylary.
1413 */
1414static void
1415do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1416{
1417 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously.\n");
1418
1419 /* Do stuff */
1420
1421 /* Compute random time value between .5 * round_interval and 1.5 *round_interval */
1422 half_round_interval = GNUNET_TIME_relative_divide (round_interval, 2);
1423 do
1424 {
1425 /*
1426 * Compute random value between (0 and 1) * round_interval
1427 * via multiplying round_interval with a 'fraction' (0 to value)/value
1428 */
1429 rand_delay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT_MAX/10);
1430 time_next_round = GNUNET_TIME_relative_multiply (round_interval, rand_delay);
1431 time_next_round = GNUNET_TIME_relative_divide (time_next_round, UINT_MAX/10);
1432 time_next_round = GNUNET_TIME_relative_add (time_next_round, half_round_interval);
1433 } while (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == time_next_round.rel_value_us);
1434
1435 /* Schedule next round */
1436 do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, NULL);
1437 LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n");
1438}
1407#endif /* ENABLE_MALICIOUS */ 1439#endif /* ENABLE_MALICIOUS */
1408 1440
1409 1441
1410/** 1442/**
1411 * Send out PUSHes and PULLs. 1443 * Send out PUSHes and PULLs, possibly update #gossip_list, samplers.
1412 * 1444 *
1413 * This is executed regylary. 1445 * This is executed regylary.
1414 */ 1446 */
1415static void 1447static void
1416do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1448do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1417{ 1449{
1418 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round\n"); 1450 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round.\n");
1419 1451
1420 uint32_t i; 1452 uint32_t i;
1421 unsigned int *permut; 1453 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 @@
1[rps] 1[rps]
2PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p 2#PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
3#BINARY = gnunet-service-rps 3#BINARY = gnunet-service-rps
4UNIXPATH = /tmp/gnunet-service-rps.sock 4UNIXPATH = /tmp/gnunet-service-rps.sock
5HOME = $SERVICEHOME 5HOME = $SERVICEHOME