Loading doc/TODO +3 −3 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ Short-term: o directory includes all routers, up and down o add "up" line to directory, listing nicknames ARMA . find an application that uses half-open connections: openssh NICK - instruments ORs to report stats - average cell fullness - average bandwidth used o instruments ORs to report stats o average cell fullness o average bandwidth used . integrate rep_ok functions, see what breaks ARMA - configure log files. separate log file, separate severities. ARMA - what assumptions break if we fclose(0) when we daemonize? Loading src/or/circuit.c +6 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ static void circuit_free_cpath(crypt_path_t *cpath); static void circuit_free_cpath_node(crypt_path_t *victim); static aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type); unsigned long stats_n_relay_cells_relayed = 0; unsigned long stats_n_relay_cells_delivered = 0; /********* START VARIABLES **********/ static circuit_t *global_circuitlist=NULL; Loading Loading @@ -240,15 +243,18 @@ int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ, if(recognized) { if(cell_direction == CELL_DIRECTION_OUT) { ++stats_n_relay_cells_delivered; log_fn(LOG_DEBUG,"Sending to exit."); return connection_edge_process_relay_cell(cell, circ, conn, EDGE_EXIT, NULL); } if(cell_direction == CELL_DIRECTION_IN) { ++stats_n_relay_cells_delivered; log_fn(LOG_DEBUG,"Sending to AP."); return connection_edge_process_relay_cell(cell, circ, conn, EDGE_AP, layer_hint); } } ++stats_n_relay_cells_relayed; /* not recognized. pass it on. */ if(cell_direction == CELL_DIRECTION_OUT) conn = circ->n_conn; Loading src/or/command.c +13 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,12 @@ extern or_options_t options; /* command-line and config-file options */ unsigned long stats_n_padding_cells_processed = 0; unsigned long stats_n_create_cells_processed = 0; unsigned long stats_n_created_cells_processed = 0; unsigned long stats_n_relay_cells_processed = 0; unsigned long stats_n_destroy_cells_processed = 0; static void command_process_create_cell(cell_t *cell, connection_t *conn); static void command_process_created_cell(cell_t *cell, connection_t *conn); static void command_process_relay_cell(cell_t *cell, connection_t *conn); Loading @@ -32,6 +38,8 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn, *time += time_passed; } void command_process_cell(cell_t *cell, connection_t *conn) { static int num_create=0, num_created=0, num_relay=0, num_destroy=0; static int create_time=0, created_time=0, relay_time=0, destroy_time=0; Loading @@ -58,21 +66,26 @@ void command_process_cell(cell_t *cell, connection_t *conn) { switch(cell->command) { case CELL_PADDING: ++stats_n_padding_cells_processed; /* do nothing */ break; case CELL_CREATE: ++stats_n_create_cells_processed; command_time_process_cell(cell, conn, &num_create, &create_time, command_process_create_cell); break; case CELL_CREATED: ++stats_n_created_cells_processed; command_time_process_cell(cell, conn, &num_created, &created_time, command_process_created_cell); break; case CELL_RELAY: ++stats_n_relay_cells_processed; command_time_process_cell(cell, conn, &num_relay, &relay_time, command_process_relay_cell); break; case CELL_DESTROY: ++stats_n_destroy_cells_processed; command_time_process_cell(cell, conn, &num_destroy, &destroy_time, command_process_destroy_cell); break; Loading src/or/connection_edge.c +9 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection } return connection_exit_begin_conn(cell, circ); case RELAY_COMMAND_DATA: ++stats_n_data_cells_received; if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) || (edge_type == EDGE_EXIT && --circ->deliver_window < 0)) { log_fn(LOG_WARNING,"(relay data) circ deliver_window below 0. Killing."); Loading @@ -173,6 +174,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection } // printf("New text for buf (%d bytes): '%s'", cell->length - RELAY_HEADER_SIZE, cell->payload + RELAY_HEADER_SIZE); stats_n_data_bytes_received += (cell->length - RELAY_HEADER_SIZE); if(connection_write_to_buf(cell->payload + RELAY_HEADER_SIZE, cell->length - RELAY_HEADER_SIZE, conn) < 0) { /*ENDCLOSE*/ conn->marked_for_close = 1; Loading Loading @@ -312,6 +314,11 @@ int connection_edge_finished_flushing(connection_t *conn) { return 0; } uint64_t stats_n_data_cells_packaged = 0; uint64_t stats_n_data_bytes_packaged = 0; uint64_t stats_n_data_cells_received = 0; uint64_t stats_n_data_bytes_received = 0; int connection_package_raw_inbuf(connection_t *conn) { int amount_to_process; cell_t cell; Loading Loading @@ -350,6 +357,8 @@ repeat_connection_package_raw_inbuf: } else { cell.length = amount_to_process; } stats_n_data_bytes_packaged += cell.length; stats_n_data_cells_packaged += 1; connection_fetch_from_buf(cell.payload+RELAY_HEADER_SIZE, cell.length, conn); Loading src/or/main.c +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; or_options_t options; /* command-line and config-file options */ int global_read_bucket; /* max number of bytes I can read this second */ static int stats_prev_global_read_bucket; static uint64_t stats_n_bytes_read = 0; static long stats_n_seconds_reading = 0; static connection_t *connection_array[MAXCONNECTIONS] = { NULL }; Loading Loading @@ -270,6 +274,8 @@ static int prepare_for_poll(void) { if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */ ++stats_n_seconds_reading; if(time_to_fetch_directory < now.tv_sec) { /* it's time to fetch a new directory and/or post our descriptor */ if(options.OnionRouter) { Loading @@ -296,10 +302,12 @@ static int prepare_for_poll(void) { time_to_new_circuit = now.tv_sec + options.NewCircuitPeriod; } stats_n_bytes_read += stats_prev_global_read_bucket-global_read_bucket; if(global_read_bucket < 9*options.TotalBandwidth) { global_read_bucket += options.TotalBandwidth; log_fn(LOG_DEBUG,"global_read_bucket now %d.", global_read_bucket); } stats_prev_global_read_bucket = global_read_bucket; /* do housekeeping for each connection */ for(i=0;i<nfds;i++) { Loading Loading @@ -670,6 +678,33 @@ static void dumpstats(void) { /* dump stats to stdout */ circuit_dump_by_conn(conn); /* dump info about all the circuits using this conn */ printf("\n"); } printf("Cells processed: % 10lud padding\n" " % 10lud create\n" " % 10lud created\n" " % 10lud relay\n" " (% 10lud relayed)\n" " (% 10lud delivered)\n" " % 10lud destroy\n", stats_n_padding_cells_processed, stats_n_create_cells_processed, stats_n_created_cells_processed, stats_n_relay_cells_processed, stats_n_relay_cells_relayed, stats_n_relay_cells_delivered, stats_n_destroy_cells_processed); if (stats_n_data_cells_packaged) printf("Average outgoing cell fullness: %2.3f%%\n", 100*(((double)stats_n_data_bytes_packaged) / (stats_n_data_cells_packaged*(CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE))) ); if (stats_n_data_cells_packaged) printf("Average incomoing cell fullness: %2.3f%%\n", 100*(((double)stats_n_data_bytes_received) / (stats_n_data_cells_received*(CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE))) ); if (stats_n_seconds_reading) printf("Average bandwidth used: %d bytes/sec\n", (int) (stats_n_bytes_read/stats_n_seconds_reading)); } void daemonize(void) { Loading Loading @@ -700,6 +735,7 @@ int tor_main(int argc, char *argv[]) { } log_set_severity(options.loglevel); /* assign logging severity level from options */ global_read_bucket = options.TotalBandwidth; /* start it at 1 second of traffic */ stats_prev_global_read_bucket = global_read_bucket; if(options.Daemon) daemonize(); Loading Loading
doc/TODO +3 −3 Original line number Diff line number Diff line Loading @@ -41,9 +41,9 @@ Short-term: o directory includes all routers, up and down o add "up" line to directory, listing nicknames ARMA . find an application that uses half-open connections: openssh NICK - instruments ORs to report stats - average cell fullness - average bandwidth used o instruments ORs to report stats o average cell fullness o average bandwidth used . integrate rep_ok functions, see what breaks ARMA - configure log files. separate log file, separate severities. ARMA - what assumptions break if we fclose(0) when we daemonize? Loading
src/or/circuit.c +6 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,9 @@ static void circuit_free_cpath(crypt_path_t *cpath); static void circuit_free_cpath_node(crypt_path_t *victim); static aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type); unsigned long stats_n_relay_cells_relayed = 0; unsigned long stats_n_relay_cells_delivered = 0; /********* START VARIABLES **********/ static circuit_t *global_circuitlist=NULL; Loading Loading @@ -240,15 +243,18 @@ int circuit_deliver_relay_cell(cell_t *cell, circuit_t *circ, if(recognized) { if(cell_direction == CELL_DIRECTION_OUT) { ++stats_n_relay_cells_delivered; log_fn(LOG_DEBUG,"Sending to exit."); return connection_edge_process_relay_cell(cell, circ, conn, EDGE_EXIT, NULL); } if(cell_direction == CELL_DIRECTION_IN) { ++stats_n_relay_cells_delivered; log_fn(LOG_DEBUG,"Sending to AP."); return connection_edge_process_relay_cell(cell, circ, conn, EDGE_AP, layer_hint); } } ++stats_n_relay_cells_relayed; /* not recognized. pass it on. */ if(cell_direction == CELL_DIRECTION_OUT) conn = circ->n_conn; Loading
src/or/command.c +13 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,12 @@ extern or_options_t options; /* command-line and config-file options */ unsigned long stats_n_padding_cells_processed = 0; unsigned long stats_n_create_cells_processed = 0; unsigned long stats_n_created_cells_processed = 0; unsigned long stats_n_relay_cells_processed = 0; unsigned long stats_n_destroy_cells_processed = 0; static void command_process_create_cell(cell_t *cell, connection_t *conn); static void command_process_created_cell(cell_t *cell, connection_t *conn); static void command_process_relay_cell(cell_t *cell, connection_t *conn); Loading @@ -32,6 +38,8 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn, *time += time_passed; } void command_process_cell(cell_t *cell, connection_t *conn) { static int num_create=0, num_created=0, num_relay=0, num_destroy=0; static int create_time=0, created_time=0, relay_time=0, destroy_time=0; Loading @@ -58,21 +66,26 @@ void command_process_cell(cell_t *cell, connection_t *conn) { switch(cell->command) { case CELL_PADDING: ++stats_n_padding_cells_processed; /* do nothing */ break; case CELL_CREATE: ++stats_n_create_cells_processed; command_time_process_cell(cell, conn, &num_create, &create_time, command_process_create_cell); break; case CELL_CREATED: ++stats_n_created_cells_processed; command_time_process_cell(cell, conn, &num_created, &created_time, command_process_created_cell); break; case CELL_RELAY: ++stats_n_relay_cells_processed; command_time_process_cell(cell, conn, &num_relay, &relay_time, command_process_relay_cell); break; case CELL_DESTROY: ++stats_n_destroy_cells_processed; command_time_process_cell(cell, conn, &num_destroy, &destroy_time, command_process_destroy_cell); break; Loading
src/or/connection_edge.c +9 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection } return connection_exit_begin_conn(cell, circ); case RELAY_COMMAND_DATA: ++stats_n_data_cells_received; if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) || (edge_type == EDGE_EXIT && --circ->deliver_window < 0)) { log_fn(LOG_WARNING,"(relay data) circ deliver_window below 0. Killing."); Loading @@ -173,6 +174,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection } // printf("New text for buf (%d bytes): '%s'", cell->length - RELAY_HEADER_SIZE, cell->payload + RELAY_HEADER_SIZE); stats_n_data_bytes_received += (cell->length - RELAY_HEADER_SIZE); if(connection_write_to_buf(cell->payload + RELAY_HEADER_SIZE, cell->length - RELAY_HEADER_SIZE, conn) < 0) { /*ENDCLOSE*/ conn->marked_for_close = 1; Loading Loading @@ -312,6 +314,11 @@ int connection_edge_finished_flushing(connection_t *conn) { return 0; } uint64_t stats_n_data_cells_packaged = 0; uint64_t stats_n_data_bytes_packaged = 0; uint64_t stats_n_data_cells_received = 0; uint64_t stats_n_data_bytes_received = 0; int connection_package_raw_inbuf(connection_t *conn) { int amount_to_process; cell_t cell; Loading Loading @@ -350,6 +357,8 @@ repeat_connection_package_raw_inbuf: } else { cell.length = amount_to_process; } stats_n_data_bytes_packaged += cell.length; stats_n_data_cells_packaged += 1; connection_fetch_from_buf(cell.payload+RELAY_HEADER_SIZE, cell.length, conn); Loading
src/or/main.c +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; or_options_t options; /* command-line and config-file options */ int global_read_bucket; /* max number of bytes I can read this second */ static int stats_prev_global_read_bucket; static uint64_t stats_n_bytes_read = 0; static long stats_n_seconds_reading = 0; static connection_t *connection_array[MAXCONNECTIONS] = { NULL }; Loading Loading @@ -270,6 +274,8 @@ static int prepare_for_poll(void) { if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */ ++stats_n_seconds_reading; if(time_to_fetch_directory < now.tv_sec) { /* it's time to fetch a new directory and/or post our descriptor */ if(options.OnionRouter) { Loading @@ -296,10 +302,12 @@ static int prepare_for_poll(void) { time_to_new_circuit = now.tv_sec + options.NewCircuitPeriod; } stats_n_bytes_read += stats_prev_global_read_bucket-global_read_bucket; if(global_read_bucket < 9*options.TotalBandwidth) { global_read_bucket += options.TotalBandwidth; log_fn(LOG_DEBUG,"global_read_bucket now %d.", global_read_bucket); } stats_prev_global_read_bucket = global_read_bucket; /* do housekeeping for each connection */ for(i=0;i<nfds;i++) { Loading Loading @@ -670,6 +678,33 @@ static void dumpstats(void) { /* dump stats to stdout */ circuit_dump_by_conn(conn); /* dump info about all the circuits using this conn */ printf("\n"); } printf("Cells processed: % 10lud padding\n" " % 10lud create\n" " % 10lud created\n" " % 10lud relay\n" " (% 10lud relayed)\n" " (% 10lud delivered)\n" " % 10lud destroy\n", stats_n_padding_cells_processed, stats_n_create_cells_processed, stats_n_created_cells_processed, stats_n_relay_cells_processed, stats_n_relay_cells_relayed, stats_n_relay_cells_delivered, stats_n_destroy_cells_processed); if (stats_n_data_cells_packaged) printf("Average outgoing cell fullness: %2.3f%%\n", 100*(((double)stats_n_data_bytes_packaged) / (stats_n_data_cells_packaged*(CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE))) ); if (stats_n_data_cells_packaged) printf("Average incomoing cell fullness: %2.3f%%\n", 100*(((double)stats_n_data_bytes_received) / (stats_n_data_cells_received*(CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE))) ); if (stats_n_seconds_reading) printf("Average bandwidth used: %d bytes/sec\n", (int) (stats_n_bytes_read/stats_n_seconds_reading)); } void daemonize(void) { Loading Loading @@ -700,6 +735,7 @@ int tor_main(int argc, char *argv[]) { } log_set_severity(options.loglevel); /* assign logging severity level from options */ global_read_bucket = options.TotalBandwidth; /* start it at 1 second of traffic */ stats_prev_global_read_bucket = global_read_bucket; if(options.Daemon) daemonize(); Loading