X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fprotocol_misc.c;h=18ff13c8de4bfb05a101666af22f2246f209d1a2;hp=52e97e5448193f9260a86d605e80e4996cebd89b;hb=6f1e0ece4e61f30612ed84ca4640635a02892cc8;hpb=de78d79db84c486afcc353884ec1770866beb653 diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 52e97e54..18ff13c8 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 / (float)maxoutbufsize - 1 > (float)rand()/(float)RAND_MAX) return true; if(!send_request(c, "%d %hd", PACKET, packet->len))