summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2002-07-16 01:12:15 +0000
committerRoger Dingledine <arma@torproject.org>2002-07-16 01:12:15 +0000
commit117cbeeaaf30cdbbfe79dbe92fe47ab6a531bd8a (patch)
tree7d8b9fdb5277299ac2e67135b077a88edd666aa5 /src/or/config.c
parentffc545311b9c1142b6ed59482cb811f6388e1932 (diff)
downloadtor-117cbeeaaf30cdbbfe79dbe92fe47ab6a531bd8a.tar.gz
tor-117cbeeaaf30cdbbfe79dbe92fe47ab6a531bd8a.zip
Implemented link padding and receiver token buckets
Each socket reads at most 'bandwidth' bytes per second sustained, but can handle bursts of up to 10*bandwidth bytes. Cells are now sent out at evenly-spaced intervals, with padding sent out otherwise. Set Linkpadding=0 in the rc file to send cells as soon as they're available (and to never send padding cells). Added license/copyrights statements at the top of most files. router->min and router->max have been merged into a single 'bandwidth' value. We should make the routerinfo_t reflect this (want to do that, Mat?) As the bandwidth increases, and we want to stop sleeping more and more frequently to send a single cell, cpu usage goes up. At 128kB/s we're pretty much calling poll with a timeout of 1ms or even 0ms. The current code takes a timeout of 0-9ms and makes it 10ms. prepare_for_poll() handles everything that should have happened in the past, so as long as our buffers don't get too full in that 10ms, we're ok. Speaking of too full, if you run three servers at 100kB/s with -l debug, it spends too much time printing debugging messages to be able to keep up with the cells. The outbuf ultimately fills up and it kills that connection. If you run with -l err, it works fine up through 500kB/s and probably beyond. Down the road we'll want to teach it to recognize when an outbuf is getting full, and back off. svn:r50
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c74
1 files changed, 22 insertions, 52 deletions
diff --git a/src/or/config.c b/src/or/config.c
index e0a583354d..640044fc7e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1,3 +1,7 @@
+/* Copyright 2001,2002 Roger Dingledine, Matej Pfajfar. */
+/* See LICENSE for licensing information */
+/* $Id$ */
+
/**
* config.c
* Routines for loading the configuration file.
@@ -5,50 +9,6 @@
* Matej Pfajfar <mp292@cam.ac.uk>
*/
-/*
- * Changes :
- * $Log$
- * Revision 1.10 2002/07/15 16:42:27 montrose
- * corrected some string literals
- *
- * Revision 1.9 2002/07/11 19:03:44 montrose
- * finishing touches. think its ready for integration now.
- *
- * Revision 1.8 2002/07/11 18:38:15 montrose
- * added new option GlobalRole to getoptions()
- *
- * Revision 1.7 2002/07/11 14:50:26 montrose
- * cleaned up some, added validation to getoptions()
- *
- * Revision 1.6 2002/07/10 12:37:49 montrose
- * Added usage display on error.
- *
- * Revision 1.5 2002/07/09 19:51:41 montrose
- * Miscellaneous bug fixes / activated "make check" for src/or
- *
- * Revision 1.4 2002/07/03 19:58:18 montrose
- * minor bug fix in error checking
- *
- * Revision 1.3 2002/07/03 16:53:34 montrose
- * added error checking into getoptions()
- *
- * Revision 1.2 2002/07/03 16:31:22 montrose
- * Added getoptions() and made minor adjustment to poptReadDefaultOptions()
- *
- * Revision 1.1.1.1 2002/06/26 22:45:50 arma
- * initial commit: current code
- *
- * Revision 1.3 2002/04/02 14:28:24 badbytes
- * Final finishes.
- *
- * Revision 1.2 2002/01/27 00:42:50 mp292
- * Reviewed according to Secure-Programs-HOWTO.
- *
- * Revision 1.1 2002/01/03 10:24:05 badbytes
- * COde based on that in op. Needs to be modified.
- *
- */
-
#include "or.h"
#include <libgen.h>
@@ -119,7 +79,9 @@ RETURN VALUE: 0 on success, non-zero on error
0, "local port on which the onion proxy is running", "<file>" },
{ "TrafficShaping", 't', POPT_ARG_INT, &options->TrafficShaping,
0, "which traffic shaping policy to use", "<policy>" },
- { "GlobalRole", 'g', POPT_ARG_INT, &options->GlobalRole,
+ { "LinkPadding", 'P', POPT_ARG_INT, &options->LinkPadding,
+ 0, "whether to use link padding", "<padding>" },
+ { "Role", 'g', POPT_ARG_INT, &options->Role,
0, "4-bit global role id", "<role>" },
{ "Verbose", 'v', POPT_ARG_NONE, &Verbose,
0, "display options selected before execution", NULL },
@@ -137,7 +99,8 @@ RETURN VALUE: 0 on success, non-zero on error
options->LogLevel = "debug";
options->loglevel = LOG_DEBUG;
options->CoinWeight = 0.8;
- options->GlobalRole = ROLE_OR_LISTEN | ROLE_OR_CONNECT_ALL | ROLE_OP_LISTEN | ROLE_AP_LISTEN;
+ options->LinkPadding = 1;
+ options->Role = ROLE_OR_LISTEN | ROLE_OR_CONNECT_ALL | ROLE_OP_LISTEN | ROLE_AP_LISTEN;
code = poptGetNextOpt(optCon); /* first we handle command-line args */
if ( code == -1 )
@@ -170,19 +133,20 @@ RETURN VALUE: 0 on success, non-zero on error
if ( Verbose )
{
- printf("LogLevel=%s, GlobalRole=%d\n",
+ printf("LogLevel=%s, Role=%d\n",
options->LogLevel,
- options->GlobalRole);
+ options->Role);
printf("RouterFile=%s, PrivateKeyFile=%s\n",
options->RouterFile,
options->PrivateKeyFile);
printf("ORPort=%d, OPPort=%d, APPort=%d\n",
options->ORPort,options->OPPort,
options->APPort);
- printf("CoinWeight=%6.4f, MaxConn=%d, TrafficShaping=%d\n",
+ printf("CoinWeight=%6.4f, MaxConn=%d, TrafficShaping=%d, LinkPadding=%d\n",
options->CoinWeight,
options->MaxConn,
- options->TrafficShaping);
+ options->TrafficShaping,
+ options->LinkPadding);
}
/* Validate options */
@@ -260,9 +224,15 @@ RETURN VALUE: 0 on success, non-zero on error
code = -1;
}
- if ( options->GlobalRole < 0 || options->GlobalRole > 15 )
+ if ( options->LinkPadding != 0 && options->LinkPadding != 1 )
+ {
+ log(LOG_ERR,"LinkPadding option must be either 0 or 1.");
+ code = -1;
+ }
+
+ if ( options->Role < 0 || options->Role > 15 )
{
- log(LOG_ERR,"GlobalRole option must be an integer between 0 and 15 (inclusive).");
+ log(LOG_ERR,"Role option must be an integer between 0 and 15 (inclusive).");
code = -1;
}