]> git.meshlink.io Git - meshlink/commitdiff
Use a simple Random Early Drop algorithm in send_tcppacket().
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 9 Mar 2009 13:04:31 +0000 (14:04 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 9 Mar 2009 13:04:31 +0000 (14:04 +0100)
src/net.c
src/net_setup.c
src/protocol_misc.c

index 41b3fb944b5827c1bca336346e775a32ca7c2bdd..0cdc72cc5ad8f150ad6520f20ef06d1847850098 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -366,6 +366,7 @@ int main_loop(void)
        last_graph_dump = now;
        
        srand(now);
        last_graph_dump = now;
        
        srand(now);
+       srand48(now);
 
        running = true;
 
 
        running = true;
 
index 256fdf7892958a9b837cb272826dd53914eaa4de..3eb564411e5affc45d1d8c52d0c2c84067c91d12 100644 (file)
@@ -547,7 +547,7 @@ bool setup_network_connections(void)
                pingtimeout = pinginterval;
 
        if(!get_config_int(lookup_config(config_tree, "MaxOutputBufferSize"), &maxoutbufsize))
                pingtimeout = pinginterval;
 
        if(!get_config_int(lookup_config(config_tree, "MaxOutputBufferSize"), &maxoutbufsize))
-               maxoutbufsize = 4 * MTU;
+               maxoutbufsize = 10 * MTU;
 
        if(!setup_myself())
                return false;
 
        if(!setup_myself())
                return false;
index 52e97e5448193f9260a86d605e80e4996cebd89b..8f56aee50aff918a20f6a0791aa0c9acd7323a6b 100644 (file)
@@ -155,9 +155,10 @@ bool send_tcppacket(connection_t *c, vpn_packet_t *packet)
 {
        cp();
 
 {
        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))
                return true;
 
        if(!send_request(c, "%d %hd", PACKET, packet->len))