rephist.c File Reference

Basic history and "reputation" 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. More...

#include "or.h"
#include "ht.h"

Data Structures

struct  link_history_t
struct  or_history_t
struct  bw_array_t
struct  circ_buffer_stats_t

Defines

#define STABILITY_EPSILON   0.0001
#define STABILITY_ALPHA   0.95
#define STABILITY_INTERVAL   (12*60*60)
#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 MAX_STABILITY_DOC_BUILD_RATE   (3*60)
#define NUM_SECS_ROLLING_MEASURE   10
#define NUM_SECS_BW_SUM_INTERVAL   (15*60)
#define NUM_SECS_BW_SUM_IS_VALID   (24*60*60)
#define NUM_TOTALS   (NUM_SECS_BW_SUM_IS_VALID/NUM_SECS_BW_SUM_INTERVAL)
#define EXIT_STATS_ROUND_UP_BYTES   1024
#define EXIT_STATS_ROUND_UP_STREAMS   4
#define EXIT_STATS_NUM_PORTS   65536
#define EXIT_STATS_THRESHOLD_RECIPROCAL   10000
#define PREDICTED_CIRCS_RELEVANCE_TIME   (60*60)
#define SHARES   10

Functions

static void bw_arrays_init (void)
static void predicted_ports_init (void)
static or_history_tget_or_history (const char *id)
static link_history_tget_link_history (const char *from_id, const char *to_id)
static void _free_link_history (void *val)
static void free_or_history (void *_hist)
static void update_or_history (or_history_t *hist, time_t when)
void rep_hist_init (void)
static void mark_or_down (or_history_t *hist, time_t when, int failed)
static void mark_or_up (or_history_t *hist, time_t when)
void rep_hist_note_connect_failed (const char *id, time_t when)
void rep_hist_note_connect_succeeded (const char *id, time_t when)
void rep_hist_note_disconnect (const char *id, time_t when)
void rep_hist_note_connection_died (const char *id, time_t when)
void rep_hist_note_router_reachable (const char *id, time_t when)
void rep_hist_note_router_unreachable (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)
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_note_extend_succeeded (const char *from_id, const char *to_id)
void rep_hist_note_extend_failed (const char *from_id, const char *to_id)
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 char * rep_hist_format_router_status (or_history_t *hist, time_t now)
const char * rep_hist_get_router_stability_doc (time_t now)
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 INLINE 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 INLINE void advance_obs (bw_array_t *b)
static INLINE void add_obs (bw_array_t *b, time_t when, uint64_t n)
static bw_array_tbw_array_new (void)
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_exit_stats_init (time_t now)
void rep_hist_exit_stats_write (time_t now)
void rep_hist_note_exit_bytes_written (uint16_t port, size_t num_bytes)
void rep_hist_note_exit_bytes_read (uint16_t port, size_t num_bytes)
void rep_hist_note_exit_stream_opened (uint16_t port)
static uint64_t find_largest_max (bw_array_t *b)
int rep_hist_bandwidth_assess (void)
static size_t rep_hist_fill_bandwidth_history (char *buf, size_t len, bw_array_t *b)
char * rep_hist_get_bandwidth_lines (int for_extrainfo)
void rep_hist_update_state (or_state_t *state)
int rep_hist_load_state (or_state_t *state, char **err)
static void add_predicted_port (time_t now, uint16_t port)
static void predicted_ports_free (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_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 note_crypto_pk_op (pk_op_t operation)
void dump_pk_ops (int severity)
void rep_hist_free_all (void)
void rep_hist_buffer_stats_init (time_t now)
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_write (time_t now)

Variables

uint64_t rephist_total_alloc = 0
uint32_t rephist_total_num = 0
static time_t stability_last_downrated = 0
static time_t started_tracking_stability = 0
static digestmap_t * history_map = NULL
static char * last_stability_doc = NULL
static time_t built_last_stability_doc_at = 0
static int n_bogus_times = 0
static bw_array_tread_array = NULL
static bw_array_twrite_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 smartlist_tpredicted_ports_list = NULL
static smartlist_tpredicted_ports_times = NULL
static time_t predicted_internal_time = 0
static time_t predicted_internal_uptime_time = 0
static time_t predicted_internal_capacity_time = 0
struct {
   unsigned long   n_signed_dir_objs
   unsigned long   n_signed_routerdescs
   unsigned long   n_verified_dir_objs
   unsigned long   n_verified_routerdescs
   unsigned long   n_onionskins_encrypted
   unsigned long   n_onionskins_decrypted
   unsigned long   n_tls_client_handshakes
   unsigned long   n_tls_server_handshakes
   unsigned long   n_rend_client_ops
   unsigned long   n_rend_mid_ops
   unsigned long   n_rend_server_ops
pk_op_counts
static time_t start_of_buffer_stats_interval
smartlist_tcircuits_for_buffer_stats = NULL


Detailed Description

Basic history and "reputation" 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.


Define Documentation

#define EXIT_STATS_NUM_PORTS   65536

Number of TCP ports

Referenced by rep_hist_exit_stats_init(), and rep_hist_exit_stats_write().

#define EXIT_STATS_ROUND_UP_BYTES   1024

To what multiple should byte numbers be rounded up?

Referenced by rep_hist_exit_stats_write().

#define EXIT_STATS_ROUND_UP_STREAMS   4

To what multiple should stream counts be rounded up?

Referenced by rep_hist_exit_stats_write().

#define EXIT_STATS_THRESHOLD_RECIPROCAL   10000

Reciprocal of threshold (= 0.01%) of total bytes that a port needs to see in order to be included in exit stats.

Referenced by rep_hist_exit_stats_write().

#define MAX_STABILITY_DOC_BUILD_RATE   (3*60)

Shortest allowable time between building two stability documents.

Referenced by rep_hist_get_router_stability_doc().

#define NUM_SECS_BW_SUM_INTERVAL   (15*60)

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

Referenced by bw_array_new(), commit_max(), rep_hist_fill_bandwidth_history(), rep_hist_get_bandwidth_lines(), rep_hist_load_state(), and rep_hist_update_state().

#define NUM_SECS_BW_SUM_IS_VALID   (24*60*60)

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

#define NUM_SECS_ROLLING_MEASURE   10

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

Referenced by advance_obs(), rep_hist_bandwidth_assess(), and rep_hist_load_state().

#define NUM_TOTALS   (NUM_SECS_BW_SUM_IS_VALID/NUM_SECS_BW_SUM_INTERVAL)

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

Referenced by commit_max(), find_largest_max(), rep_hist_fill_bandwidth_history(), rep_hist_get_bandwidth_lines(), rep_hist_load_state(), and rep_hist_update_state().

#define PREDICTED_CIRCS_RELEVANCE_TIME   (60*60)

For this long after we've seen a request for a given port, assume that we'll want to make connections to the same port in the future.

Referenced by any_predicted_circuits(), rep_hist_get_predicted_internal(), and rep_hist_get_predicted_ports().

#define STABILITY_ALPHA   0.95

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

Referenced by rep_hist_downrate_old_runs().

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

Referenced by get_stability(), and rep_history_clean().

#define STABILITY_INTERVAL   (12*60*60)

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

Referenced by rep_hist_downrate_old_runs().


Function Documentation

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

Referenced by rep_hist_buffer_stats_write().

static void _free_link_history ( void *  val  )  [static]

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

References rephist_total_alloc, and tor_free.

Referenced by free_or_history().

static INLINE void add_obs ( bw_array_t b,
time_t  when,
uint64_t  n 
) [static]

static void add_predicted_port ( time_t  now,
uint16_t  port 
) [static]

We just got an application request for a connection with port port. Remember it for the future, so we can keep some circuits open that will exit to this port.

References rephist_total_alloc, and smartlist_add().

Referenced by predicted_ports_init(), and rep_hist_note_used_port().

static INLINE void advance_obs ( bw_array_t b  )  [static]

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.

References PREDICTED_CIRCS_RELEVANCE_TIME, and predicted_internal_time.

Referenced by directory_info_has_arrived(), options_act(), rep_hist_circbuilding_dormant(), and run_scheduled_events().

static bw_array_t* bw_array_new ( void   )  [static]

Allocate, initialize, and return a new bw_array.

References bw_array_t::cur_obs_time, bw_array_t::next_period, NUM_SECS_BW_SUM_INTERVAL, and rephist_total_alloc.

Referenced by bw_arrays_init(), and rep_hist_load_state().

static void bw_arrays_init ( void   )  [static]

Set up read_array and write_array.

References bw_array_new().

Referenced by rep_hist_init().

static void commit_max ( bw_array_t b  )  [static]

static INLINE time_t correct_time ( time_t  t,
time_t  now,
time_t  stored_at,
time_t  started_measuring 
) [static]

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.

Referenced by rep_hist_load_mtbf_data().

void dump_pk_ops ( int  severity  ) 

Log the number of times we've done each public/private-key operation.

References LD_HIST, and pk_op_counts.

Referenced by dumpstats().

static uint64_t find_largest_max ( bw_array_t b  )  [static]

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

References bw_array_t::maxima, and NUM_TOTALS.

Referenced by rep_hist_bandwidth_assess().

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.

References strcmpstart().

Referenced by rep_hist_load_mtbf_data().

static void free_or_history ( void *  _hist  )  [static]

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

References _free_link_history(), digestmap_free(), or_history_t::link_history_map, rephist_total_alloc, rephist_total_num, and tor_free.

Referenced by rep_hist_free_all(), and rep_history_clean().

static link_history_t* get_link_history ( const char *  from_id,
const char *  to_id 
) [static]

Return the link_history_t for the link from the first named OR to the second, creating it if necessary. (ORs are identified by identity digest.)

References link_history_t::changed, DIGEST_LEN, digestmap_get(), digestmap_set(), get_or_history(), or_history_t::link_history_map, rephist_total_alloc, link_history_t::since, and tor_mem_is_zero().

Referenced by rep_hist_note_extend_failed(), and rep_hist_note_extend_succeeded().

static or_history_t* get_or_history ( const char *  id  )  [static]

static double get_stability ( or_history_t hist,
time_t  when 
) [static]

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.

References or_history_t::start_of_downtime, or_history_t::start_of_run, and or_history_t::total_weighted_time.

Referenced by rep_hist_get_weighted_time_known().

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.

References or_history_t::start_of_downtime, or_history_t::start_of_run, or_history_t::total_weighted_time, and or_history_t::weighted_uptime.

Referenced by rep_hist_format_router_status(), and rep_hist_get_weighted_fractional_uptime().

static void mark_or_down ( or_history_t hist,
time_t  when,
int  failed 
) [static]

Helper: note that we are no longer connected to the router with history hist. If failed, the connection failed; otherwise, it was closed correctly.

References or_history_t::down_since, or_history_t::up_since, and or_history_t::uptime.

Referenced by rep_hist_note_connect_failed(), rep_hist_note_connection_died(), and rep_hist_note_disconnect().

static void mark_or_up ( or_history_t hist,
time_t  when 
) [static]

Helper: note that we are connected to the router with history hist.

References or_history_t::down_since, or_history_t::downtime, and or_history_t::up_since.

Referenced by rep_hist_note_connect_succeeded().

void note_crypto_pk_op ( pk_op_t  operation  ) 

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 rounds any pre-1970 date to Jan 1, 1970.

References n_bogus_times, parse_iso_time(), and tor_parse_long().

Referenced by rep_hist_load_mtbf_data().

static void predicted_ports_free ( void   )  [static]

Free whatever memory is needed for predicting which ports will be used.

References rephist_total_alloc, smartlist_free(), and tor_free.

Referenced by rep_hist_free_all().

static void predicted_ports_init ( void   )  [static]

Initialize whatever memory and structs are needed for predicting which ports will be used. Also seed it with port 80, so we'll build circuits on start-up.

References add_predicted_port(), and smartlist_create().

Referenced by rep_hist_init().

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.

References find_largest_max(), and NUM_SECS_ROLLING_MEASURE.

Referenced by check_descriptor_bandwidth_changed(), and router_rebuild_descriptor().

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.

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

Referenced by circuit_free(), and rep_hist_buffer_stats_write().

void rep_hist_buffer_stats_init ( time_t  now  ) 

Initialize buffer stats.

References start_of_buffer_stats_interval.

Referenced by run_scheduled_events().

void rep_hist_buffer_stats_write ( time_t  now  ) 

int rep_hist_circbuilding_dormant ( time_t  now  ) 

time_t rep_hist_downrate_old_runs ( time_t  now  ) 

void rep_hist_dump_stats ( time_t  now,
int  severity 
)

void rep_hist_exit_stats_init ( time_t  now  ) 

void rep_hist_exit_stats_write ( time_t  now  ) 

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

Print the bandwidth history of b (either read_array or 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.

References get_options(), 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.

Referenced by rep_hist_get_bandwidth_lines(), and rep_hist_update_state().

static char* rep_hist_format_router_status ( or_history_t hist,
time_t  now 
) [static]

void rep_hist_free_all ( void   ) 

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

References built_last_stability_doc_at, digestmap_free(), exit_bytes_read, exit_bytes_written, exit_streams, free_or_history(), history_map, last_stability_doc, predicted_ports_free(), and tor_free.

Referenced by tor_free_all().

char* rep_hist_get_bandwidth_lines ( int  for_extrainfo  ) 

Allocate and return lines for representing this server's bandwidth history in its descriptor.

References format_iso_time(), bw_array_t::next_period, NUM_SECS_BW_SUM_INTERVAL, NUM_TOTALS, rep_hist_fill_bandwidth_history(), tor_assert, and tor_snprintf().

Referenced by extrainfo_dump_to_string().

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.

References PREDICTED_CIRCS_RELEVANCE_TIME, predicted_internal_capacity_time, predicted_internal_time, and predicted_internal_uptime_time.

Referenced by circuit_predict_and_launch_new().

smartlist_t* rep_hist_get_predicted_ports ( time_t  now  ) 

Return a pointer to the list of port numbers that are likely to be asked for in the near future.

The caller promises not to mess with it.

References LD_CIRC, PREDICTED_CIRCS_RELEVANCE_TIME, rephist_total_alloc, smartlist_del(), tor_assert, and tor_free.

Referenced by circuit_get_unhandled_ports().

const char* rep_hist_get_router_stability_doc ( time_t  now  ) 

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.

References get_or_history(), and get_stability().

Referenced by dirserv_compute_performance_thresholds(), and dirserv_thinks_router_is_unreliable().

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.

References get_or_history(), and get_weighted_fractional_uptime().

Referenced by set_routerstatus_from_routerinfo().

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.

References get_or_history(), and get_total_weighted_time().

Referenced by dirserv_compute_performance_thresholds(), and set_routerstatus_from_routerinfo().

int rep_hist_have_measured_enough_stability ( void   ) 

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

References started_tracking_stability.

Referenced by rep_hist_get_router_stability_doc().

void rep_hist_init ( void   ) 

Initialize the static data structures for tracking history.

References bw_arrays_init(), digestmap_new(), history_map, and predicted_ports_init().

Referenced by tor_init().

int rep_hist_load_mtbf_data ( time_t  now  ) 

int rep_hist_load_state ( or_state_t state,
char **  err 
)

void rep_hist_note_bytes_read ( size_t  num_bytes,
time_t  when 
)

We wrote num_bytes more bytes in second when. (like rep_hist_note_bytes_written() above)

References add_obs().

Referenced by connection_buckets_decrement().

void rep_hist_note_bytes_written ( size_t  num_bytes,
time_t  when 
)

We read num_bytes more 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.

References add_obs().

Referenced by connection_buckets_decrement().

void rep_hist_note_connect_failed ( const char *  id,
time_t  when 
)

Remember that an attempt to connect to the OR with identity digest id failed at when.

References or_history_t::changed, get_or_history(), mark_or_down(), and or_history_t::n_conn_fail.

Referenced by connection_about_to_close_connection().

void rep_hist_note_connect_succeeded ( const char *  id,
time_t  when 
)

Remember that an attempt to connect to the OR with identity digest id succeeded at when.

References or_history_t::changed, get_or_history(), mark_or_up(), and or_history_t::n_conn_ok.

Referenced by connection_or_set_state_open().

void rep_hist_note_connection_died ( const char *  id,
time_t  when 
)

Remember that our connection to the OR with identity digest id had an error and stopped working at when.

References or_history_t::changed, get_or_history(), and mark_or_down().

Referenced by connection_about_to_close_connection().

void rep_hist_note_disconnect ( const char *  id,
time_t  when 
)

Remember that we intentionally closed our connection to the OR with identity digest id at when.

References or_history_t::changed, get_or_history(), and mark_or_down().

Referenced by connection_about_to_close_connection().

void rep_hist_note_exit_bytes_read ( uint16_t  port,
size_t  num_bytes 
)

Note that we read num_bytes from an exit connection to port.

References exit_bytes_read, get_options(), and LD_HIST.

Referenced by connection_buckets_decrement().

void rep_hist_note_exit_bytes_written ( uint16_t  port,
size_t  num_bytes 
)

Note that we wrote num_bytes to an exit connection to port.

References exit_bytes_written, get_options(), and LD_HIST.

Referenced by connection_buckets_decrement().

void rep_hist_note_exit_stream_opened ( uint16_t  port  ) 

Note that we opened an exit stream to port.

References exit_streams, get_options(), and LD_HIST.

Referenced by connection_edge_finished_connecting().

void rep_hist_note_extend_failed ( const char *  from_id,
const char *  to_id 
)

Remember that we tried to extend from the OR with identity digest from_id to the OR with identity digest to_name, but failed.

References link_history_t::changed, get_link_history(), and link_history_t::n_extend_fail.

Referenced by circuit_rep_hist_note_result().

void rep_hist_note_extend_succeeded ( const char *  from_id,
const char *  to_id 
)

Remember that we successfully extended from the OR with identity digest from_id to the OR with identity digest to_name.

References link_history_t::changed, get_link_history(), and link_history_t::n_extend_ok.

Referenced by circuit_rep_hist_note_result().

void rep_hist_note_router_reachable ( const char *  id,
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.

References DIGEST_LEN, format_local_iso_time(), get_or_history(), hex_str(), LD_HIST, or_history_t::start_of_downtime, or_history_t::start_of_run, started_tracking_stability, tor_assert, and or_history_t::total_weighted_time.

Referenced by dirserv_orconn_tls_done().

void rep_hist_note_router_unreachable ( const char *  id,
time_t  when 
)

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

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.

References add_predicted_port(), and tor_assert.

Referenced by directory_initiate_command_rend(), and 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.

References rep_hist_note_used_port().

int rep_hist_record_mtbf_data ( time_t  now,
int  missing_means_down 
)

void rep_hist_update_state ( or_state_t state  ) 

void rep_history_clean ( time_t  before  ) 

static void update_or_history ( or_history_t hist,
time_t  when 
) [static]

Update an or_history_t object hist so that its uptime/downtime count is up-to-date as of when.

References or_history_t::down_since, or_history_t::downtime, tor_assert, or_history_t::up_since, and or_history_t::uptime.

Referenced by rep_hist_dump_stats().


Variable Documentation

time_t built_last_stability_doc_at = 0 [static]

The last time we created a stability analysis document, or 0 if we never have created one.

Referenced by rep_hist_free_all(), and rep_hist_get_router_stability_doc().

Holds stats.

uint64_t* exit_bytes_read = NULL [static]

Number of bytes read in current period by exit port

Referenced by rep_hist_exit_stats_init(), rep_hist_exit_stats_write(), rep_hist_free_all(), and rep_hist_note_exit_bytes_read().

uint64_t* exit_bytes_written = NULL [static]

Number of bytes written in current period by exit port

Referenced by rep_hist_exit_stats_init(), rep_hist_exit_stats_write(), rep_hist_free_all(), and rep_hist_note_exit_bytes_written().

uint32_t* exit_streams = NULL [static]

Number of streams opened in current period by exit port

Referenced by rep_hist_exit_stats_init(), rep_hist_exit_stats_write(), rep_hist_free_all(), and rep_hist_note_exit_stream_opened().

digestmap_t* history_map = NULL [static]

char* last_stability_doc = NULL [static]

The last stability analysis document that we created, or NULL if we never have created one.

Referenced by rep_hist_free_all(), and rep_hist_get_router_stability_doc().

int n_bogus_times = 0 [static]

How many bad times has parse_possibly_bad_iso_time parsed?

Referenced by parse_possibly_bad_iso_time(), and rep_hist_load_mtbf_data().

unsigned long n_onionskins_decrypted

How many onionskins have we decrypted to do circuit build requests?

unsigned long n_onionskins_encrypted

How many onionskins have we encrypted to build circuits?

unsigned long n_rend_client_ops

How many PK operations have we done as a hidden service client?

unsigned long n_rend_mid_ops

How many PK operations have we done as a hidden service midpoint?

unsigned long n_rend_server_ops

How many PK operations have we done as a hidden service provider?

unsigned long n_signed_dir_objs

How many directory objects have we signed?

unsigned long n_signed_routerdescs

How many routerdescs have we signed?

unsigned long n_tls_client_handshakes

How many times have we done the TLS handshake as a client?

unsigned long n_tls_server_handshakes

How many times have we done the TLS handshake as a server?

unsigned long n_verified_dir_objs

How many directory objects have we verified?

unsigned long n_verified_routerdescs

How many routerdescs have we verified

struct { ... } pk_op_counts [static]

Structure to track how many times we've done each public key operation.

Referenced by dump_pk_ops(), and note_crypto_pk_op().

time_t predicted_internal_capacity_time = 0 [static]

The last time we needed an internal circ with good capacity.

Referenced by rep_hist_get_predicted_internal(), and rep_hist_note_used_internal().

time_t predicted_internal_time = 0 [static]

The last time at which we needed an internal circ.

Referenced by any_predicted_circuits(), rep_hist_get_predicted_internal(), and rep_hist_note_used_internal().

time_t predicted_internal_uptime_time = 0 [static]

The last time we needed an internal circ with good uptime.

Referenced by rep_hist_get_predicted_internal(), and rep_hist_note_used_internal().

A list of port numbers that have been used recently.

The corresponding most recently used time for each port.

bw_array_t* read_array = NULL [static]

Recent history of bandwidth observations for read operations.

uint64_t rephist_total_alloc = 0

uint32_t rephist_total_num = 0

Number of or_history_t objects currently allocated.

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

time_t stability_last_downrated = 0 [static]

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

Referenced by rep_hist_downrate_old_runs(), rep_hist_load_mtbf_data(), and rep_hist_record_mtbf_data().

Start of the current buffer stats interval.

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

When does the current exit stats period end?

Referenced by rep_hist_exit_stats_init(), and rep_hist_exit_stats_write().

time_t started_tracking_stability = 0 [static]

bw_array_t* write_array = NULL [static]

Recent history of bandwidth observations for write operations.


Generated on Tue May 25 00:30:49 2010 for tor by  doxygen 1.5.6