From 43fa7283ac01f2ecc95381b519ef6b3342546f35 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 9 Mar 2009 14:04:31 +0100 Subject: [PATCH] Use a simple Random Early Drop algorithm in send_tcppacket(). --- src/net.c | 1 + src/net_setup.c | 2 +- src/protocol_misc.c | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net.c b/src/net.c index 41b3fb94..0cdc72cc 100644 --- a/src/net.c +++ b/src/net.c @@ -366,6 +366,7 @@ int main_loop(void) last_graph_dump = now; srand(now); + srand48(now); running = true; diff --git a/src/net_setup.c b/src/net_setup.c index 256fdf78..3eb56441 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -547,7 +547,7 @@ bool setup_network_connections(void) pingtimeout = pinginterval; if(!get_config_int(lookup_config(config_tree, "MaxOutputBufferSize"), &maxoutbufsize)) - maxoutbufsize = 4 * MTU; + maxoutbufsize = 10 * MTU; if(!setup_myself()) return false; diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 52e97e54..8f56aee5 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -155,9 +155,10 @@ bool send_tcppacket(connection_t *c, vpn_packet_t *packet) { cp(); - /* If there already is a lot of data in the outbuf buffer, discard this packet. */ + /* If there already is a lot of data in the outbuf buffer, discard this packet. + We use a very simple Random Early Drop algorithm. */ - if(c->outbuflen > maxoutbufsize) + if(2.0 * c->outbuflen / (double)maxoutbufsize - 1 > drand48()) return true; if(!send_request(c, "%d %hd", PACKET, packet->len)) -- 2.39.5