tor  0.4.0.0-alpha-dev
Data Structures | Macros | Typedefs | Functions | Variables
rephist.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/statefile.h"
#include "core/or/circuitlist.h"
#include "core/or/connection_or.h"
#include "feature/dirauth/authmode.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/relay/routermode.h"
#include "feature/stats/predict_ports.h"
#include "feature/stats/rephist.h"
#include "lib/container/order.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/math/laplace.h"
#include "feature/nodelist/networkstatus_st.h"
#include "core/or/or_circuit_st.h"
#include "app/config/or_state_st.h"

Go to the source code of this file.

Data Structures

struct  or_history_t
 
struct  padding_counts_t
 
struct  bw_array_t
 
struct  circ_buffer_stats_t
 
struct  bidi_map_entry_t
 
struct  hs_stats_t
 

Macros

#define REPHIST_PRIVATE
 
#define STABILITY_EPSILON   0.0001
 
#define STABILITY_ALPHA   0.95
 
#define STABILITY_INTERVAL   (12*60*60)
 
#define SUBTRACT_CLAMPED(var, penalty)   do { (var) = (var) < (penalty) ? 0 : (var) - (penalty); } while (0)
 
#define PUT(s)   STMT_BEGIN if (fputs((s),f)<0) goto err; STMT_END
 
#define PRINTF(args)   STMT_BEGIN if (fprintf args <0) goto err; STMT_END
 
#define NUM_SECS_ROLLING_MEASURE   10
 
#define NUM_SECS_BW_SUM_INTERVAL   (24*60*60)
 
#define NUM_SECS_BW_SUM_IS_VALID   (5*24*60*60)
 
#define NUM_TOTALS   (NUM_SECS_BW_SUM_IS_VALID/NUM_SECS_BW_SUM_INTERVAL)
 
#define bw_array_free(val)   FREE_AND_NULL(bw_array_t, bw_array_free_, (val))
 
#define MAX_HIST_VALUE_LEN   (21*NUM_TOTALS)
 
#define UPDATE(arrname, st)
 
#define LOAD(arrname, st)
 
#define EXIT_STATS_ROUND_UP_BYTES   1024
 
#define EXIT_STATS_ROUND_UP_STREAMS   4
 
#define EXIT_STATS_NUM_PORTS   65536
 
#define EXIT_STATS_TOP_N_PORTS   10
 
#define SHARES   10
 
#define BIDI_THRESHOLD   20480
 
#define BIDI_FACTOR   10
 
#define BIDI_INTERVAL   10
 
#define hs_stats_free(val)   FREE_AND_NULL(hs_stats_t, hs_stats_free_, (val))
 
#define REND_CELLS_DELTA_F   2048
 
#define REND_CELLS_EPSILON   0.3
 
#define REND_CELLS_BIN_SIZE   1024
 
#define ONIONS_SEEN_DELTA_F   8
 
#define ONIONS_SEEN_EPSILON   0.3
 
#define ONIONS_SEEN_BIN_SIZE   8
 
#define MIN_CELL_COUNTS_TO_PUBLISH   1
 
#define ROUND_CELL_COUNTS_TO   10000
 
#define ROUND_AND_SET_COUNT(x)
 

Typedefs

typedef struct or_history_t or_history_t
 
typedef struct padding_counts_t padding_counts_t
 
typedef struct circ_buffer_stats_t circ_buffer_stats_t
 
typedef struct bidi_map_entry_t bidi_map_entry_t
 
typedef struct hs_stats_t hs_stats_t
 

Functions

static void bw_arrays_init (void)
 
static or_history_tget_or_history (const char *id)
 
static void free_or_history (void *_hist)
 
void rep_hist_init (void)
 
void rep_hist_note_router_reachable (const char *id, const tor_addr_t *at_addr, const uint16_t at_port, time_t when)
 
void rep_hist_note_router_unreachable (const char *id, time_t when)
 
void rep_hist_make_router_pessimal (const char *id, time_t when)
 
time_t rep_hist_downrate_old_runs (time_t now)
 
static double get_stability (or_history_t *hist, time_t when)
 
static long get_total_weighted_time (or_history_t *hist, time_t when)
 
static double get_weighted_fractional_uptime (or_history_t *hist, time_t when)
 
long rep_hist_get_uptime (const char *id, time_t when)
 
double rep_hist_get_stability (const char *id, time_t when)
 
double rep_hist_get_weighted_fractional_uptime (const char *id, time_t when)
 
long rep_hist_get_weighted_time_known (const char *id, time_t when)
 
int rep_hist_have_measured_enough_stability (void)
 
void rep_hist_dump_stats (time_t now, int severity)
 
void rep_history_clean (time_t before)
 
int rep_hist_record_mtbf_data (time_t now, int missing_means_down)
 
static int find_next_with (smartlist_t *sl, int i, const char *prefix)
 
static int parse_possibly_bad_iso_time (const char *s, time_t *time_out)
 
static time_t correct_time (time_t t, time_t now, time_t stored_at, time_t started_measuring)
 
int rep_hist_load_mtbf_data (time_t now)
 
STATIC void commit_max (bw_array_t *b)
 
STATIC void advance_obs (bw_array_t *b)
 
static void add_obs (bw_array_t *b, time_t when, uint64_t n)
 
static bw_array_tbw_array_new (void)
 
static void bw_array_free_ (bw_array_t *b)
 
void rep_hist_note_bytes_written (uint64_t num_bytes, time_t when)
 
void rep_hist_note_bytes_read (uint64_t num_bytes, time_t when)
 
void rep_hist_note_dir_bytes_written (uint64_t num_bytes, time_t when)
 
void rep_hist_note_dir_bytes_read (uint64_t num_bytes, time_t when)
 
STATIC uint64_t find_largest_max (bw_array_t *b)
 
 MOCK_IMPL (int, rep_hist_bandwidth_assess,(void))
 
static size_t rep_hist_fill_bandwidth_history (char *buf, size_t len, const bw_array_t *b)
 
char * rep_hist_get_bandwidth_lines (void)
 
static void rep_hist_update_bwhist_state_section (or_state_t *state, const bw_array_t *b, smartlist_t **s_values, smartlist_t **s_maxima, time_t *s_begins, int *s_interval)
 
void rep_hist_update_state (or_state_t *state)
 
static int rep_hist_load_bwhist_state_section (bw_array_t *b, const smartlist_t *s_values, const smartlist_t *s_maxima, const time_t s_begins, const int s_interval)
 
int rep_hist_load_state (or_state_t *state, char **err)
 
void rep_hist_exit_stats_init (time_t now)
 
void rep_hist_reset_exit_stats (time_t now)
 
void rep_hist_exit_stats_term (void)
 
static int compare_int_ (const void *x, const void *y)
 
char * rep_hist_format_exit_stats (time_t now)
 
time_t rep_hist_exit_stats_write (time_t now)
 
void rep_hist_note_exit_bytes (uint16_t port, size_t num_written, size_t num_read)
 
void rep_hist_note_exit_stream_opened (uint16_t port)
 
void rep_hist_buffer_stats_init (time_t now)
 
void rep_hist_add_buffer_stats (double mean_num_cells_in_queue, double mean_time_cells_in_queue, uint32_t processed_cells)
 
void rep_hist_buffer_stats_add_circ (circuit_t *circ, time_t end_of_interval)
 
static int buffer_stats_compare_entries_ (const void **_a, const void **_b)
 
void rep_hist_buffer_stats_term (void)
 
void rep_hist_reset_buffer_stats (time_t now)
 
char * rep_hist_format_buffer_stats (time_t now)
 
time_t rep_hist_buffer_stats_write (time_t now)
 
void rep_hist_desc_stats_init (time_t now)
 
static void rep_hist_reset_desc_stats (time_t now)
 
void rep_hist_desc_stats_term (void)
 
static char * rep_hist_format_desc_stats (time_t now)
 
time_t rep_hist_desc_stats_write (time_t now)
 
void rep_hist_note_desc_served (const char *desc)
 
void rep_hist_conn_stats_init (time_t now)
 
static HT_HEAD (bidimap, bidi_map_entry_t)
 
static unsigned bidi_map_ent_hash (const bidi_map_entry_t *entry)
 
 HT_PROTOTYPE (HT_GENERATE2(bidimap, HT_GENERATE2(bidi_map_entry_t, HT_GENERATE2(node, HT_GENERATE2(bidi_map_ent_hash, HT_GENERATE2(bidi_map_ent_eq)
 
void rep_hist_reset_conn_stats (time_t now)
 
void rep_hist_conn_stats_term (void)
 
void rep_hist_note_or_conn_bytes (uint64_t conn_id, size_t num_read, size_t num_written, time_t when)
 
char * rep_hist_format_conn_stats (time_t now)
 
time_t rep_hist_conn_stats_write (time_t now)
 
void rep_hist_note_circuit_handshake_requested (uint16_t type)
 
void rep_hist_note_circuit_handshake_assigned (uint16_t type)
 
void rep_hist_log_circuit_handshake_stats (time_t now)
 
static hs_stats_ths_stats_new (void)
 
static void hs_stats_free_ (hs_stats_t *victim_hs_stats)
 
void rep_hist_hs_stats_init (time_t now)
 
static void rep_hist_reset_hs_stats (time_t now)
 
void rep_hist_hs_stats_term (void)
 
void rep_hist_seen_new_rp_cell (void)
 
void rep_hist_stored_maybe_new_hs (const crypto_pk_t *pubkey)
 
static char * rep_hist_format_hs_stats (time_t now)
 
time_t rep_hist_hs_stats_write (time_t now)
 
void rep_hist_note_negotiated_link_proto (unsigned link_proto, int started_here)
 
void rep_hist_padding_count_timers (uint64_t num_timers)
 
void rep_hist_padding_count_write (padding_type_t type)
 
void rep_hist_padding_count_read (padding_type_t type)
 
void rep_hist_reset_padding_counts (void)
 
void rep_hist_prep_published_padding_counts (time_t now)
 
char * rep_hist_get_padding_count_lines (void)
 
void rep_hist_log_link_protocol_counts (void)
 
void rep_hist_free_all (void)
 

Variables

uint64_t rephist_total_alloc =0
 
uint32_t rephist_total_num =0
 
static padding_counts_t padding_current
 
static padding_counts_t padding_published
 
static time_t stability_last_downrated = 0
 
static time_t started_tracking_stability = 0
 
static digestmap_t * history_map = NULL
 
static int n_bogus_times = 0
 
static bw_array_tread_array = NULL
 
STATIC bw_array_twrite_array = NULL
 
static bw_array_tdir_read_array = NULL
 
static bw_array_tdir_write_array = NULL
 
static uint64_t * exit_bytes_read = NULL
 
static uint64_t * exit_bytes_written = NULL
 
static uint32_t * exit_streams = NULL
 
static time_t start_of_exit_stats_interval
 
static time_t start_of_buffer_stats_interval
 
static smartlist_tcircuits_for_buffer_stats = NULL
 
static digestmap_t * served_descs = NULL
 
static unsigned long total_descriptor_downloads
 
static time_t start_of_served_descs_stats_interval
 
static time_t start_of_conn_stats_interval
 
static time_t bidi_next_interval = 0
 
static uint32_t below_threshold = 0
 
static uint32_t mostly_read = 0
 
static uint32_t mostly_written = 0
 
static uint32_t both_read_and_written = 0
 
static time_t start_of_hs_stats_interval
 
static hs_stats_ths_stats = NULL
 
static uint64_t link_proto_count [MAX_LINK_PROTO+1][2]
 
STATIC int onion_handshakes_requested [MAX_ONION_HANDSHAKE_TYPE+1] = {0}
 
STATIC int onion_handshakes_assigned [MAX_ONION_HANDSHAKE_TYPE+1] = {0}
 

Detailed Description

Basic history and performance-tracking functionality.

Basic history and performance-tracking functionality to remember which servers have worked in the past, how much bandwidth we've been using, which ports we tend to want, and so on; further, exit port statistics, cell statistics, and connection statistics.

The history and information tracked in this module could sensibly be divided into several categories:

The entry points for this module are scattered throughout the codebase. Sending data, receiving data, connecting to a relay, losing a connection to a relay, and so on can all trigger a change in our current stats. Relays also invoke this module in order to extract their statistics when building routerinfo and extrainfo objects in router.c.

TODO: This module should be broken up.

(The "rephist" name originally stood for "reputation and history". )

Definition in file rephist.c.

Macro Definition Documentation

◆ EXIT_STATS_NUM_PORTS

#define EXIT_STATS_NUM_PORTS   65536

Number of TCP ports

Definition at line 1538 of file rephist.c.

Referenced by rep_hist_reset_exit_stats().

◆ EXIT_STATS_ROUND_UP_BYTES

#define EXIT_STATS_ROUND_UP_BYTES   1024

To what multiple should byte numbers be rounded up?

Definition at line 1534 of file rephist.c.

◆ EXIT_STATS_ROUND_UP_STREAMS

#define EXIT_STATS_ROUND_UP_STREAMS   4

To what multiple should stream counts be rounded up?

Definition at line 1536 of file rephist.c.

◆ EXIT_STATS_TOP_N_PORTS

#define EXIT_STATS_TOP_N_PORTS   10

Top n ports that will be included in exit stats.

Definition at line 1540 of file rephist.c.

Referenced by rep_hist_format_exit_stats().

◆ LOAD

#define LOAD (   arrname,
  st 
)
Value:
(arrname), \
state->BWHistory ## st ## Values, \
state->BWHistory ## st ## Maxima, \
state->BWHistory ## st ## Ends, \
state->BWHistory ## st ## Interval)<0) \
all_ok = 0
static int rep_hist_load_bwhist_state_section(bw_array_t *b, const smartlist_t *s_values, const smartlist_t *s_maxima, const time_t s_begins, const int s_interval)
Definition: rephist.c:1422

◆ MIN_CELL_COUNTS_TO_PUBLISH

#define MIN_CELL_COUNTS_TO_PUBLISH   1

Copy our current cell counts into a structure for listing in our extra-info descriptor. Also perform appropriate rounding and redaction.

This function is called once every 24 hours.

Definition at line 2795 of file rephist.c.

◆ NUM_SECS_BW_SUM_INTERVAL

#define NUM_SECS_BW_SUM_INTERVAL   (24*60*60)

How large are the intervals for which we track and report bandwidth use?

Definition at line 980 of file rephist.c.

Referenced by commit_max(), and rep_hist_fill_bandwidth_history().

◆ NUM_SECS_BW_SUM_IS_VALID

#define NUM_SECS_BW_SUM_IS_VALID   (5*24*60*60)

How far in the past do we remember and publish bandwidth use?

Definition at line 982 of file rephist.c.

◆ NUM_SECS_ROLLING_MEASURE

#define NUM_SECS_ROLLING_MEASURE   10

For how many seconds do we keep track of individual per-second bandwidth totals?

Definition at line 978 of file rephist.c.

Referenced by advance_obs(), and MOCK_IMPL().

◆ NUM_TOTALS

How many bandwidth usage intervals do we remember? (derived)

Definition at line 984 of file rephist.c.

Referenced by commit_max(), find_largest_max(), and rep_hist_fill_bandwidth_history().

◆ ROUND_AND_SET_COUNT

#define ROUND_AND_SET_COUNT (   x)
Value:
ROUND_CELL_COUNTS_TO)
uint64_t round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor)
Definition: muldiv.c:50

◆ STABILITY_ALPHA

#define STABILITY_ALPHA   0.95

Value by which to discount all old intervals for MTBF purposes. This is compounded every STABILITY_INTERVAL.

Definition at line 113 of file rephist.c.

Referenced by rep_hist_downrate_old_runs().

◆ STABILITY_EPSILON

#define STABILITY_EPSILON   0.0001

If the total weighted run count of all runs for a router ever falls below this amount, the router can be treated as having 0 MTBF.

Definition at line 110 of file rephist.c.

Referenced by get_stability(), and rep_history_clean().

◆ STABILITY_INTERVAL

#define STABILITY_INTERVAL   (12*60*60)

Interval at which to discount all old intervals for MTBF purposes.

Definition at line 115 of file rephist.c.

Referenced by rep_hist_downrate_old_runs().

◆ UPDATE

#define UPDATE (   arrname,
  st 
)
Value:
(arrname),\
&state->BWHistory ## st ## Values, \
&state->BWHistory ## st ## Maxima, \
&state->BWHistory ## st ## Ends, \
&state->BWHistory ## st ## Interval)
static void rep_hist_update_bwhist_state_section(or_state_t *state, const bw_array_t *b, smartlist_t **s_values, smartlist_t **s_maxima, time_t *s_begins, int *s_interval)
Definition: rephist.c:1338

Typedef Documentation

◆ bidi_map_entry_t

Entry in a map from connection ID to the number of read and written bytes on this connection in a BIDI_INTERVAL second interval.

◆ circ_buffer_stats_t

Statistics from a single circuit. Collected when the circuit closes, or when we flush statistics to disk.

◆ hs_stats_t

typedef struct hs_stats_t hs_stats_t

Carries the various hidden service statistics, and any other information needed.

◆ or_history_t

typedef struct or_history_t or_history_t

History of an OR.

◆ padding_counts_t

This structure holds accounting needed to calculate the padding overhead.

Function Documentation

◆ add_obs()

static void add_obs ( bw_array_t b,
time_t  when,
uint64_t  n 
)
inlinestatic

◆ advance_obs()

STATIC void advance_obs ( bw_array_t b)

Shift the current observation time of b forward by one second.

Definition at line 1040 of file rephist.c.

References commit_max(), bw_array_t::cur_obs_idx, bw_array_t::cur_obs_time, bw_array_t::max_total, bw_array_t::next_period, NUM_SECS_ROLLING_MEASURE, bw_array_t::obs, and bw_array_t::total_obs.

Referenced by add_obs().

◆ buffer_stats_compare_entries_()

static int buffer_stats_compare_entries_ ( const void **  _a,
const void **  _b 
)
static

Sorting helper: return -1, 1, or 0 based on comparison of two circ_buffer_stats_t

Definition at line 1893 of file rephist.c.

References circ_buffer_stats_t::processed_cells.

◆ bw_array_free_()

static void bw_array_free_ ( bw_array_t b)
static

Free storage held by bandwidth array b.

Definition at line 1104 of file rephist.c.

References rephist_total_alloc, and tor_free.

◆ bw_array_new()

static bw_array_t* bw_array_new ( void  )
static

Allocate, initialize, and return a new bw_array.

Definition at line 1087 of file rephist.c.

◆ bw_arrays_init()

static void bw_arrays_init ( void  )
static

Set up [dir-]read_array and [dir-]write_array, freeing them if they already exist.

Definition at line 1128 of file rephist.c.

Referenced by rep_hist_init().

◆ commit_max()

STATIC void commit_max ( bw_array_t b)

◆ compare_int_()

static int compare_int_ ( const void *  x,
const void *  y 
)
static

Helper for qsort: compare two ints. Does not handle overflow properly, but works fine for sorting an array of port numbers, which is what we use it for.

Definition at line 1591 of file rephist.c.

◆ correct_time()

static time_t correct_time ( time_t  t,
time_t  now,
time_t  stored_at,
time_t  started_measuring 
)
inlinestatic

We've read a time t from a file stored at stored_at, which says we started measuring at started_measuring. Return a new number that's about as much before now as t was before stored_at.

Definition at line 769 of file rephist.c.

◆ find_largest_max()

STATIC uint64_t find_largest_max ( bw_array_t b)

Helper: Return the largest value in b->maxima. (This is equal to the most bandwidth used in any NUM_SECS_ROLLING_MEASURE period for the last NUM_SECS_BW_SUM_IS_VALID seconds.)

Definition at line 1195 of file rephist.c.

References bw_array_t::maxima, and NUM_TOTALS.

Referenced by MOCK_IMPL().

◆ find_next_with()

static int find_next_with ( smartlist_t sl,
int  i,
const char *  prefix 
)
static

Helper: return the first j >= i such that !strcmpstart(sl[j], prefix) and such that no line sl[k] with i <= k < j starts with "R ". Return -1 if no such line exists.

Definition at line 731 of file rephist.c.

◆ free_or_history()

static void free_or_history ( void *  _hist)
static

Helper: free storage held by a single OR history entry.

Definition at line 222 of file rephist.c.

References rephist_total_alloc, rephist_total_num, and tor_free.

Referenced by rep_history_clean().

◆ get_or_history()

static or_history_t* get_or_history ( const char *  id)
static

◆ get_stability()

static double get_stability ( or_history_t hist,
time_t  when 
)
static

Helper: Return the weighted MTBF of the router with history hist.

Definition at line 427 of file rephist.c.

References STABILITY_EPSILON, or_history_t::start_of_run, or_history_t::total_run_weights, and or_history_t::weighted_run_length.

Referenced by rep_hist_dump_stats(), and rep_hist_get_stability().

◆ get_total_weighted_time()

static long get_total_weighted_time ( or_history_t hist,
time_t  when 
)
static

Return the total amount of time we've been observing, with each run of time downrated by the appropriate factor.

Definition at line 449 of file rephist.c.

References or_history_t::start_of_run.

Referenced by rep_hist_get_weighted_time_known().

◆ get_weighted_fractional_uptime()

static double get_weighted_fractional_uptime ( or_history_t hist,
time_t  when 
)
static

Helper: Return the weighted percent-of-time-online of the router with history hist.

Definition at line 463 of file rephist.c.

References or_history_t::start_of_run.

Referenced by rep_hist_get_weighted_fractional_uptime().

◆ hs_stats_free_()

static void hs_stats_free_ ( hs_stats_t victim_hs_stats)
static

Free an hs_stats_t structure.

Definition at line 2508 of file rephist.c.

◆ hs_stats_new()

static hs_stats_t* hs_stats_new ( void  )
static

Allocate, initialize and return an hs_stats_t structure.

Definition at line 2495 of file rephist.c.

Referenced by rep_hist_hs_stats_init(), and rep_hist_reset_hs_stats().

◆ HT_HEAD()

static HT_HEAD ( bidimap  ,
bidi_map_entry_t   
)
static

Map of OR connections together with the number of read and written bytes in the current BIDI_INTERVAL second interval.

Definition at line 2271 of file rephist.c.

◆ MOCK_IMPL()

MOCK_IMPL ( int  ,
rep_hist_bandwidth_assess  ,
(void)   
)

Find the largest sums in the past NUM_SECS_BW_SUM_IS_VALID (roughly) seconds. Find one sum for reading and one for writing. They don't have to be at the same time.

Return the smaller of these sums, divided by NUM_SECS_ROLLING_MEASURE.

Definition at line 1213 of file rephist.c.

References find_largest_max(), NUM_SECS_ROLLING_MEASURE, read_array, and write_array.

◆ parse_possibly_bad_iso_time()

static int parse_possibly_bad_iso_time ( const char *  s,
time_t *  time_out 
)
static

Parse the ISO-formatted time in s into *time_out, but round any pre-1970 date to Jan 1, 1970.

Definition at line 748 of file rephist.c.

◆ rep_hist_add_buffer_stats()

void rep_hist_add_buffer_stats ( double  mean_num_cells_in_queue,
double  mean_time_cells_in_queue,
uint32_t  processed_cells 
)

Remember cell statistics mean_num_cells_in_queue, mean_time_cells_in_queue, and processed_cells of a circuit.

Definition at line 1838 of file rephist.c.

References start_of_buffer_stats_interval.

Referenced by rep_hist_buffer_stats_add_circ().

◆ rep_hist_buffer_stats_add_circ()

void rep_hist_buffer_stats_add_circ ( circuit_t circ,
time_t  end_of_interval 
)

Remember cell statistics for circuit circ at time end_of_interval and reset cell counters in case the circuit remains open in the next measurement interval.

Definition at line 1857 of file rephist.c.

References CIRCUIT_IS_ORIGIN, or_circuit_t::processed_cells, rep_hist_add_buffer_stats(), start_of_buffer_stats_interval, circuit_t::timestamp_created, TO_OR_CIRCUIT(), and or_circuit_t::total_cell_waiting_time.

◆ rep_hist_buffer_stats_init()

void rep_hist_buffer_stats_init ( time_t  now)

Initialize buffer stats.

Definition at line 1815 of file rephist.c.

References start_of_buffer_stats_interval.

◆ rep_hist_buffer_stats_term()

void rep_hist_buffer_stats_term ( void  )

Stop collecting cell stats in a way that we can re-start doing so in rep_hist_buffer_stats_init().

Definition at line 1907 of file rephist.c.

References rep_hist_reset_buffer_stats().

◆ rep_hist_buffer_stats_write()

time_t rep_hist_buffer_stats_write ( time_t  now)

If 24 hours have passed since the beginning of the current buffer stats period, write buffer stats to $DATADIR/stats/buffer-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write buffer stats or 0 if we never want to write.

Definition at line 2032 of file rephist.c.

References start_of_buffer_stats_interval.

◆ rep_hist_conn_stats_init()

void rep_hist_conn_stats_init ( time_t  now)

Initialize connection stats.

Definition at line 2222 of file rephist.c.

References start_of_conn_stats_interval.

◆ rep_hist_conn_stats_term()

void rep_hist_conn_stats_term ( void  )

Stop collecting connection stats in a way that we can re-start doing so in rep_hist_conn_stats_init().

Definition at line 2320 of file rephist.c.

References rep_hist_reset_conn_stats().

◆ rep_hist_conn_stats_write()

time_t rep_hist_conn_stats_write ( time_t  now)

If 24 hours have passed since the beginning of the current conn stats period, write conn stats to $DATADIR/stats/conn-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write conn stats or 0 if we never want to write.

Definition at line 2408 of file rephist.c.

References start_of_conn_stats_interval.

◆ rep_hist_desc_stats_init()

void rep_hist_desc_stats_init ( time_t  now)

Initialize descriptor stats.

Definition at line 2079 of file rephist.c.

References served_descs.

Referenced by rep_hist_reset_desc_stats().

◆ rep_hist_desc_stats_term()

void rep_hist_desc_stats_term ( void  )

Stop collecting served descs stats, so that rep_hist_desc_stats_init() is safe to be called again.

Definition at line 2102 of file rephist.c.

Referenced by rep_hist_reset_desc_stats().

◆ rep_hist_desc_stats_write()

time_t rep_hist_desc_stats_write ( time_t  now)

If WRITE_STATS_INTERVAL seconds have passed since the beginning of the current served desc stats interval, write the stats to $DATADIR/stats/served-desc-stats (possibly appending to an existing file) and reset the state for the next interval. Return when we would next want to write served desc stats or 0 if we won't want to write.

Definition at line 2169 of file rephist.c.

References start_of_served_descs_stats_interval.

◆ rep_hist_downrate_old_runs()

time_t rep_hist_downrate_old_runs ( time_t  now)

Helper: Discount all old MTBF data, if it is time to do so. Return the time at which we should next discount MTBF data.

Definition at line 382 of file rephist.c.

References history_map, STABILITY_ALPHA, STABILITY_INTERVAL, and stability_last_downrated.

Referenced by downrate_stability_callback().

◆ rep_hist_dump_stats()

void rep_hist_dump_stats ( time_t  now,
int  severity 
)

Log all the reliability data we have remembered, with the chosen severity.

Definition at line 554 of file rephist.c.

References base16_encode(), DIGEST_LEN, get_stability(), HEX_DIGEST_LEN, history_map, LD_HIST, node_get_nickname(), rep_history_clean(), and tor_log().

◆ rep_hist_exit_stats_init()

void rep_hist_exit_stats_init ( time_t  now)

Initialize exit port stats.

Definition at line 1558 of file rephist.c.

References exit_bytes_read, and start_of_exit_stats_interval.

◆ rep_hist_exit_stats_term()

void rep_hist_exit_stats_term ( void  )

Stop collecting exit port stats in a way that we can re-start doing so in rep_hist_exit_stats_init().

Definition at line 1579 of file rephist.c.

References exit_bytes_read, exit_bytes_written, exit_streams, start_of_exit_stats_interval, and tor_free.

◆ rep_hist_exit_stats_write()

time_t rep_hist_exit_stats_write ( time_t  now)

If 24 hours have passed since the beginning of the current exit port stats period, write exit stats to $DATADIR/stats/exit-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write exit stats or 0 if we never want to write.

Definition at line 1755 of file rephist.c.

References start_of_exit_stats_interval.

◆ rep_hist_fill_bandwidth_history()

static size_t rep_hist_fill_bandwidth_history ( char *  buf,
size_t  len,
const bw_array_t b 
)
static

Print the bandwidth history of b (either [dir-]read_array or [dir-]write_array) into the buffer pointed to by buf. The format is simply comma separated numbers, from oldest to newest.

It returns the number of bytes written.

Definition at line 1232 of file rephist.c.

References bw_array_t::next_max_idx, bw_array_t::num_maxes_set, NUM_SECS_BW_SUM_INTERVAL, NUM_TOTALS, or_options_t::RelayBandwidthRate, tor_assert(), tor_snprintf(), and bw_array_t::totals.

◆ rep_hist_format_buffer_stats()

char* rep_hist_format_buffer_stats ( time_t  now)

Return a newly allocated string containing the buffer statistics until now, or NULL if we're not collecting buffer stats. Caller must ensure start_of_buffer_stats_interval is in the past.

Definition at line 1929 of file rephist.c.

◆ rep_hist_format_conn_stats()

char* rep_hist_format_conn_stats ( time_t  now)

Return a newly allocated string containing the connection statistics until now, or NULL if we're not collecting conn stats. Caller must ensure start_of_conn_stats_interval is in the past.

Definition at line 2383 of file rephist.c.

◆ rep_hist_format_desc_stats()

static char* rep_hist_format_desc_stats ( time_t  now)
static

Helper for rep_hist_desc_stats_write(). Return a newly allocated string containing the served desc statistics until now, or NULL if we're not collecting served desc stats. Caller must ensure that now is not before start_of_served_descs_stats_interval.

Definition at line 2115 of file rephist.c.

◆ rep_hist_format_exit_stats()

char* rep_hist_format_exit_stats ( time_t  now)

Return a newly allocated string containing the exit port statistics until now, or NULL if we're not collecting exit stats. Caller must ensure start_of_exit_stats_interval is in the past.

Definition at line 1600 of file rephist.c.

References EXIT_STATS_TOP_N_PORTS.

◆ rep_hist_format_hs_stats()

static char* rep_hist_format_hs_stats ( time_t  now)
static

Allocate and return a string containing hidden service stats that are meant to be placed in the extra-info descriptor.

Definition at line 2620 of file rephist.c.

◆ rep_hist_free_all()

void rep_hist_free_all ( void  )

Free all storage held by the OR/link history caches, by the bandwidth history arrays, by the port history, or by statistics .

Definition at line 2899 of file rephist.c.

◆ rep_hist_get_bandwidth_lines()

char* rep_hist_get_bandwidth_lines ( void  )

Allocate and return lines for representing this server's bandwidth history in its descriptor. We publish these lines in our extra-info descriptor.

Definition at line 1281 of file rephist.c.

◆ rep_hist_get_padding_count_lines()

char* rep_hist_get_padding_count_lines ( void  )

Returns an allocated string for extra-info documents for publishing padding statistics from the last 24 hour interval.

Definition at line 2829 of file rephist.c.

References padding_counts_t::first_published_at, padding_published, padding_counts_t::read_cell_count, REPHIST_CELL_PADDING_COUNTS_INTERVAL, tor_asprintf(), and padding_counts_t::write_cell_count.

◆ rep_hist_get_stability()

double rep_hist_get_stability ( const char *  id,
time_t  when 
)

Return an estimated MTBF for the router whose identity digest is id. Return 0 if the router is unknown.

Definition at line 503 of file rephist.c.

References get_or_history(), and get_stability().

Referenced by dirserv_thinks_router_is_unreliable().

◆ rep_hist_get_uptime()

long rep_hist_get_uptime ( const char *  id,
time_t  when 
)

Return how long the router whose identity digest is id has been reachable. Return 0 if the router is unknown or currently deemed unreachable.

Definition at line 490 of file rephist.c.

References get_or_history(), and or_history_t::start_of_run.

◆ rep_hist_get_weighted_fractional_uptime()

double rep_hist_get_weighted_fractional_uptime ( const char *  id,
time_t  when 
)

Return an estimated percent-of-time-online for the router whose identity digest is id. Return 0 if the router is unknown.

Definition at line 515 of file rephist.c.

References get_or_history(), and get_weighted_fractional_uptime().

◆ rep_hist_get_weighted_time_known()

long rep_hist_get_weighted_time_known ( const char *  id,
time_t  when 
)

Return a number representing how long we've known about the router whose digest is id. Return 0 if the router is unknown.

Be careful: this measure increases monotonically as we know the router for longer and longer, but it doesn't increase linearly.

Definition at line 531 of file rephist.c.

References get_or_history(), and get_total_weighted_time().

◆ rep_hist_have_measured_enough_stability()

int rep_hist_have_measured_enough_stability ( void  )

Return true if we've been measuring MTBFs for long enough to pronounce on Stability.

Definition at line 543 of file rephist.c.

◆ rep_hist_hs_stats_init()

void rep_hist_hs_stats_init ( time_t  now)

Initialize hidden service statistics.

Definition at line 2520 of file rephist.c.

References hs_stats, hs_stats_new(), and start_of_hs_stats_interval.

◆ rep_hist_hs_stats_term()

void rep_hist_hs_stats_term ( void  )

Stop collecting hidden service stats in a way that we can re-start doing so in rep_hist_buffer_stats_init().

Definition at line 2549 of file rephist.c.

References rep_hist_reset_hs_stats().

◆ rep_hist_hs_stats_write()

time_t rep_hist_hs_stats_write ( time_t  now)

If 24 hours have passed since the beginning of the current HS stats period, write buffer stats to $DATADIR/stats/hidserv-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write buffer stats or 0 if we never want to write.

Definition at line 2666 of file rephist.c.

References start_of_hs_stats_interval.

◆ rep_hist_init()

void rep_hist_init ( void  )

Initialize the static data structures for tracking history.

Definition at line 232 of file rephist.c.

References bw_arrays_init(), and history_map.

Referenced by tor_init().

◆ rep_hist_load_bwhist_state_section()

static int rep_hist_load_bwhist_state_section ( bw_array_t b,
const smartlist_t s_values,
const smartlist_t s_maxima,
const time_t  s_begins,
const int  s_interval 
)
static

Load a single bw_array_t from its Values, Ends, Maxima, and Interval entries in an or_state_t. Done while reading the state file.

Definition at line 1422 of file rephist.c.

◆ rep_hist_load_mtbf_data()

int rep_hist_load_mtbf_data ( time_t  now)

Load MTBF data from disk. Returns 0 on success or recoverable error, -1 on failure.

Definition at line 789 of file rephist.c.

◆ rep_hist_load_state()

int rep_hist_load_state ( or_state_t state,
char **  err 
)

Set bandwidth history from the state file we just loaded.

Definition at line 1498 of file rephist.c.

References dir_read_array, dir_write_array, read_array, tor_assert(), and write_array.

◆ rep_hist_log_circuit_handshake_stats()

void rep_hist_log_circuit_handshake_stats ( time_t  now)

Log our onionskin statistics since the last time we were called.

Definition at line 2460 of file rephist.c.

◆ rep_hist_log_link_protocol_counts()

void rep_hist_log_link_protocol_counts ( void  )

Log a heartbeat message explaining how many connections of each link protocol version we have used.

Definition at line 2875 of file rephist.c.

◆ rep_hist_make_router_pessimal()

void rep_hist_make_router_pessimal ( const char *  id,
time_t  when 
)

Mark a router with ID id as non-Running, and retroactively declare that it has never been running: give it no stability and no WFU.

Definition at line 368 of file rephist.c.

References get_or_history(), rep_hist_note_router_unreachable(), tor_assert(), and or_history_t::weighted_run_length.

◆ rep_hist_note_bytes_read()

void rep_hist_note_bytes_read ( uint64_t  num_bytes,
time_t  when 
)

Remember that we wrote num_bytes bytes in second when. (like rep_hist_note_bytes_written() above)

Definition at line 1166 of file rephist.c.

References add_obs(), and read_array.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_bytes_written()

void rep_hist_note_bytes_written ( uint64_t  num_bytes,
time_t  when 
)

Remember that we read num_bytes bytes in second when.

Add num_bytes to the current running total for when.

when can go back to time, but it's safe to ignore calls earlier than the latest when you've heard of.

Definition at line 1149 of file rephist.c.

References add_obs(), and write_array.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_circuit_handshake_assigned()

void rep_hist_note_circuit_handshake_assigned ( uint16_t  type)

We've sent an onionskin (using the type handshake) to a cpuworker.

Definition at line 2452 of file rephist.c.

◆ rep_hist_note_circuit_handshake_requested()

void rep_hist_note_circuit_handshake_requested ( uint16_t  type)

A new onionskin (using the type handshake) has arrived.

Definition at line 2443 of file rephist.c.

◆ rep_hist_note_desc_served()

void rep_hist_note_desc_served ( const char *  desc)

Called to note that we've served a given descriptor (by digest). Increments the count of descriptors served, and the number of times we've served this descriptor.

Definition at line 2200 of file rephist.c.

References served_descs, and total_descriptor_downloads.

◆ rep_hist_note_dir_bytes_read()

void rep_hist_note_dir_bytes_read ( uint64_t  num_bytes,
time_t  when 
)

Remember that we read num_bytes directory bytes in second when. (like rep_hist_note_bytes_written() above)

Definition at line 1185 of file rephist.c.

References add_obs(), and dir_read_array.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_dir_bytes_written()

void rep_hist_note_dir_bytes_written ( uint64_t  num_bytes,
time_t  when 
)

Remember that we wrote num_bytes directory bytes in second when. (like rep_hist_note_bytes_written() above)

Definition at line 1176 of file rephist.c.

References add_obs(), and dir_write_array.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_exit_bytes()

void rep_hist_note_exit_bytes ( uint16_t  port,
size_t  num_written,
size_t  num_read 
)

Note that we wrote num_written bytes and read num_read bytes to/from an exit connection to port.

Definition at line 1785 of file rephist.c.

References exit_bytes_read, exit_bytes_written, and start_of_exit_stats_interval.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_exit_stream_opened()

void rep_hist_note_exit_stream_opened ( uint16_t  port)

Note that we opened an exit stream to port.

Definition at line 1799 of file rephist.c.

References exit_streams, and start_of_exit_stats_interval.

◆ rep_hist_note_negotiated_link_proto()

void rep_hist_note_negotiated_link_proto ( unsigned  link_proto,
int  started_here 
)

Note that we negotiated link protocol version link_proto, on a connection that started here iff started_here is true.

Definition at line 2701 of file rephist.c.

◆ rep_hist_note_or_conn_bytes()

void rep_hist_note_or_conn_bytes ( uint64_t  conn_id,
size_t  num_read,
size_t  num_written,
time_t  when 
)

We read num_read bytes and wrote num_written from/to OR connection conn_id in second when. If this is the first observation in a new interval, sum up the last observations. Add bytes for this connection.

Definition at line 2330 of file rephist.c.

References bidi_next_interval, and start_of_conn_stats_interval.

Referenced by record_num_bytes_transferred_impl().

◆ rep_hist_note_router_reachable()

void rep_hist_note_router_reachable ( const char *  id,
const tor_addr_t at_addr,
const uint16_t  at_port,
time_t  when 
)

We have just decided that this router with identity digest id is reachable, meaning we will give it a "Running" flag for the next while.

Definition at line 241 of file rephist.c.

References get_or_history().

◆ rep_hist_note_router_unreachable()

void rep_hist_note_router_unreachable ( const char *  id,
time_t  when 
)

We have just decided that this router is unreachable, meaning we are taking away its "Running" flag.

Definition at line 314 of file rephist.c.

References get_or_history().

Referenced by rep_hist_make_router_pessimal().

◆ rep_hist_padding_count_read()

void rep_hist_padding_count_read ( padding_type_t  type)

Count a cell that we've received for padding overhead statistics.

RELAY_COMMAND_DROP and CELL_PADDING are accounted separately. Both should be counted for PADDING_TYPE_TOTAL.

Definition at line 2759 of file rephist.c.

◆ rep_hist_padding_count_timers()

void rep_hist_padding_count_timers ( uint64_t  num_timers)

Update the maximum count of total pending channel padding timers in this period.

Definition at line 2717 of file rephist.c.

References padding_counts_t::maximum_chanpad_timers, and padding_current.

◆ rep_hist_padding_count_write()

void rep_hist_padding_count_write ( padding_type_t  type)

Count a cell that we sent for padding overhead statistics.

RELAY_COMMAND_DROP and CELL_PADDING are accounted separately. Both should be counted for PADDING_TYPE_TOTAL.

Definition at line 2731 of file rephist.c.

◆ rep_hist_record_mtbf_data()

int rep_hist_record_mtbf_data ( time_t  now,
int  missing_means_down 
)

Write MTBF data to disk. Return 0 on success, negative on failure.

If missing_means_down, then if we're about to write an entry that is still considered up but isn't in our routerlist, consider it to be down.

Definition at line 626 of file rephist.c.

Referenced by save_stability_callback().

◆ rep_hist_reset_buffer_stats()

void rep_hist_reset_buffer_stats ( time_t  now)

Clear history of circuit statistics and set the measurement interval start to now.

Definition at line 1915 of file rephist.c.

References circuits_for_buffer_stats, smartlist_clear(), SMARTLIST_FOREACH, start_of_buffer_stats_interval, and tor_free.

Referenced by rep_hist_buffer_stats_term().

◆ rep_hist_reset_conn_stats()

void rep_hist_reset_conn_stats ( time_t  now)

Reset counters for conn statistics.

Definition at line 2307 of file rephist.c.

References below_threshold, both_read_and_written, mostly_read, mostly_written, and start_of_conn_stats_interval.

Referenced by rep_hist_conn_stats_term().

◆ rep_hist_reset_desc_stats()

static void rep_hist_reset_desc_stats ( time_t  now)
static

Reset served descs stats to empty, starting a new interval now.

Definition at line 2093 of file rephist.c.

References rep_hist_desc_stats_init(), and rep_hist_desc_stats_term().

◆ rep_hist_reset_exit_stats()

void rep_hist_reset_exit_stats ( time_t  now)

Reset counters for exit port statistics.

Definition at line 1568 of file rephist.c.

References exit_bytes_read, exit_bytes_written, EXIT_STATS_NUM_PORTS, exit_streams, and start_of_exit_stats_interval.

◆ rep_hist_reset_hs_stats()

static void rep_hist_reset_hs_stats ( time_t  now)
static

Clear history of hidden service statistics and set the measurement interval start to now.

Definition at line 2532 of file rephist.c.

References hs_stats, hs_stats_new(), and hs_stats_t::rp_relay_cells_seen.

Referenced by rep_hist_hs_stats_term().

◆ rep_hist_reset_padding_counts()

void rep_hist_reset_padding_counts ( void  )

Reset our current padding statistics. Called once every 24 hours.

Definition at line 2784 of file rephist.c.

References padding_current.

◆ rep_hist_seen_new_rp_cell()

void rep_hist_seen_new_rp_cell ( void  )

We saw a new HS relay cell, Count it!

Definition at line 2556 of file rephist.c.

References hs_stats, and hs_stats_t::rp_relay_cells_seen.

◆ rep_hist_stored_maybe_new_hs()

void rep_hist_stored_maybe_new_hs ( const crypto_pk_t pubkey)

As HSDirs, we saw another hidden service with public key pubkey. Check whether we have counted it before, if not count it now!

Definition at line 2569 of file rephist.c.

References crypto_pk_get_digest(), DIGEST_LEN, hs_stats, and hs_stats_t::onions_seen_this_period.

◆ rep_hist_update_bwhist_state_section()

static void rep_hist_update_bwhist_state_section ( or_state_t state,
const bw_array_t b,
smartlist_t **  s_values,
smartlist_t **  s_maxima,
time_t *  s_begins,
int *  s_interval 
)
static

Write a single bw_array_t into the Values, Ends, Interval, and Maximum entries of an or_state_t. Done before writing out a new state file.

Definition at line 1338 of file rephist.c.

References SMARTLIST_FOREACH, and tor_free.

◆ rep_hist_update_state()

void rep_hist_update_state ( or_state_t state)

Update state with the newest bandwidth history. Done before writing out a new state file.

Definition at line 1398 of file rephist.c.

◆ rep_history_clean()

void rep_history_clean ( time_t  before)

Remove history info for routers/links that haven't changed since before.

Definition at line 593 of file rephist.c.

References authdir_mode(), or_history_t::changed, free_or_history(), history_map, STABILITY_EPSILON, or_history_t::start_of_run, and or_history_t::total_run_weights.

Referenced by clean_caches_callback(), and rep_hist_dump_stats().

Variable Documentation

◆ below_threshold

uint32_t below_threshold = 0
static

Number of connections that we read and wrote less than BIDI_THRESHOLD bytes from/to in BIDI_INTERVAL seconds.

Definition at line 2245 of file rephist.c.

Referenced by rep_hist_reset_conn_stats().

◆ bidi_next_interval

time_t bidi_next_interval = 0
static

Start of next BIDI_INTERVAL second interval.

Definition at line 2241 of file rephist.c.

Referenced by rep_hist_note_or_conn_bytes().

◆ both_read_and_written

uint32_t both_read_and_written = 0
static

Number of connections that we read and wrote at least BIDI_THRESHOLD bytes from/to, but not BIDI_FACTOR times more in either direction in BIDI_INTERVAL seconds.

Definition at line 2258 of file rephist.c.

Referenced by rep_hist_reset_conn_stats().

◆ circuits_for_buffer_stats

smartlist_t* circuits_for_buffer_stats = NULL
static

List of circ_buffer_stats_t.

Definition at line 1832 of file rephist.c.

Referenced by rep_hist_reset_buffer_stats().

◆ dir_read_array

bw_array_t* dir_read_array = NULL
static

Recent history of bandwidth observations for read operations for the directory protocol.

Definition at line 1120 of file rephist.c.

Referenced by rep_hist_load_state(), and rep_hist_note_dir_bytes_read().

◆ dir_write_array

bw_array_t* dir_write_array = NULL
static

Recent history of bandwidth observations for write operations for the directory protocol.

Definition at line 1123 of file rephist.c.

Referenced by rep_hist_load_state(), and rep_hist_note_dir_bytes_written().

◆ exit_bytes_read

uint64_t* exit_bytes_read = NULL
static

Number of bytes read in current period by exit port

Definition at line 1547 of file rephist.c.

Referenced by rep_hist_exit_stats_init(), rep_hist_exit_stats_term(), rep_hist_note_exit_bytes(), and rep_hist_reset_exit_stats().

◆ exit_bytes_written

uint64_t* exit_bytes_written = NULL
static

Number of bytes written in current period by exit port

Definition at line 1549 of file rephist.c.

Referenced by rep_hist_exit_stats_term(), rep_hist_note_exit_bytes(), and rep_hist_reset_exit_stats().

◆ exit_streams

uint32_t* exit_streams = NULL
static

Number of streams opened in current period by exit port

Definition at line 1551 of file rephist.c.

Referenced by rep_hist_exit_stats_term(), rep_hist_note_exit_stream_opened(), and rep_hist_reset_exit_stats().

◆ history_map

digestmap_t* history_map = NULL
static

Map from hex OR identity digest to or_history_t.

Definition at line 196 of file rephist.c.

Referenced by get_or_history(), rep_hist_downrate_old_runs(), rep_hist_dump_stats(), rep_hist_init(), and rep_history_clean().

◆ hs_stats

hs_stats_t* hs_stats = NULL
static

Our statistics structure singleton.

Definition at line 2491 of file rephist.c.

Referenced by rep_hist_hs_stats_init(), rep_hist_reset_hs_stats(), rep_hist_seen_new_rp_cell(), and rep_hist_stored_maybe_new_hs().

◆ mostly_read

uint32_t mostly_read = 0
static

Number of connections that we read at least BIDI_FACTOR times more bytes from than we wrote to in BIDI_INTERVAL seconds.

Definition at line 2249 of file rephist.c.

Referenced by rep_hist_reset_conn_stats().

◆ mostly_written

uint32_t mostly_written = 0
static

Number of connections that we wrote at least BIDI_FACTOR times more bytes to than we read from in BIDI_INTERVAL seconds.

Definition at line 2253 of file rephist.c.

Referenced by rep_hist_reset_conn_stats().

◆ n_bogus_times

int n_bogus_times = 0
static

How many bad times has parse_possibly_bad_iso_time() parsed?

Definition at line 744 of file rephist.c.

◆ onion_handshakes_requested

STATIC int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1] = {0}

Internal statistics to track how many requests of each type of handshake we've received, and how many we've assigned to cpuworkers. Useful for seeing trends in cpu load.

Definition at line 2437 of file rephist.c.

◆ padding_current

padding_counts_t padding_current
static

Holds the current values of our padding statistics. It is not published until it is transferred to padding_published.

Definition at line 182 of file rephist.c.

Referenced by rep_hist_padding_count_timers(), and rep_hist_reset_padding_counts().

◆ padding_published

padding_counts_t padding_published
static

Remains fixed for a 24 hour period, and then is replaced by a redacted copy of padding_current

Definition at line 186 of file rephist.c.

Referenced by rep_hist_get_padding_count_lines().

◆ read_array

bw_array_t* read_array = NULL
static

Recent history of bandwidth observations for read operations.

Definition at line 1115 of file rephist.c.

Referenced by MOCK_IMPL(), rep_hist_load_state(), and rep_hist_note_bytes_read().

◆ rephist_total_alloc

uint64_t rephist_total_alloc =0

Total number of bytes currently allocated in fields used by rephist.c.

Definition at line 104 of file rephist.c.

Referenced by bw_array_free_(), dumpmemusage(), and free_or_history().

◆ rephist_total_num

uint32_t rephist_total_num =0

Number of or_history_t objects currently allocated.

Definition at line 106 of file rephist.c.

Referenced by dumpmemusage(), and free_or_history().

◆ served_descs

digestmap_t* served_descs = NULL
static

Digestmap to track which descriptors were downloaded this stats collection interval. It maps descriptor digest to pointers to 1, effectively turning this into a list.

Definition at line 2068 of file rephist.c.

Referenced by rep_hist_desc_stats_init(), and rep_hist_note_desc_served().

◆ stability_last_downrated

time_t stability_last_downrated = 0
static

When did we last multiply all routers' weighted_run_length and total_run_weights by STABILITY_ALPHA?

Definition at line 190 of file rephist.c.

Referenced by rep_hist_downrate_old_runs().

◆ start_of_buffer_stats_interval

time_t start_of_buffer_stats_interval
static

Start of the current buffer stats interval or 0 if we're not collecting buffer statistics.

Definition at line 1811 of file rephist.c.

Referenced by rep_hist_add_buffer_stats(), rep_hist_buffer_stats_add_circ(), rep_hist_buffer_stats_init(), rep_hist_buffer_stats_write(), and rep_hist_reset_buffer_stats().

◆ start_of_conn_stats_interval

time_t start_of_conn_stats_interval
static

Start of the current connection stats interval or 0 if we're not collecting connection statistics.

Definition at line 2218 of file rephist.c.

Referenced by rep_hist_conn_stats_init(), rep_hist_conn_stats_write(), rep_hist_note_or_conn_bytes(), and rep_hist_reset_conn_stats().

◆ start_of_exit_stats_interval

time_t start_of_exit_stats_interval
static

Start time of exit stats or 0 if we're not collecting exit stats.

Definition at line 1554 of file rephist.c.

Referenced by rep_hist_exit_stats_init(), rep_hist_exit_stats_term(), rep_hist_exit_stats_write(), rep_hist_note_exit_bytes(), rep_hist_note_exit_stream_opened(), and rep_hist_reset_exit_stats().

◆ start_of_hs_stats_interval

time_t start_of_hs_stats_interval
static

Start of the current hidden service stats interval or 0 if we're not collecting hidden service statistics.

Definition at line 2477 of file rephist.c.

Referenced by rep_hist_hs_stats_init(), and rep_hist_hs_stats_write().

◆ start_of_served_descs_stats_interval

time_t start_of_served_descs_stats_interval
static

Start time of served descs stats or 0 if we're not collecting those.

Definition at line 2075 of file rephist.c.

Referenced by rep_hist_desc_stats_write().

◆ total_descriptor_downloads

unsigned long total_descriptor_downloads
static

Number of how many descriptors were downloaded in total during this interval.

Definition at line 2072 of file rephist.c.

Referenced by rep_hist_note_desc_served().

◆ write_array

STATIC bw_array_t* write_array = NULL

Recent history of bandwidth observations for write operations.

Definition at line 1117 of file rephist.c.

Referenced by MOCK_IMPL(), rep_hist_load_state(), and rep_hist_note_bytes_written().