[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Add new cell fullness and bandwidth stats.
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv23292/src/or
Modified Files:
circuit.c command.c connection_edge.c main.c or.h
Log Message:
Add new cell fullness and bandwidth stats.
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- circuit.c 1 Oct 2003 01:49:53 -0000 1.71
+++ circuit.c 2 Oct 2003 20:00:38 -0000 1.72
@@ -10,6 +10,9 @@
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;
@@ -240,15 +243,18 @@
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;
Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- command.c 29 Sep 2003 23:14:49 -0000 1.40
+++ command.c 2 Oct 2003 20:00:38 -0000 1.41
@@ -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);
@@ -32,6 +38,8 @@
*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;
@@ -58,21 +66,26 @@
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;
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- connection_edge.c 27 Sep 2003 21:09:56 -0000 1.28
+++ connection_edge.c 2 Oct 2003 20:00:38 -0000 1.29
@@ -152,6 +152,7 @@
}
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.");
@@ -173,6 +174,7 @@
}
// 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;
@@ -312,6 +314,11 @@
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;
@@ -350,6 +357,8 @@
} 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);
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- main.c 1 Oct 2003 01:49:53 -0000 1.121
+++ main.c 2 Oct 2003 20:00:38 -0000 1.122
@@ -16,6 +16,10 @@
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 };
@@ -270,6 +274,8 @@
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) {
@@ -296,10 +302,12 @@
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++) {
@@ -670,6 +678,33 @@
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) {
@@ -700,6 +735,7 @@
}
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();
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- or.h 1 Oct 2003 01:49:53 -0000 1.153
+++ or.h 2 Oct 2003 20:00:38 -0000 1.154
@@ -509,10 +509,19 @@
void assert_cpath_layer_ok(const crypt_path_t *c);
void assert_circuit_ok(const circuit_t *c);
+extern unsigned long stats_n_relay_cells_relayed;
+extern unsigned long stats_n_relay_cells_delivered;
+
/********************************* command.c ***************************/
void command_process_cell(cell_t *cell, connection_t *conn);
+extern unsigned long stats_n_padding_cells_processed;
+extern unsigned long stats_n_create_cells_processed;
+extern unsigned long stats_n_created_cells_processed;
+extern unsigned long stats_n_relay_cells_processed;
+extern unsigned long stats_n_destroy_cells_processed;
+
/********************************* config.c ***************************/
int getconfig(int argc, char **argv, or_options_t *options);
@@ -572,6 +581,11 @@
int connection_consider_sending_sendme(connection_t *conn, int edge_type);
int connection_exit_connect(connection_t *conn);
+
+extern uint64_t stats_n_data_cells_packaged;
+extern uint64_t stats_n_data_bytes_packaged;
+extern uint64_t stats_n_data_cells_received;
+extern uint64_t stats_n_data_bytes_received;
/********************************* connection_or.c ***************************/