]> git.proxmox.com Git - mirror_iproute2.git/blob - netem/pareto.c
iproute: Set ip/ip6 lwtunnel flags
[mirror_iproute2.git] / netem / pareto.c
1 /*
2 * Pareto distribution table generator
3 * Taken from the uncopyrighted NISTnet code.
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <limits.h>
9
10 #include <linux/types.h>
11 #include <linux/pkt_sched.h>
12
13 static const double a=3.0;
14 #define TABLESIZE 16384
15 #define TABLEFACTOR NETEM_DIST_SCALE
16
17 int
18 main(int argc, char **argv)
19 {
20 int i, n;
21 double dvalue;
22
23 printf("# This is the distribution table for the pareto distribution.\n");
24
25 for (i = 65536, n = 0; i > 0; i -= 16) {
26 dvalue = (double)i/(double)65536;
27 dvalue = 1.0/pow(dvalue, 1.0/a);
28 dvalue -= 1.5;
29 dvalue *= (4.0/3.0)*(double)TABLEFACTOR;
30 if (dvalue > 32767)
31 dvalue = 32767;
32
33 printf(" %d", (int)rint(dvalue));
34 if (++n == 8) {
35 putchar('\n');
36 n = 0;
37 }
38 }
39
40 return 0;
41 }