osdl.net!shemminger | a59e8ed | 2005-02-09 22:05:41 +0000 | [diff] [blame] | 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 | } |