tor  master
rephist.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2017, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_REPHIST_H
13 #define TOR_REPHIST_H
14 
15 void rep_hist_init(void);
16 void rep_hist_dump_stats(time_t now, int severity);
17 void rep_hist_note_bytes_read(size_t num_bytes, time_t when);
18 void rep_hist_note_bytes_written(size_t num_bytes, time_t when);
19 
20 void rep_hist_make_router_pessimal(const char *id, time_t when);
21 
22 void rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when);
23 void rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when);
24 
28 int rep_hist_load_state(or_state_t *state, char **err);
29 void rep_history_clean(time_t before);
30 
31 void rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
32  const uint16_t at_port, time_t when);
33 void rep_hist_note_router_unreachable(const char *id, time_t when);
34 int rep_hist_record_mtbf_data(time_t now, int missing_means_down);
35 int rep_hist_load_mtbf_data(time_t now);
36 
37 time_t rep_hist_downrate_old_runs(time_t now);
38 long rep_hist_get_uptime(const char *id, time_t when);
39 double rep_hist_get_stability(const char *id, time_t when);
40 double rep_hist_get_weighted_fractional_uptime(const char *id, time_t when);
41 long rep_hist_get_weighted_time_known(const char *id, time_t when);
43 
44 void predicted_ports_init(void);
45 void rep_hist_note_used_port(time_t now, uint16_t port);
47 void rep_hist_remove_predicted_ports(const smartlist_t *rmv_ports);
48 void rep_hist_note_used_resolve(time_t now);
49 void rep_hist_note_used_internal(time_t now, int need_uptime,
50  int need_capacity);
51 int rep_hist_get_predicted_internal(time_t now, int *need_uptime,
52  int *need_capacity);
53 
54 int any_predicted_circuits(time_t now);
55 int rep_hist_circbuilding_dormant(time_t now);
57 
58 void rep_hist_exit_stats_init(time_t now);
59 void rep_hist_reset_exit_stats(time_t now);
60 void rep_hist_exit_stats_term(void);
61 char *rep_hist_format_exit_stats(time_t now);
62 time_t rep_hist_exit_stats_write(time_t now);
63 void rep_hist_note_exit_bytes(uint16_t port, size_t num_written,
64  size_t num_read);
65 void rep_hist_note_exit_stream_opened(uint16_t port);
66 
67 void rep_hist_buffer_stats_init(time_t now);
69  time_t end_of_interval);
70 time_t rep_hist_buffer_stats_write(time_t now);
72 void rep_hist_add_buffer_stats(double mean_num_cells_in_queue,
73  double mean_time_cells_in_queue, uint32_t processed_cells);
74 char *rep_hist_format_buffer_stats(time_t now);
75 void rep_hist_reset_buffer_stats(time_t now);
76 
77 void rep_hist_desc_stats_init(time_t now);
78 void rep_hist_note_desc_served(const char * desc);
79 void rep_hist_desc_stats_term(void);
80 time_t rep_hist_desc_stats_write(time_t now);
81 
82 void rep_hist_conn_stats_init(time_t now);
83 void rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
84  size_t num_written, time_t when);
85 void rep_hist_reset_conn_stats(time_t now);
86 char *rep_hist_format_conn_stats(time_t now);
87 time_t rep_hist_conn_stats_write(time_t now);
88 void rep_hist_conn_stats_term(void);
89 
93 
94 void rep_hist_hs_stats_init(time_t now);
95 void rep_hist_hs_stats_term(void);
96 time_t rep_hist_hs_stats_write(time_t now);
97 char *rep_hist_get_hs_stats_string(void);
98 void rep_hist_seen_new_rp_cell(void);
99 void rep_hist_stored_maybe_new_hs(const crypto_pk_t *pubkey);
100 
101 void rep_hist_free_all(void);
102 
103 void rep_hist_note_negotiated_link_proto(unsigned link_proto,
104  int started_here);
106 
107 extern uint64_t rephist_total_alloc;
108 extern uint32_t rephist_total_num;
109 #ifdef TOR_UNIT_TESTS
110 extern int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1];
111 extern int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1];
112 #endif
113 
117 typedef enum padding_type_t {
129 
131 #define REPHIST_CELL_PADDING_COUNTS_INTERVAL (24*60*60)
136 void rep_hist_prep_published_padding_counts(time_t now);
137 void rep_hist_padding_count_timers(uint64_t num_timers);
138 
139 #endif /* !defined(TOR_REPHIST_H) */
140 
int rep_hist_have_measured_enough_stability(void)
Definition: rephist.c:536
Definition: rephist.h:127
void rep_hist_conn_stats_init(time_t now)
Definition: rephist.c:2495
void rep_hist_dump_stats(time_t now, int severity)
Definition: rephist.c:547
time_t rep_hist_buffer_stats_write(time_t now)
Definition: rephist.c:2305
char * rep_hist_get_padding_count_lines(void)
Definition: rephist.c:3102
int predicted_ports_prediction_time_remaining(time_t now)
Definition: rephist.c:1546
void rep_hist_reset_exit_stats(time_t now)
Definition: rephist.c:1841
void rep_hist_padding_count_timers(uint64_t num_timers)
Definition: rephist.c:2990
void rep_hist_note_circuit_handshake_requested(uint16_t type)
Definition: rephist.c:2716
smartlist_t * rep_hist_get_predicted_ports(time_t now)
Definition: rephist.c:1663
Definition: rephist.h:119
void rep_hist_hs_stats_term(void)
Definition: rephist.c:2822
char * rep_hist_format_conn_stats(time_t now)
Definition: rephist.c:2656
void rep_hist_note_negotiated_link_proto(unsigned link_proto, int started_here)
Definition: rephist.c:2974
time_t rep_hist_downrate_old_runs(time_t now)
Definition: rephist.c:375
Definition: address.h:56
void rep_hist_seen_new_rp_cell(void)
Definition: rephist.c:2829
int rep_hist_circbuilding_dormant(time_t now)
Definition: rephist.c:1785
Definition: rephist.h:123
void rep_hist_note_exit_bytes(uint16_t port, size_t num_written, size_t num_read)
Definition: rephist.c:2058
uint32_t rephist_total_num
Definition: rephist.c:98
void rep_hist_note_exit_stream_opened(uint16_t port)
Definition: rephist.c:2072
STATIC int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1]
Definition: rephist.c:2710
Definition: container.h:18
void rep_hist_note_bytes_read(size_t num_bytes, time_t when)
Definition: rephist.c:1159
void rep_history_clean(time_t before)
Definition: rephist.c:586
void rep_hist_desc_stats_term(void)
Definition: rephist.c:2375
void rep_hist_free_all(void)
Definition: rephist.c:3173
time_t rep_hist_desc_stats_write(time_t now)
Definition: rephist.c:2442
void rep_hist_note_dir_bytes_written(size_t num_bytes, time_t when)
Definition: rephist.c:1169
void rep_hist_note_used_internal(time_t now, int need_uptime, int need_capacity)
Definition: rephist.c:1727
int rep_hist_load_state(or_state_t *state, char **err)
Definition: rephist.c:1491
uint64_t rephist_total_alloc
Definition: rephist.c:96
padding_type_t
Definition: rephist.h:117
int any_predicted_circuits(time_t now)
Definition: rephist.c:1774
int rep_hist_get_predicted_internal(time_t now, int *need_uptime, int *need_capacity)
Definition: rephist.c:1750
time_t rep_hist_hs_stats_write(time_t now)
Definition: rephist.c:2939
void rep_hist_note_circuit_handshake_assigned(uint16_t type)
Definition: rephist.c:2725
void rep_hist_desc_stats_init(time_t now)
Definition: rephist.c:2352
char * rep_hist_get_bandwidth_lines(void)
Definition: rephist.c:1274
Definition: or.h:4708
void rep_hist_padding_count_read(padding_type_t type)
Definition: rephist.c:3032
void rep_hist_note_router_unreachable(const char *id, time_t when)
Definition: rephist.c:307
void rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read, size_t num_written, time_t when)
Definition: rephist.c:2603
void rep_hist_reset_conn_stats(time_t now)
Definition: rephist.c:2580
void rep_hist_exit_stats_init(time_t now)
Definition: rephist.c:1831
char * rep_hist_format_exit_stats(time_t now)
Definition: rephist.c:1873
long rep_hist_get_uptime(const char *id, time_t when)
Definition: rephist.c:483
void rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval)
Definition: rephist.c:2130
int rep_hist_bandwidth_assess(void)
Definition: rephist.c:1207
void rep_hist_make_router_pessimal(const char *id, time_t when)
Definition: rephist.c:361
void rep_hist_reset_buffer_stats(time_t now)
Definition: rephist.c:2188
void rep_hist_conn_stats_term(void)
Definition: rephist.c:2593
void rep_hist_padding_count_write(padding_type_t type)
Definition: rephist.c:3004
double rep_hist_get_weighted_fractional_uptime(const char *id, time_t when)
Definition: rephist.c:508
Definition: or.h:3059
void rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr, const uint16_t at_port, time_t when)
Definition: rephist.c:234
time_t rep_hist_conn_stats_write(time_t now)
Definition: rephist.c:2681
void rep_hist_hs_stats_init(time_t now)
Definition: rephist.c:2793
void rep_hist_add_buffer_stats(double mean_num_cells_in_queue, double mean_time_cells_in_queue, uint32_t processed_cells)
Definition: rephist.c:2111
void rep_hist_buffer_stats_init(time_t now)
Definition: rephist.c:2088
void rep_hist_note_desc_served(const char *desc)
Definition: rephist.c:2473
void rep_hist_log_link_protocol_counts(void)
Definition: rephist.c:3148
Definition: crypto_rsa.c:41
void rep_hist_buffer_stats_term(void)
Definition: rephist.c:2180
void rep_hist_exit_stats_term(void)
Definition: rephist.c:1852
void rep_hist_log_circuit_handshake_stats(time_t now)
Definition: rephist.c:2733
void rep_hist_note_dir_bytes_read(size_t num_bytes, time_t when)
Definition: rephist.c:1178
int rep_hist_load_mtbf_data(time_t now)
Definition: rephist.c:782
long rep_hist_get_weighted_time_known(const char *id, time_t when)
Definition: rephist.c:524
void rep_hist_stored_maybe_new_hs(const crypto_pk_t *pubkey)
Definition: rephist.c:2842
void rep_hist_note_used_port(time_t now, uint16_t port)
Definition: rephist.c:1636
int rep_hist_record_mtbf_data(time_t now, int missing_means_down)
Definition: rephist.c:619
time_t rep_hist_exit_stats_write(time_t now)
Definition: rephist.c:2028
char * rep_hist_format_buffer_stats(time_t now)
Definition: rephist.c:2202
double rep_hist_get_stability(const char *id, time_t when)
Definition: rephist.c:496
void rep_hist_init(void)
Definition: rephist.c:224
void rep_hist_note_used_resolve(time_t now)
Definition: rephist.c:1713
void rep_hist_update_state(or_state_t *state)
Definition: rephist.c:1391
void rep_hist_reset_padding_counts(void)
Definition: rephist.c:3057
void rep_hist_remove_predicted_ports(const smartlist_t *rmv_ports)
Definition: rephist.c:1691
void rep_hist_note_bytes_written(size_t num_bytes, time_t when)
Definition: rephist.c:1142
Definition: rephist.h:121
Definition: rephist.h:125