2 * tc_core.c TC core library.
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>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 int tc_setup_estimator(unsigned int A, unsigned int time_const, struct tc_estimator *est)
28 for (est->interval = 0; est->interval <= 5; est->interval++) {
29 if (A <= (1<<est->interval)*(TIME_UNITS_PER_SEC/4))
32 if (est->interval > 5)
35 for (est->ewma_log = 1; est->ewma_log < 32; est->ewma_log++) {
36 double w = 1.0 - 1.0/(1<<est->ewma_log);
38 if (A/(-log(w)) > time_const)
42 if (est->ewma_log == 0 || est->ewma_log >= 31)