/* apegen.c */ /* Generate traffic on a particular lc */ #include #include #include "atmdd.h" #include #include #include #include struct timezone dummy = {0,0}; struct tms timeb; int frames; void sigint( int dummy) { printf("Frames sent = %d \n", frames); exit(1); } char buf[XB_SIZE]; main( int argc, char **argv) { int in; int fd; int len; int vci; int rc; int fc; int blk; int count = 0; int sent = 0; int lc; int psr = 4; struct timeval time1; struct timeval time2; double tu1; double tu2; blk = 1000; fd = open("/dev/ape25", O_RDWR); memset(buf, 'A', sizeof(buf)); if (argc < 2) { printf("This sends stdin to the vci specified. \n"); printf("You must give vci number in decimal as parm 1. \n"); printf("You may give blk size in decimal as parm 2. \n"); printf("You may give byte count in decimal as parm 3. \n"); printf("You may give the psr in decimal as parm 4. \n"); exit(1); } sscanf(argv[1], "%d", &vci); if (argc > 2) sscanf(argv[2], "%d", &blk); if (argc > 3) sscanf(argv[3], "%d", &count); if (argc > 4) sscanf(argv[4], "%d", &psr); lc = ape_createlc(fd, vci); ape_tmqcfg(fd, vci & 7, 26 * 1024 * 1024, 1, 1); ape_lccfg(fd, vci, psr, 4096); printf("Sending to vci %d \n", vci); printf("Frame size %d bytes \n", blk); signal(SIGINT, sigint); fc = 0; gettimeofday(&time1,&dummy); while ((sent < count) || (count <= 0)) { long *loc; loc = (long *)buf; *loc = fc; rc = ape_send(fd, vci, buf, blk); sent += blk; fc += 1; if (rc < 0) { printf("Send returned %d \n", rc); break; } frames += 1; } times(&timeb); printf("User time = %6d.%02d \n", timeb.tms_utime / 100, timeb.tms_utime % 100); printf("System time = %6d.%02d \n", timeb.tms_stime / 100, timeb.tms_stime % 100); gettimeofday(&time2,&dummy); #if 0 printf("time 1: %d %d\n",time1.tv_sec, time1.tv_usec); printf("time 2: %d %d\n",time2.tv_sec, time2.tv_usec); #endif tu1 = 1000000 * time1.tv_sec; tu1 += time1.tv_usec; tu2 = 1000000 * time2.tv_sec; tu2 += time2.tv_usec; printf("Elapsed time= %8.2lf \n", (tu2 - tu1)/ 1000000); printf("MBits / sec = %8.3lf \n", 8 * count / (tu2 - tu1)); printf("Frames sent = %8d \n", fc); printf("Frames/usec = %8.3lf \n", fc / (tu2 - tu1)); fprintf(stderr, "%6d \t %6d.%02d \t %6d.%02d \t %8.2lf \t %8.3lf \t %8d \t %8.3lf \n", blk, timeb.tms_utime / 100, timeb.tms_utime % 100, timeb.tms_stime / 100, timeb.tms_stime % 100, (tu2 - tu1)/ 1000000, 8 * count / (tu2 - tu1), fc, fc / (tu2 - tu1)); }