X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=src%2Fprotocol_misc.c;h=02e3859810d2d9f76880abca5be513d852666767;hb=08aabbf9317806bc50a9a6693ca866c8936ce26b;hp=95a240e18d8ffdbce7f2fe8aa599625ddc68c7d2;hpb=551cd19406a560d0d206bff5b4e9da064ec222b6;p=meshlink diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 95a240e1..02e38598 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -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))