[or-cvs] r12219: base "Guard" flag on WFU rather than MTBF. Note an issue in (in tor/trunk: . doc doc/spec src/or)

nickm at seul.org nickm at seul.org
Fri Oct 26 22:50:43 UTC 2007


Author: nickm
Date: 2007-10-26 18:50:42 -0400 (Fri, 26 Oct 2007)
New Revision: 12219

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/doc/spec/dir-spec.txt
   tor/trunk/src/or/dirserv.c
Log:
 r16195 at catbus:  nickm | 2007-10-26 18:48:52 -0400
 base "Guard" flag on WFU rather than MTBF.  Note an issue in the TODO. Roger: thoughts?



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r16195] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-10-26 22:50:40 UTC (rev 12218)
+++ tor/trunk/ChangeLog	2007-10-26 22:50:42 UTC (rev 12219)
@@ -4,6 +4,9 @@
       it, it had no AES, and it hasn't seen any security patches since 2004.
 
   o Minor features:
+    - Directory authorities now decide whether routers are stable enough to
+      be guards based not on their MTBF or their uptime, but on their
+      fractional uptime: the fraction of the time that they are online.
     - Clients new hold circuitless TLS connections open for 1.5 times
       MaxCircuitDirtiness, since it is likely that they'll need to build
       a circuit over them within that timeframe.  Previously, they held them

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-10-26 22:50:40 UTC (rev 12218)
+++ tor/trunk/doc/TODO	2007-10-26 22:50:42 UTC (rev 12219)
@@ -27,7 +27,11 @@
       o Bump up OR the "connection timeout" value to be 1.5
 	circuit dirtiness interval.
       o Document this in tor-spec
-    - base Guard flag on WFU rather than or in addition to MTBF
+    o base Guard flag on WFU rather than on MTBF.
+      o Change guard calculation
+      o Change dir-spec.txt
+      - What should we do about hosts that have been up for only 1 hour,
+        but have been up for 100% of that one hour?
     D 118 if feasible and obvious
     D Maintain a skew estimate and use ftime consistently.
     - 105+TLS, if possible.

Modified: tor/trunk/doc/spec/dir-spec.txt
===================================================================
--- tor/trunk/doc/spec/dir-spec.txt	2007-10-26 22:50:40 UTC (rev 12218)
+++ tor/trunk/doc/spec/dir-spec.txt	2007-10-26 22:50:42 UTC (rev 12219)
@@ -990,12 +990,17 @@
    "Fast" -- A router is 'Fast' if it is active, and its bandwidth is
    either in the top 7/8ths for known active routers or at least 100KB/s.
 
-   "Guard" -- A router is a possible 'Guard' if it is 'Stable' and its
-   bandwidth is either at least the median for known active routers or
-   at least 250KB/s. If the total bandwidth of active non-BadExit Exit
-   servers is less than one third of the total bandwidth of all active
-   servers, no Exit is listed as a Guard.
+   "Guard" -- A router is a possible 'Guard' if its Weighted Fractional
+   Uptime is at least the median for known active routers, and its bandwidth
+   is either at least the median for known active routers or at least
+   250KB/s. If the total bandwidth of active non-BadExit Exit servers is less
+   than one third of the total bandwidth of all active servers, no Exit is
+   listed as a Guard.
 
+        To calculate weighted fractional uptime, compute the fraction
+        of time that the router is up in any given day, weighting so that
+        downtime and uptime in the past counts less.
+
    "Authority" -- A router is called an 'Authority' if the authority
    generating the network-status document believes it is an authority.
 

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-10-26 22:50:40 UTC (rev 12218)
+++ tor/trunk/src/or/dirserv.c	2007-10-26 22:50:42 UTC (rev 12219)
@@ -1474,6 +1474,7 @@
 static uint32_t stable_uptime = 0; /* start at a safe value */
 static double stable_mtbf = 0.0;
 static int enough_mtbf_info = 0;
+static double guard_wfu = 0.0;
 static uint32_t fast_bandwidth = 0;
 static uint32_t guard_bandwidth_including_exits = 0;
 static uint32_t guard_bandwidth_excluding_exits = 0;
@@ -1536,7 +1537,7 @@
 {
   int n_active, n_active_nonexit;
   uint32_t *uptimes, *bandwidths, *bandwidths_excluding_exits;
-  double *mtbfs;
+  double *mtbfs, *wfus;
   time_t now = time(NULL);
 
   /* initialize these all here, in case there are no routers */
@@ -1554,6 +1555,7 @@
   bandwidths_excluding_exits =
     tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
   mtbfs = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
+  wfus = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
 
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
     if (router_is_active(ri, now)) {
@@ -1562,6 +1564,7 @@
       ri->is_exit = exit_policy_is_general_exit(ri->exit_policy);
       uptimes[n_active] = real_uptime(ri, now);
       mtbfs[n_active] = rep_hist_get_stability(id, now);
+      wfus [n_active] = rep_hist_get_weighted_fractional_uptime(id, now);
       bandwidths[n_active] = bw = router_get_advertised_bandwidth(ri);
       total_bandwidth += bw;
       if (ri->is_exit && !ri->is_bad_exit) {
@@ -1577,6 +1580,7 @@
   if (n_active) {
     stable_uptime = median_uint32(uptimes, n_active);
     stable_mtbf = median_double(mtbfs, n_active);
+    guard_wfu = median_double(wfus, n_active);
     fast_bandwidth = find_nth_uint32(bandwidths, n_active, n_active/8);
     /* Now bandwidths is sorted. */
     if (fast_bandwidth < ROUTER_REQUIRED_MIN_BANDWIDTH)
@@ -1591,6 +1595,7 @@
       median_uint32(bandwidths_excluding_exits, n_active_nonexit);
   }
 
+  /*XXXX020 Log the other stuff too. */
   log(LOG_INFO, LD_DIRSERV,
       "Cutoffs: %lus uptime, %lu b/s fast, %lu or %lu b/s guard.",
       (unsigned long)stable_uptime,
@@ -1600,6 +1605,7 @@
 
   tor_free(uptimes);
   tor_free(mtbfs);
+  tor_free(wfus);
   tor_free(bandwidths);
   tor_free(bandwidths_excluding_exits);
 }
@@ -1823,12 +1829,19 @@
     rs->is_unnamed = (naming && (name_status & FP_UNNAMED)) ? 1 : 0;
   }
   rs->is_valid = ri->is_valid;
-  rs->is_possible_guard = rs->is_fast && rs->is_stable &&
-    (!rs->is_exit || exits_can_be_guards) &&
-    (router_get_advertised_bandwidth(ri) >= BANDWIDTH_TO_GUARANTEE_GUARD ||
-     router_get_advertised_bandwidth(ri) >=
-     (exits_can_be_guards ? guard_bandwidth_including_exits :
-      guard_bandwidth_excluding_exits));
+  
+  if (rs->is_fast &&
+      (!rs->is_exit || exits_can_be_guards) &&
+      (router_get_advertised_bandwidth(ri) >= BANDWIDTH_TO_GUARANTEE_GUARD ||
+       router_get_advertised_bandwidth(ri) >=
+       (exits_can_be_guards ? guard_bandwidth_including_exits :
+        guard_bandwidth_excluding_exits))) {
+    double wfu = rep_hist_get_weighted_fractional_uptime(
+                                      ri->cache_info.identity_digest, now);
+    rs->is_possible_guard = (wfu >= guard_wfu) ? 1 : 0;
+  } else {
+    rs->is_possible_guard = 0;
+  }
   rs->is_bad_exit = listbadexits && ri->is_bad_exit;
   /* 0.1.1.9-alpha is the first version to support fetch by descriptor
    * hash. */



More information about the tor-commits mailing list