tor  0.4.1.0-alpha-dev
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-2019, 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(uint64_t num_bytes, time_t when);
18 void rep_hist_note_bytes_written(uint64_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(uint64_t num_bytes, time_t when);
23 void rep_hist_note_dir_bytes_written(uint64_t num_bytes, time_t when);
24 
25 MOCK_DECL(int, rep_hist_bandwidth_assess, (void));
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 rep_hist_exit_stats_init(time_t now);
45 void rep_hist_reset_exit_stats(time_t now);
46 void rep_hist_exit_stats_term(void);
47 char *rep_hist_format_exit_stats(time_t now);
48 time_t rep_hist_exit_stats_write(time_t now);
49 void rep_hist_note_exit_bytes(uint16_t port, size_t num_written,
50  size_t num_read);
51 void rep_hist_note_exit_stream_opened(uint16_t port);
52 
53 void rep_hist_buffer_stats_init(time_t now);
55  time_t end_of_interval);
56 time_t rep_hist_buffer_stats_write(time_t now);
58 void rep_hist_add_buffer_stats(double mean_num_cells_in_queue,
59  double mean_time_cells_in_queue, uint32_t processed_cells);
60 char *rep_hist_format_buffer_stats(time_t now);
61 void rep_hist_reset_buffer_stats(time_t now);
62 
63 void rep_hist_desc_stats_init(time_t now);
64 void rep_hist_note_desc_served(const char * desc);
65 void rep_hist_desc_stats_term(void);
66 time_t rep_hist_desc_stats_write(time_t now);
67 
68 void rep_hist_conn_stats_init(time_t now);
69 void rep_hist_note_or_conn_bytes(uint64_t conn_id, size_t num_read,
70  size_t num_written, time_t when);
71 void rep_hist_reset_conn_stats(time_t now);
72 char *rep_hist_format_conn_stats(time_t now);
73 time_t rep_hist_conn_stats_write(time_t now);
74 void rep_hist_conn_stats_term(void);
75 
79 
80 void rep_hist_hs_stats_init(time_t now);
81 void rep_hist_hs_stats_term(void);
82 time_t rep_hist_hs_stats_write(time_t now);
83 char *rep_hist_get_hs_stats_string(void);
84 void rep_hist_seen_new_rp_cell(void);
85 void rep_hist_stored_maybe_new_hs(const crypto_pk_t *pubkey);
86 
87 void rep_hist_free_all(void);
88 
89 void rep_hist_note_negotiated_link_proto(unsigned link_proto,
90  int started_here);
92 
93 extern uint64_t rephist_total_alloc;
94 extern uint32_t rephist_total_num;
95 #ifdef TOR_UNIT_TESTS
96 extern int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1];
97 extern int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1];
98 extern struct bw_array_t *write_array;
99 #endif
100 
101 #ifdef REPHIST_PRIVATE
102 typedef struct bw_array_t bw_array_t;
103 STATIC uint64_t find_largest_max(bw_array_t *b);
104 STATIC void commit_max(bw_array_t *b);
105 STATIC void advance_obs(bw_array_t *b);
106 #endif
107 
111 typedef enum padding_type_t {
123 
125 #define REPHIST_CELL_PADDING_COUNTS_INTERVAL (24*60*60)
130 void rep_hist_prep_published_padding_counts(time_t now);
131 void rep_hist_padding_count_timers(uint64_t num_timers);
132 
133 #endif /* !defined(TOR_REPHIST_H) */
int rep_hist_have_measured_enough_stability(void)
Definition: rephist.c:543
void rep_hist_conn_stats_init(time_t now)
Definition: rephist.c:2222
void rep_hist_dump_stats(time_t now, int severity)
Definition: rephist.c:554
time_t rep_hist_buffer_stats_write(time_t now)
Definition: rephist.c:2032
char * rep_hist_get_padding_count_lines(void)
Definition: rephist.c:2829
void rep_hist_reset_exit_stats(time_t now)
Definition: rephist.c:1568
void rep_hist_padding_count_timers(uint64_t num_timers)
Definition: rephist.c:2717
void rep_hist_note_circuit_handshake_requested(uint16_t type)
Definition: rephist.c:2443
void rep_hist_hs_stats_term(void)
Definition: rephist.c:2549
char * rep_hist_format_conn_stats(time_t now)
Definition: rephist.c:2383
void rep_hist_note_negotiated_link_proto(unsigned link_proto, int started_here)
Definition: rephist.c:2701
time_t rep_hist_downrate_old_runs(time_t now)
Definition: rephist.c:382
void rep_hist_seen_new_rp_cell(void)
Definition: rephist.c:2556
void rep_hist_note_exit_bytes(uint16_t port, size_t num_written, size_t num_read)
Definition: rephist.c:1785
uint32_t rephist_total_num
Definition: rephist.c:106
void rep_hist_note_exit_stream_opened(uint16_t port)
Definition: rephist.c:1799
void rep_hist_note_dir_bytes_read(uint64_t num_bytes, time_t when)
Definition: rephist.c:1185
STATIC int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1]
Definition: rephist.c:2437
void rep_history_clean(time_t before)
Definition: rephist.c:593
void rep_hist_desc_stats_term(void)
Definition: rephist.c:2102
void rep_hist_free_all(void)
Definition: rephist.c:2899
time_t rep_hist_desc_stats_write(time_t now)
Definition: rephist.c:2169
int rep_hist_load_state(or_state_t *state, char **err)
Definition: rephist.c:1498
uint64_t rephist_total_alloc
Definition: rephist.c:104
padding_type_t
Definition: rephist.h:111
STATIC void commit_max(bw_array_t *b)
Definition: rephist.c:1020
time_t rep_hist_hs_stats_write(time_t now)
Definition: rephist.c:2666
void rep_hist_note_bytes_written(uint64_t num_bytes, time_t when)
Definition: rephist.c:1149
void rep_hist_note_circuit_handshake_assigned(uint16_t type)
Definition: rephist.c:2452
void rep_hist_desc_stats_init(time_t now)
Definition: rephist.c:2079
char * rep_hist_get_bandwidth_lines(void)
Definition: rephist.c:1281
void rep_hist_padding_count_read(padding_type_t type)
Definition: rephist.c:2759
void rep_hist_note_router_unreachable(const char *id, time_t when)
Definition: rephist.c:314
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:2330
void rep_hist_reset_conn_stats(time_t now)
Definition: rephist.c:2307
void rep_hist_exit_stats_init(time_t now)
Definition: rephist.c:1558
char * rep_hist_format_exit_stats(time_t now)
Definition: rephist.c:1600
long rep_hist_get_uptime(const char *id, time_t when)
Definition: rephist.c:490
void rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval)
Definition: rephist.c:1857
void rep_hist_make_router_pessimal(const char *id, time_t when)
Definition: rephist.c:368
void rep_hist_reset_buffer_stats(time_t now)
Definition: rephist.c:1915
void rep_hist_conn_stats_term(void)
Definition: rephist.c:2320
void rep_hist_padding_count_write(padding_type_t type)
Definition: rephist.c:2731
double rep_hist_get_weighted_fractional_uptime(const char *id, time_t when)
Definition: rephist.c:515
STATIC uint64_t find_largest_max(bw_array_t *b)
Definition: rephist.c:1195
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:241
time_t rep_hist_conn_stats_write(time_t now)
Definition: rephist.c:2408
void rep_hist_hs_stats_init(time_t now)
Definition: rephist.c:2520
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:1838
void rep_hist_note_dir_bytes_written(uint64_t num_bytes, time_t when)
Definition: rephist.c:1176
void rep_hist_buffer_stats_init(time_t now)
Definition: rephist.c:1815
void rep_hist_note_desc_served(const char *desc)
Definition: rephist.c:2200
void rep_hist_log_link_protocol_counts(void)
Definition: rephist.c:2875
STATIC bw_array_t * write_array
Definition: rephist.c:1117
void rep_hist_buffer_stats_term(void)
Definition: rephist.c:1907
void rep_hist_exit_stats_term(void)
Definition: rephist.c:1579
void rep_hist_log_circuit_handshake_stats(time_t now)
Definition: rephist.c:2460
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
int rep_hist_load_mtbf_data(time_t now)
Definition: rephist.c:789
long rep_hist_get_weighted_time_known(const char *id, time_t when)
Definition: rephist.c:531
void rep_hist_stored_maybe_new_hs(const crypto_pk_t *pubkey)
Definition: rephist.c:2569
int rep_hist_record_mtbf_data(time_t now, int missing_means_down)
Definition: rephist.c:626
time_t rep_hist_exit_stats_write(time_t now)
Definition: rephist.c:1755
char * rep_hist_format_buffer_stats(time_t now)
Definition: rephist.c:1929
STATIC void advance_obs(bw_array_t *b)
Definition: rephist.c:1040
double rep_hist_get_stability(const char *id, time_t when)
Definition: rephist.c:503
void rep_hist_init(void)
Definition: rephist.c:232
void rep_hist_update_state(or_state_t *state)
Definition: rephist.c:1398
void rep_hist_reset_padding_counts(void)
Definition: rephist.c:2784
void rep_hist_note_bytes_read(uint64_t num_bytes, time_t when)
Definition: rephist.c:1166