12 #ifndef TOR_CIRCUITSTATS_H
13 #define TOR_CIRCUITSTATS_H
22 int ignore_consensus);
35 int did_onehop, time_t start_time);
56 #define CBT_NCIRCUITS_TO_OBSERVE 1000
59 #define CBT_BIN_WIDTH ((build_time_t)10)
62 #define CBT_DEFAULT_NUM_XM_MODES 10
63 #define CBT_MIN_NUM_XM_MODES 1
64 #define CBT_MAX_NUM_XM_MODES 20
70 #define CBT_BUILD_ABANDONED ((build_time_t)(INT32_MAX-1))
71 #define CBT_BUILD_TIME_MAX ((build_time_t)(INT32_MAX))
74 #define CBT_SAVE_STATE_EVERY 10
82 #define CBT_DEFAULT_CLOSE_QUANTILE 99
83 #define CBT_MIN_CLOSE_QUANTILE CBT_MIN_QUANTILE_CUTOFF
84 #define CBT_MAX_CLOSE_QUANTILE CBT_MAX_QUANTILE_CUTOFF
90 #define CBT_DEFAULT_RECENT_CIRCUITS 20
91 #define CBT_MIN_RECENT_CIRCUITS 3
92 #define CBT_MAX_RECENT_CIRCUITS 1000
102 #define CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT (CBT_DEFAULT_RECENT_CIRCUITS*9/10)
103 #define CBT_MIN_MAX_RECENT_TIMEOUT_COUNT 3
104 #define CBT_MAX_MAX_RECENT_TIMEOUT_COUNT 10000
107 #define CBT_DEFAULT_MIN_CIRCUITS_TO_OBSERVE 100
108 #define CBT_MIN_MIN_CIRCUITS_TO_OBSERVE 1
109 #define CBT_MAX_MIN_CIRCUITS_TO_OBSERVE 10000
112 #define CBT_DEFAULT_QUANTILE_CUTOFF 80
113 #define CBT_MIN_QUANTILE_CUTOFF 10
114 #define CBT_MAX_QUANTILE_CUTOFF 99
118 #define CBT_DEFAULT_TEST_FREQUENCY 10
119 #define CBT_MIN_TEST_FREQUENCY 1
120 #define CBT_MAX_TEST_FREQUENCY INT32_MAX
123 #define CBT_DEFAULT_TIMEOUT_MIN_VALUE (CBT_BIN_WIDTH)
124 #define CBT_MIN_TIMEOUT_MIN_VALUE CBT_BIN_WIDTH
125 #define CBT_MAX_TIMEOUT_MIN_VALUE INT32_MAX
128 #define CBT_DEFAULT_TIMEOUT_INITIAL_VALUE (60*1000)
129 #define CBT_MIN_TIMEOUT_INITIAL_VALUE CBT_MIN_TIMEOUT_MIN_VALUE
130 #define CBT_MAX_TIMEOUT_INITIAL_VALUE INT32_MAX
133 #if CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT < CBT_MIN_MAX_RECENT_TIMEOUT_COUNT
134 #error "RECENT_CIRCUITS is set too low."
137 #ifdef CIRCUITSTATS_PRIVATE
148 #ifdef TOR_UNIT_TESTS
150 double q_lo,
double q_hi);
153 double quantile,
double time_ms);
154 void circuitbuild_running_unit_tests(
void);
STATIC double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt, double quantile)
STATIC int circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
STATIC build_time_t circuit_build_times_get_xm(circuit_build_times_t *cbt)
STATIC int circuit_build_times_update_alpha(circuit_build_times_t *cbt)
int circuit_build_times_needs_circuits_now(const circuit_build_times_t *cbt)
void circuit_build_times_free_timeouts(circuit_build_times_t *cbt)
void circuit_build_times_network_is_live(circuit_build_times_t *cbt)
void circuit_build_times_handle_completed_hop(origin_circuit_t *circ)
void circuit_build_times_set_timeout(circuit_build_times_t *cbt)
double get_circuit_build_timeout_ms(void)
int circuit_build_times_parse_state(circuit_build_times_t *cbt, or_state_t *state)
int circuit_build_times_network_check_live(const circuit_build_times_t *cbt)
#define CBT_NCIRCUITS_TO_OBSERVE
int circuit_build_times_disabled_(const or_options_t *options, int ignore_consensus)
void circuit_build_times_count_timeout(circuit_build_times_t *cbt, int did_onehop)
const circuit_build_times_t * get_circuit_build_times(void)
double get_circuit_build_close_time_ms(void)
void circuit_build_times_new_consensus_params(circuit_build_times_t *cbt, const networkstatus_t *ns)
double circuit_build_times_timeout_rate(const circuit_build_times_t *cbt)
void circuit_build_times_update_state(const circuit_build_times_t *cbt, or_state_t *state)
void circuit_build_times_mark_circ_as_measurement_only(origin_circuit_t *circ)
void circuit_build_times_init(circuit_build_times_t *cbt)
int circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t time)
int32_t circuit_build_times_initial_timeout(void)
void circuit_build_times_network_circ_success(circuit_build_times_t *cbt)
int circuit_build_times_enough_to_compute(const circuit_build_times_t *cbt)
int circuit_build_times_count_close(circuit_build_times_t *cbt, int did_onehop, time_t start_time)
int circuit_build_times_disabled(const or_options_t *options)
circuit_build_times_t * get_circuit_build_times_mutable(void)
double circuit_build_times_quantile_cutoff(void)
void circuit_build_times_reset(circuit_build_times_t *cbt)
double circuit_build_times_close_rate(const circuit_build_times_t *cbt)
int circuit_build_times_needs_circuits(const circuit_build_times_t *cbt)
int have_computed_timeout
uint32_t num_circ_timeouts
uint32_t num_circ_succeeded
build_time_t circuit_build_times[CBT_NCIRCUITS_TO_OBSERVE]
network_liveness_t liveness
int8_t * timeouts_after_firsthop