/* fprobe.c - main routines for fprobe tool. try to use one process for sending and the other for receiving The following result in cprobe shows all msgs are sent before their responses are received. ============================= 600 592 12088 600 1273 12808 600 1920 12848 600 2537 12870 600 5119 12893 600 7588 12915 600 8134 12937 600 8746 12957 600 9361 14422 600 10645 14452 */ #include "congtool.h" #include static char rcsid[] = "$Id: congtool.c,v 1.5 1996/07/10 18:56:07 carter Exp $"; char hostname[MAXHOSTNAMELEN]; void usage(){fprintf(stderr,"Usage: cprobe hostname\n");} /* forward declarations */ void sortGaps(int gapCount, int *gaps, int *departGaps, int *sortedGaps, int *sortedDGaps); float probeLoop(char * hostName, int packetCount); /* if we did not declare cprobe return float type here the result will be strange, the main() probabaly interpret cprobe as integer float cprobe(char *hostName); */ int main(int argc, char *argv[]) { int npackets = 0; /* number of packets to send */ float bandwidth; /* available bandwidth estimate */ int i; if (argc != 2) { usage(); exit(1); } printf("CPROBE (%s) %s\n", VERSION, argv[1]); bandwidth = -1.0; bandwidth = sprobe(argv[1]); exit(0); } float sprobe(char *host) { float result; result = probeLoop(host, 10); printf ("aprobe: probing result=%f\n", result); return result; } /* print stats for each received packet */ void reportResults(int npackets, hw_time_t depart[], hw_time_t arrive[], int bytes[], int returnCodes, int numPaths) { int i = 0; for (i=0; i< npackets; i++){ printf("pkt %d: %d bytes depart %d arrive %d rtt= %d us ", i, bytes[i], depart[i], arrive[i], arrive[i] - depart[i]); if (arrive[i] > 0) printf("\n"); else printf(" ++ lost ++\n"); } printf("bytes departT arriveT \n=============================\n"); for (i=0; i< npackets; i++){ printf("%5d %8d %8d\n", bytes[i], depart[i], arrive[i]); } if (returnCodes & PacketsInOrder) { printf(" SEQOK "); } else { printf(" NOTSEQOK "); } if (returnCodes & RecordRouteData) { printf(" RR"); } else { printf(" NORR"); } if (returnCodes & DuplicatePackets) { /* tack this string onto the end of the record route info flag that way, it doesn't disrupt the processing by other scripts */ printf("_DUP "); } else { printf(" "); } if (numPaths > 1) { printf("multipath: %d", numPaths); } printf("\n"); } float probeLoop(char * hostName, int packetCount) { int probeSize = 600; int bytesReceived; hw_time_t timeSpent; int numPaths = 0; /* how many paths did the packets take ? */ int returnCodes = 0; hw_time_t depart[MAX_PROBES]; /* dparture time of each packet */ hw_time_t arrive[MAX_PROBES]; /* arrival time of each packet */ int packetSize[MAX_PROBES]; int bytes[MAX_PROBES]; /* size of each packet */ int orderOK[MAX_PROBES]; int gaps[MAX_PROBES]; int departGaps[MAX_PROBES]; int sortedGaps[MAX_PROBES]; int sortedDGaps[MAX_PROBES]; int gapCount = 0; float estimate1 = 0.0, estimate2 = 0.0; float bandwidth = 0.0; float bandwidthVector[NUM_ROUNDS]; float probeSizeVector[NUM_ROUNDS]; int pass = 0; int i = 0, j = 0; int validObservations = 0; int badIteration = 0; /* Chow: look at this bug it was hard code with replace interanl variable to be 8 while outside packetCount variable is set to be 10. A strange bug? intentionally put in? packetCount = 8; */ for(j=0;j