summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-02-13 16:57:21 +0000
committerAlexander Færøy <ahf@torproject.org>2017-02-16 15:11:53 +0000
commit3848d236439d476793f03699519a818f26f56c6c (patch)
tree4cd2dcfef5b8b69bbc1cb312177cbcc87866d53e
parent89334a040d6496191e3cee1d69ecd3c0e566583a (diff)
downloadtor-3848d236439d476793f03699519a818f26f56c6c.tar.gz
tor-3848d236439d476793f03699519a818f26f56c6c.zip
Save number of sent/received RELAY_DATA cells for directory connections.
This patch makes us store the number of sent and received RELAY_DATA cells used for directory connections. We log the numbers after we have received an EOF in connection_dir_client_reached_eof() from the directory server.
-rw-r--r--src/or/directory.c13
-rw-r--r--src/or/or.h8
-rw-r--r--src/or/relay.c20
3 files changed, 37 insertions, 4 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 4ef39af1dd..78cee29690 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1983,12 +1983,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
log_debug(LD_DIR,
"Received response from directory server '%s:%d': %d %s "
- "(purpose: %d, response size: " U64_FORMAT ", "
- "compression: %d)",
+ "(purpose: %d, response size: " U64_FORMAT
+#ifdef MEASUREMENTS_21206
+ ", data cells received: %d, data cells sent: %d"
+#endif
+ ", compression: %d)",
conn->base_.address, conn->base_.port, status_code,
- escaped(reason),
- conn->base_.purpose,
+ escaped(reason), conn->base_.purpose,
U64_PRINTF_ARG(received_bytes),
+#ifdef MEASUREMENTS_21206
+ conn->data_cells_received, conn->data_cells_sent,
+#endif
compression);
if (conn->guard_state) {
diff --git a/src/or/or.h b/src/or/or.h
index 0db9f23604..0e2dc2401b 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1786,6 +1786,14 @@ typedef struct dir_connection_t {
* that's going away and being used on channels instead. The dirserver still
* needs this for the incoming side, so it's moved here. */
uint64_t dirreq_id;
+
+#ifdef MEASUREMENTS_21206
+ /** Number of RELAY_DATA cells received. */
+ uint32_t data_cells_received;
+
+ /** Number of RELAY_DATA cells sent. */
+ uint32_t data_cells_sent;
+#endif
} dir_connection_t;
/** Subtype of connection_t for an connection to a controller. */
diff --git a/src/or/relay.c b/src/or/relay.c
index 2e76a8ec36..6b3f34f3e5 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -732,6 +732,16 @@ connection_edge_send_command(edge_connection_t *fromconn,
return -1;
}
+#ifdef MEASUREMENTS_21206
+ /* Keep track of the number of RELAY_DATA cells sent for directory
+ * connections. */
+ connection_t *linked_conn = TO_CONN(fromconn)->linked_conn;
+
+ if (linked_conn && linked_conn->type == CONN_TYPE_DIR) {
+ ++(TO_DIR_CONN(linked_conn)->data_cells_sent);
+ }
+#endif
+
return relay_send_command_from_edge(fromconn->stream_id, circ,
relay_command, payload,
payload_len, cpath_layer);
@@ -1585,6 +1595,16 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
connection_write_to_buf((char*)(cell->payload + RELAY_HEADER_SIZE),
rh.length, TO_CONN(conn));
+#ifdef MEASUREMENTS_21206
+ /* Count number of RELAY_DATA cells received on a linked directory
+ * connection. */
+ connection_t *linked_conn = TO_CONN(conn)->linked_conn;
+
+ if (linked_conn && linked_conn->type == CONN_TYPE_DIR) {
+ ++(TO_DIR_CONN(linked_conn)->data_cells_received);
+ }
+#endif
+
if (!optimistic_data) {
/* Only send a SENDME if we're not getting optimistic data; otherwise
* a SENDME could arrive before the CONNECTED.