]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_misc.c
Merge branch 'master' into 1.1
[meshlink] / src / protocol_misc.c
index 95a240e18d8ffdbce7f2fe8aa599625ddc68c7d2..02e3859810d2d9f76880abca5be513d852666767 100644 (file)
@@ -151,9 +151,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->buffer->output->off > maxoutbufsize)
+       if(2.0 * c->buffer->output->off / (double)maxoutbufsize - 1 > drand48())
                return true;
 
        if(!send_request(c, "%d %hd", PACKET, packet->len))