tor  master
Data Structures | Macros | Typedefs | Functions | Variables
rephist.c File Reference

Basic history and performance-tracking functionality. More...

#include "or.h"
#include "circuitlist.h"
#include "circuituse.h"
#include "config.h"
#include "crypto_rand.h"
#include "networkstatus.h"
#include "nodelist.h"
#include "rephist.h"
#include "router.h"
#include "routerlist.h"
#include "ht.h"
#include "channelpadding.h"
#include "connection_or.h"
#include "statefile.h"
Include dependency graph for rephist.c:

Data Structures

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

Macros

#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 bw_array_t bw_array_t
 
typedef struct predicted_port_t predicted_port_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

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)
 
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)
 
int rep_hist_load_mtbf_data (time_t now)
 
void rep_hist_note_bytes_written (size_t num_bytes, time_t when)
 
void rep_hist_note_bytes_read (size_t num_bytes, time_t when)
 
void rep_hist_note_dir_bytes_written (size_t num_bytes, time_t when)
 
void rep_hist_note_dir_bytes_read (size_t num_bytes, time_t when)
 
int rep_hist_bandwidth_assess (void)
 
char * rep_hist_get_bandwidth_lines (void)
 
void rep_hist_update_state (or_state_t *state)
 
int rep_hist_load_state (or_state_t *state, char **err)
 
int predicted_ports_prediction_time_remaining (time_t now)
 
void predicted_ports_init (void)
 
void rep_hist_note_used_port (time_t now, uint16_t port)
 
smartlist_trep_hist_get_predicted_ports (time_t now)
 
void rep_hist_remove_predicted_ports (const smartlist_t *rmv_ports)
 
void rep_hist_note_used_resolve (time_t now)
 
void rep_hist_note_used_internal (time_t now, int need_uptime, int need_capacity)
 
int rep_hist_get_predicted_internal (time_t now, int *need_uptime, int *need_capacity)
 
int any_predicted_circuits (time_t now)
 
int rep_hist_circbuilding_dormant (time_t now)
 
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)
 
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)
 
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)
 
void rep_hist_desc_stats_term (void)
 
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)
 
 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)
 
void rep_hist_hs_stats_init (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)
 
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 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". )

Macro Definition Documentation

◆ EXIT_STATS_NUM_PORTS

#define EXIT_STATS_NUM_PORTS   65536

Number of TCP ports

◆ EXIT_STATS_ROUND_UP_BYTES

#define EXIT_STATS_ROUND_UP_BYTES   1024

To what multiple should byte numbers be rounded up?

◆ EXIT_STATS_ROUND_UP_STREAMS

#define EXIT_STATS_ROUND_UP_STREAMS   4

To what multiple should stream counts be rounded up?

◆ EXIT_STATS_TOP_N_PORTS

#define EXIT_STATS_TOP_N_PORTS   10

Top n ports that will be included in exit stats.

◆ LOAD

#define LOAD (   arrname,
  st 
)
Value:
if (rep_hist_load_bwhist_state_section( \
(arrname), \
state->BWHistory ## st ## Values, \
state->BWHistory ## st ## Maxima, \
state->BWHistory ## st ## Ends, \
state->BWHistory ## st ## Interval)<0) \
all_ok = 0

◆ 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.

◆ 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?

◆ 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?

◆ NUM_SECS_ROLLING_MEASURE

#define NUM_SECS_ROLLING_MEASURE   10

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

◆ NUM_TOTALS

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

◆ 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: util.c:511

◆ STABILITY_ALPHA

#define STABILITY_ALPHA   0.95

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

◆ 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.

◆ STABILITY_INTERVAL

#define STABILITY_INTERVAL   (12*60*60)

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

◆ UPDATE

#define UPDATE (   arrname,
  st 
)
Value:
rep_hist_update_bwhist_state_section(state,\
(arrname),\
&state->BWHistory ## st ## Values, \
&state->BWHistory ## st ## Maxima, \
&state->BWHistory ## st ## Ends, \
&state->BWHistory ## st ## Interval)

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.

◆ bw_array_t

typedef struct bw_array_t bw_array_t

Structure to track bandwidth use, and remember the maxima for a given time period.

◆ 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.

◆ predicted_port_t

A single predicted port: used to remember which ports we've made connections to, so that we can try to keep making circuits that can handle those ports.

Function Documentation

◆ any_predicted_circuits()

int any_predicted_circuits ( time_t  now)

Any ports used lately? These are pre-seeded if we just started up or if we're running a hidden service.

Here is the caller graph for this function:

◆ predicted_ports_prediction_time_remaining()

int predicted_ports_prediction_time_remaining ( time_t  now)

How much time left until we stop predicting circuits?

◆ 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.

◆ rep_hist_bandwidth_assess()

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.

◆ 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.

◆ rep_hist_buffer_stats_init()

void rep_hist_buffer_stats_init ( time_t  now)

Initialize buffer stats.

◆ 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().

Here is the call graph for this function:

◆ 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.

◆ rep_hist_circbuilding_dormant()

int rep_hist_circbuilding_dormant ( time_t  now)

Return 1 if we have no need for circuits currently, else return 0.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rep_hist_conn_stats_init()

void rep_hist_conn_stats_init ( time_t  now)

Initialize connection stats.

◆ 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().

Here is the call graph for this function:

◆ 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.

◆ rep_hist_desc_stats_init()

void rep_hist_desc_stats_init ( time_t  now)

Initialize descriptor 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.

◆ 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.

◆ 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.

◆ 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.

Here is the call graph for this function:

◆ rep_hist_exit_stats_init()

void rep_hist_exit_stats_init ( time_t  now)

Initialize exit port stats.

◆ 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().

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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 .

◆ 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.

◆ 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.

Here is the call graph for this function:

◆ rep_hist_get_predicted_internal()

int rep_hist_get_predicted_internal ( time_t  now,
int *  need_uptime,
int *  need_capacity 
)

Return 1 if we've used an internal circ recently; else return 0.

◆ rep_hist_get_predicted_ports()

smartlist_t* rep_hist_get_predicted_ports ( time_t  now)

Return a newly allocated pointer to a list of uint16_t * for ports that are likely to be asked for in the near future.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ rep_hist_hs_stats_init()

void rep_hist_hs_stats_init ( time_t  now)

Initialize hidden service statistics.

◆ 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().

◆ 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.

◆ rep_hist_init()

void rep_hist_init ( void  )

Initialize the static data structures for tracking history.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ rep_hist_note_bytes_read()

void rep_hist_note_bytes_read ( size_t  num_bytes,
time_t  when 
)

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

◆ rep_hist_note_bytes_written()

void rep_hist_note_bytes_written ( size_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.

◆ 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.

◆ 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.

◆ 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.

◆ rep_hist_note_dir_bytes_read()

void rep_hist_note_dir_bytes_read ( size_t  num_bytes,
time_t  when 
)

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

◆ rep_hist_note_dir_bytes_written()

void rep_hist_note_dir_bytes_written ( size_t  num_bytes,
time_t  when 
)

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

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

Here is the caller graph for this function:

◆ rep_hist_note_used_internal()

void rep_hist_note_used_internal ( time_t  now,
int  need_uptime,
int  need_capacity 
)

Remember that we used an internal circ at time now.

Here is the call graph for this function:

◆ rep_hist_note_used_port()

void rep_hist_note_used_port ( time_t  now,
uint16_t  port 
)

Remember that port has been asked for as of time now. This is used for predicting what sorts of streams we'll make in the future and making exit circuits to anticipate that.

Here is the caller graph for this function:

◆ rep_hist_note_used_resolve()

void rep_hist_note_used_resolve ( time_t  now)

The user asked us to do a resolve. Rather than keeping track of timings and such of resolves, we fake it for now by treating it the same way as a connection to port 80. This way we will continue to have circuits lying around if the user only uses Tor for resolves.

Here is the call graph for this function:

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ rep_hist_remove_predicted_ports()

void rep_hist_remove_predicted_ports ( const smartlist_t rmv_ports)

Take a list of uint16_t *, and remove every port in the list from the current list of predicted ports.

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rep_hist_reset_conn_stats()

void rep_hist_reset_conn_stats ( time_t  now)

Reset counters for conn statistics.

Here is the caller graph for this function:

◆ rep_hist_reset_exit_stats()

void rep_hist_reset_exit_stats ( time_t  now)

Reset counters for exit port statistics.

◆ rep_hist_reset_padding_counts()

void rep_hist_reset_padding_counts ( void  )

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

◆ rep_hist_seen_new_rp_cell()

void rep_hist_seen_new_rp_cell ( void  )

We saw a new HS relay cell, Count it!

◆ 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!

Here is the call graph for this function:

◆ 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.

◆ rep_history_clean()

void rep_history_clean ( time_t  before)

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

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ 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.

◆ rephist_total_alloc

uint64_t rephist_total_alloc =0

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

◆ rephist_total_num

uint32_t rephist_total_num =0

Number of or_history_t objects currently allocated.