Use a simple Random Early Drop algorithm in send_tcppacket().

This commit is contained in:
Guus Sliepen 2009-03-09 14:04:31 +01:00
parent d5b56bbba5
commit 43fa7283ac
3 changed files with 5 additions and 3 deletions

View file

@ -366,6 +366,7 @@ int main_loop(void)
last_graph_dump = now;
srand(now);
srand48(now);
running = true;

View file

@ -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;

View file

@ -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))