**PathBiasDropGuards** __NUM__ +
-**PathBiasScaleThreshold** __NUM__ +
-
-**PathBiasMultFactor** __NUM__ +
-
-**PathBiasScaleFactor** __NUM__::
+**PathBiasScaleThreshold** __NUM__::
These options override the default behavior of Tor's (**currently
experimental**) path bias detection algorithm. To try to find broken or
misbehaving guard nodes, Tor looks for nodes where more than a certain
is set to 1, we disable use of that guard. +
+
When we have seen more than PathBiasScaleThreshold
- circuits through a guard, we scale our observations by
- PathBiasMultFactor/PathBiasScaleFactor, so that new observations don't get
- swamped by old ones. +
+ circuits through a guard, we scale our observations by 0.5 (governed by
+ the consensus) so that new observations don't get swamped by old ones. +
+
By default, or if a negative value is provided for one of these options,
Tor uses reasonable defaults from the networkstatus consensus document.
If no defaults are available there, these options default to 150, .70,
- .50, .30, 0, 300, 1, and 2 respectively.
+ .50, .30, 0, and 300 respectively.
**PathBiasUseThreshold** __NUM__ +
}
/**
- * The scale factor is the denominator for our scaling
- * of circuit counts for our path bias window.
+ * Compute the path bias scaling ratio from the consensus
+ * parameters pb_multfactor/pb_scalefactor.
*
- * Note that our use of doubles for the path bias state
- * file means that powers of 2 work best here.
+ * Returns a value in (0, 1.0] which we multiply our pathbias
+ * counts with to scale them down.
*/
-static int
-pathbias_get_scale_factor(const or_options_t *options)
-{
-#define DFLT_PATH_BIAS_SCALE_FACTOR 2
- if (options->PathBiasScaleFactor >= 1)
- return options->PathBiasScaleFactor;
- else
- return networkstatus_get_param(NULL, "pb_scalefactor",
- DFLT_PATH_BIAS_SCALE_FACTOR, 1, INT32_MAX);
-}
-
-/**
- * The mult factor is the numerator for our scaling
- * of circuit counts for our path bias window. It
- * allows us to scale by fractions.
- */
-static int
-pathbias_get_mult_factor(const or_options_t *options)
+static double
+pathbias_get_scale_ratio(const or_options_t *options)
{
-#define DFLT_PATH_BIAS_MULT_FACTOR 1
- if (options->PathBiasMultFactor >= 1)
- return options->PathBiasMultFactor;
- else
- return networkstatus_get_param(NULL, "pb_multfactor",
- DFLT_PATH_BIAS_MULT_FACTOR, 1,
- pathbias_get_scale_factor(options));
+ /*
+ * The scale factor is the denominator for our scaling
+ * of circuit counts for our path bias window.
+ *
+ * Note that our use of doubles for the path bias state
+ * file means that powers of 2 work best here.
+ */
+ int denominator = networkstatus_get_param(NULL, "pb_scalefactor",
+ 2, 2, INT32_MAX);
+ /**
+ * The mult factor is the numerator for our scaling
+ * of circuit counts for our path bias window. It
+ * allows us to scale by fractions.
+ */
+ return networkstatus_get_param(NULL, "pb_multfactor",
+ 1, 1, denominator)/((double)denominator);
}
/** The minimum number of circuit usage attempts before we start
/* If we get a ton of circuits, just scale everything down */
if (guard->use_attempts > pathbias_get_scale_use_threshold(options)) {
- const int scale_factor = pathbias_get_scale_factor(options);
- const int mult_factor = pathbias_get_mult_factor(options);
+ double scale_ratio = pathbias_get_scale_ratio(options);
int opened_attempts = pathbias_count_circs_in_states(guard,
PATH_STATE_USE_ATTEMPTED, PATH_STATE_USE_SUCCEEDED);
guard->use_attempts -= opened_attempts;
- guard->use_attempts *= mult_factor;
- guard->use_successes *= mult_factor;
-
- guard->use_attempts /= scale_factor;
- guard->use_successes /= scale_factor;
+ guard->use_attempts *= scale_ratio;
+ guard->use_successes *= scale_ratio;
guard->use_attempts += opened_attempts;
/* If we get a ton of circuits, just scale everything down */
if (guard->circ_attempts > pathbias_get_scale_threshold(options)) {
- const int scale_factor = pathbias_get_scale_factor(options);
- const int mult_factor = pathbias_get_mult_factor(options);
+ double scale_ratio = pathbias_get_scale_ratio(options);
int opened_attempts = pathbias_count_circs_in_states(guard,
PATH_STATE_BUILD_ATTEMPTED, PATH_STATE_BUILD_ATTEMPTED);
int opened_built = pathbias_count_circs_in_states(guard,
guard->circ_attempts -= opened_attempts;
guard->circ_successes -= opened_built;
- guard->circ_attempts *= mult_factor;
- guard->circ_successes *= mult_factor;
- guard->timeouts *= mult_factor;
- guard->successful_circuits_closed *= mult_factor;
- guard->collapsed_circuits *= mult_factor;
- guard->unusable_circuits *= mult_factor;
-
- guard->circ_attempts /= scale_factor;
- guard->circ_successes /= scale_factor;
- guard->timeouts /= scale_factor;
- guard->successful_circuits_closed /= scale_factor;
- guard->collapsed_circuits /= scale_factor;
- guard->unusable_circuits /= scale_factor;
+ guard->circ_attempts *= scale_ratio;
+ guard->circ_successes *= scale_ratio;
+ guard->timeouts *= scale_ratio;
+ guard->successful_circuits_closed *= scale_ratio;
+ guard->collapsed_circuits *= scale_ratio;
+ guard->unusable_circuits *= scale_ratio;
guard->circ_attempts += opened_attempts;
guard->circ_successes += opened_built;