gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35369 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r35369 - gnunet/src/rps
Date: Tue, 10 Mar 2015 13:20:31 +0100

Author: ch3
Date: 2015-03-10 13:20:31 +0100 (Tue, 10 Mar 2015)
New Revision: 35369

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/test_rps.conf
Log:
- added malicous round execution primitive

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-03-10 12:20:29 UTC (rev 35368)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-03-10 12:20:31 UTC (rev 35369)
@@ -1404,18 +1404,50 @@
 
   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;

Modified: gnunet/src/rps/test_rps.conf
===================================================================
--- gnunet/src/rps/test_rps.conf        2015-03-10 12:20:29 UTC (rev 35368)
+++ gnunet/src/rps/test_rps.conf        2015-03-10 12:20:31 UTC (rev 35369)
@@ -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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]