/* An Emperical Approach to TCP/IP Sequence Number Analysis -------------------------------------------------------- This utility is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. (C) 2001 Michal Zalewski */ // To be honest, this code is crappy. #include #include #include #include #include #include #include double itable[100000]; int cnt; #define SCALING 0.5 int main(int argc, char *argv[]) { int num; double nth, n1th = 0, n2th = 0, n3th = 0; double x, y; double usex, usey, pha = 0; ssize_t len; size_t size; unsigned long tmp; FILE *fh = NULL; char *buf = malloc(100); if (argc > 1) { if (argv[1]) { fh = fopen(argv[1], "r"); if (fh == NULL) { printf("Cannot open %s\n", argv[1]); return 1; } } } else fh = stdin; while ((len = getline(&buf, &size, fh)) > 0) { errno = 0; tmp = strtoul(buf, NULL, 0); if (errno) { perror("vseq"); return 1; } itable[cnt++] = tmp; if (cnt >= 100000) break; } num = 0; usex = sin(pha); usey = cos(pha); printf("X,Y\n"); while (num < cnt) { double x1, y1, z1; nth = itable[num]; num++; x1 = (nth - n1th) * SCALING; y1 = (n1th - n2th) * SCALING; z1 = (n2th - n3th) * SCALING; x = (x1*usey+z1*usex); y = y1 + (z1*usey-x1*usex) / 2; if (num > 4) printf("%lf,%lf\n", x, y); n3th=n2th; n2th=n1th; n1th=nth; } return 0; }