#include #include #include int msgSize = 1000; /* in terms of bytes!!! */ int noOfMsgs = 10; int debug = 0; int iteration = 1; double bwrLowerBound = 1000; double bwrUpperBound = 1000000; double bwrReportValue; double abw; int bwrReportValid; void help_msg() { printf("format: abm -[dn:l:u:s:i:] hostname \n"); printf(" option: d set debug mode\n"); printf(" option: n set number of messages sent\n"); printf(" option: l set lower bound of probing bandwidth\n"); printf(" option: u set upper bound of probing bandwidth\n"); printf(" option: s set message size\n"); printf(" option: i set the number of iteration\n"); } main(argc, argv) int argc; char *argv[]; { int sock; struct sockaddr_in from; extern char *optarg; extern int optind; int option_exist = 0; int c; char *hostname; int lbw, ubw; char buf[128]; int i; FILE *fp; /* process command line args */ while ((c=getopt(argc,argv,"dn:l:u:s:i:")) != EOF) { option_exist = 1; switch(c) { case 'd': debug = 1; printf("turn on debug mode.\n"); break; case 'i': if ((iteration = atoi(optarg)) < 1) iteration = 1; break; case 'n': if ((noOfMsgs = atoi(optarg)) < 1) noOfMsgs = 10; break; case 'l': if ((lbw = atoi(optarg)) > 0) bwrLowerBound = lbw; break; case 'u': if ((ubw = atoi(optarg)) > 0) bwrUpperBound = ubw; break; case 's': if ((msgSize = atoi(optarg)) < 1) msgSize = 600; break; case '?': help_msg(); exit (1); default: fprintf (stderr, "unrecognized arg >%s<\n", optarg); help_msg(); exit (1); } } printf("Lower bound of probing bandwidth is set to %g\n", bwrLowerBound); printf("Upper bound of probing bandwidth is set to %g\n", bwrUpperBound); printf("The number of msgs sent is set to %d\n", noOfMsgs); printf("msgSize is set to %d\n", msgSize); printf("iteration is set to %d\n", iteration); hostname = argv[optind++]; printf("hostname=%s\n", hostname); for (i=1; i<= iteration; i++) { sprintf(buf, "./abwm3 -l %f -u %f -n %d -s %d %s", bwrLowerBound, bwrUpperBound, noOfMsgs, msgSize, hostname); printf("cmd=%s\n", buf); system(buf); fp = fopen("probeResult.txt", "r"); fscanf(fp, "bwr.reportValue=%lf\n", &bwrReportValue); fscanf(fp, "bwr.lowerBound=%lf\n", &bwrLowerBound); fscanf(fp, "bwr.upperBound=%lf\n", &bwrUpperBound); fscanf(fp, "bwr.reportValid=%d\n", &bwrReportValid); fclose(fp); printf("iteration %d: abw=%lf, lbw=%lf, ubw=%lf, ", i, bwrReportValue, bwrLowerBound, bwrUpperBound); if (bwrReportValid) { printf(" reportValid\n"); abw = bwrReportValue; } else printf(" reportNotValid\n"); } printf("final estimate abw = %lf\n", abw); }