aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirvote.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-22 09:48:10 -0400
committerNick Mathewson <nickm@torproject.org>2013-02-19 11:05:15 -0500
commite73bbea26271dd6db75ca5c676f3c4ba8fc735e4 (patch)
tree78342452f8bb10737736209265e0e5901c48d5d3 /src/or/dirvote.c
parent1cd67443383966687af3b2f9086ceeb7915017bf (diff)
downloadtor-e73bbea26271dd6db75ca5c676f3c4ba8fc735e4.tar
tor-e73bbea26271dd6db75ca5c676f3c4ba8fc735e4.tar.gz
Tweak consensus method 17 based on arma's comments
Instead of capping whenever a router has fewer than 3 measurements, we cap whenever a router has fewer than 3 measurements *AND* there are at least 3 authorities publishing measured bandwidths. We also generate bandwidth lines with a new "Unmeasured=1" flag, meaning that we didn't have enough observations for a node to use measured bandwidth values in the authority's input, whether we capped it or not.
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r--src/or/dirvote.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 08a9eb4c0..d1ac8f8e9 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -1638,6 +1638,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
int *named_flag; /* Index of the flag "Named" for votes[j] */
int *unnamed_flag; /* Index of the flag "Unnamed" for votes[j] */
int chosen_named_idx;
+ int n_authorities_measuring_bandwidth;
strmap_t *name_to_id_map = strmap_new();
char conflict[DIGEST_LEN];
@@ -1726,6 +1727,14 @@ networkstatus_compute_consensus(smartlist_t *votes,
} SMARTLIST_FOREACH_END(v);
}
+ /* We need to know how many votes measure bandwidth. */
+ n_authorities_measuring_bandwidth = 0;
+ SMARTLIST_FOREACH(votes, networkstatus_t *, v,
+ if (v->has_measured_bws) {
+ ++n_authorities_measuring_bandwidth;
+ }
+ );
+
/* Now go through all the votes */
flag_counts = tor_malloc(sizeof(int) * smartlist_len(flags));
while (1) {
@@ -1889,14 +1898,17 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Pick a bandwidth */
if (consensus_method >= 6 && num_mbws > 2) {
rs_out.has_bandwidth = 1;
+ rs_out.has_measured_bw = 1;
rs_out.bandwidth = median_uint32(measured_bws, num_mbws);
} else if (consensus_method >= 5 && num_bandwidths > 0) {
rs_out.has_bandwidth = 1;
rs_out.bandwidth = median_uint32(bandwidths, num_bandwidths);
- if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW) {
- /* Cap non-measured bandwidths to 20k. */
- if (rs_out.bandwidth > max_unmeasured_bw)
+ if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW &&
+ n_authorities_measuring_bandwidth > 2) {
+ /* Cap non-measured bandwidths. */
+ if (rs_out.bandwidth > max_unmeasured_bw) {
rs_out.bandwidth = max_unmeasured_bw;
+ }
}
}
@@ -2039,7 +2051,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_add(chunks, tor_strdup("\n"));
/* Now the weight line. */
if (rs_out.has_bandwidth) {
- smartlist_add_asprintf(chunks, "w Bandwidth=%d\n", rs_out.bandwidth);
+ int unmeasured = ! rs_out.has_measured_bw &&
+ consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW;
+ smartlist_add_asprintf(chunks, "w Bandwidth=%d%s\n", rs_out.bandwidth,
+ unmeasured?" Unmeasured=1":"");
}
/* Now the exitpolicy summary line. */