2 * tc_red.c RED maintanance routines.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
19 #include <sys/socket.h>
20 #include <netinet/in.h>
21 #include <arpa/inet.h>
28 Plog = log(prob/(qmax - qmin))
30 int tc_red_eval_P(unsigned qmin, unsigned qmax, double prob)
39 for (i=0; i<32; i++) {
50 burst + 1 - qmin/avpkt < (1-(1-W)^burst)/W
53 int tc_red_eval_ewma(unsigned qmin, unsigned burst, unsigned avpkt)
57 double a = (double)burst + 1 - (double)qmin/avpkt;
60 fprintf(stderr, "tc_red_eval_ewma() burst %u is too small ?"
61 " Try burst %u\n", burst, 1 + qmin/avpkt);
64 for (wlog=1; wlog<32; wlog++, W /= 2) {
65 if (a <= (1 - pow(1-W, burst))/W)
72 Stab[t>>Scell_log] = -log(1-W) * t/xmit_time
75 int tc_red_eval_idle_damping(int Wlog, unsigned avpkt, unsigned bps, __u8 *sbuf)
77 double xmit_time = tc_calc_xmittime(bps, avpkt);
78 double lW = -log(1.0 - 1.0/(1<<Wlog))/xmit_time;
79 double maxtime = 31/lW;
83 for (clog=0; clog<32; clog++) {
84 if (maxtime/(1<<clog) < 512)
91 for (i=1; i<255; i++) {
92 sbuf[i] = (i<<clog)*lW;