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