configurable threshold for randomized backoff
authorFlorian Dold <florian.dold@gmail.com>
Wed, 26 Sep 2018 20:58:21 +0000 (22:58 +0200)
committerFlorian Dold <florian.dold@gmail.com>
Wed, 26 Sep 2018 20:58:30 +0000 (22:58 +0200)
src/include/gnunet_time_lib.h
src/util/time.c

index 41840e9a38b2dc0673a8343f6885dadfca93989d..c7a06ba23bbf7ee921f99ed6816c5db89efc1fcf 100644 (file)
@@ -177,13 +177,14 @@ GNUNET_NETWORK_STRUCT_END
 /**
  * Randomized exponential back-off, starting at 1 ms
  * and going up by a factor of 2+r, where 0 <= r <= 0.5, up
- * to a maximum of 15 m.
+ * to a maximum of the given threshold.
  *
- * @param r current backoff time, initially zero
+ * @param rt current backoff time, initially zero
+ * @param threshold maximum value for backoff
  * @return the next backoff time
  */
 struct GNUNET_TIME_Relative
-GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt);
+GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold);
 
 
 /**
index 0c177c381ef581f0854d76dde6ead9ff91cfb72a..b02c43c1b90e5c7be3c0a79b1f5f9d810a8189c5 100644 (file)
@@ -737,13 +737,14 @@ GNUNET_TIME_year_to_time (unsigned int year)
 /**
  * Randomized exponential back-off, starting at 1 ms
  * and going up by a factor of 2+r, where 0 <= r <= 0.5, up
- * to a maximum of 15 m.
+ * to a maximum of the given threshold.
  *
  * @param r current backoff time, initially zero
+ * @param threshold maximum value for backoff
  * @return the next backoff time
  */
 struct GNUNET_TIME_Relative
-GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt)
+GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold)
 {
   double r = (rand() % 500) / 1000.0;
   struct GNUNET_TIME_Relative t;
@@ -751,9 +752,11 @@ GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt)
   t = relative_multiply_double (GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS,
                                                           rt),
                                 2 + r);
-  return GNUNET_TIME_relative_min (GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD,
+  return GNUNET_TIME_relative_min (threshold,
                                    t);
 }
 
 
+
+
 /* end of time.c */