aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-09-15 05:30:25 +0000
committerRoger Dingledine <arma@torproject.org>2006-09-15 05:30:25 +0000
commit769f9201a68387c2cdf03e1efd28399c93bb2bdf (patch)
treefc597d1711653997e2b56d39e3f6e63f8dbf8d70 /src/or/router.c
parentba091ae5d73c7992ebd62fa5c2ce80922a3d97d8 (diff)
downloadtor-769f9201a68387c2cdf03e1efd28399c93bb2bdf.tar.gz
tor-769f9201a68387c2cdf03e1efd28399c93bb2bdf.zip
Send out a burst of long-range drop cells after we've established that
we're reachable. Spread them over 4 circuits, so hopefully a few will be fast. This exercises our bandwidth and bootstraps us quicker. svn:r8399
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 032069c480..2dbbefa2b8 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -439,11 +439,13 @@ void
consider_testing_reachability(void)
{
routerinfo_t *me = router_get_my_routerinfo();
+ int orport_reachable = !check_whether_orport_reachable();
if (!me)
return;
- if (!check_whether_orport_reachable()) {
- log_info(LD_CIRC, "Testing reachability of my ORPort: %s:%d.",
+ if (!orport_reachable || !circuit_enough_testing_circs()) {
+ log_info(LD_CIRC, "Testing %s of my ORPort: %s:%d.",
+ !orport_reachable ? "reachability" : "bandwidth",
me->address, me->or_port);
circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 1, 1);
}
@@ -488,9 +490,38 @@ server_has_changed_ip(void)
stats_n_seconds_working = 0;
can_reach_or_port = 0;
can_reach_dir_port = 0;
+ reset_bandwidth_test();
mark_my_descriptor_dirty();
}
+/** We have enough testing circuit open. Send a bunch of "drop"
+ * cells down each of them, to exercise our bandwidth. */
+void
+router_perform_bandwidth_test(int num_circs, time_t now)
+{
+ int num_cells = get_options()->BandwidthRate * 10 / CELL_NETWORK_SIZE;
+ int max_cells = num_cells < CIRCWINDOW_START ?
+ num_cells : CIRCWINDOW_START;
+ int cells_per_circuit = max_cells / num_circs;
+ origin_circuit_t *circ = NULL;
+
+ while ((circ = circuit_get_next_by_pk_and_purpose(circ, NULL,
+ CIRCUIT_PURPOSE_TESTING))) {
+ /* dump cells_per_circuit drop cells onto this circ */
+ int i = cells_per_circuit;
+ if (circ->_base.state != CIRCUIT_STATE_OPEN)
+ continue;
+ circ->_base.timestamp_dirty = now;
+ while (i-- > 0) {
+ if (connection_edge_send_command(NULL, TO_CIRCUIT(circ),
+ RELAY_COMMAND_DROP,
+ NULL, 0, circ->cpath->prev)<0) {
+ return; /* stop if error */
+ }
+ }
+ }
+}
+
/** Return true iff we believe ourselves to be an authoritative
* directory server.
*/