/* cprobe.c - main routines for cprobe tool. $Header: /home/roycroft/carter/Ping+/rpr/src/Release/RCS/congtool.c,v 1.5 1996/07/10 18:56:07 carter Exp $ */ #include "congtool.h" #include static char rcsid[] = "$Id: congtool.c,v 1.5 1996/07/10 18:56:07 carter Exp $"; char hostname[MAXHOSTNAMELEN]; int debug = 0; int noOfMsgs; int equalBWTimeGap = 1; int msgSize = 600; int packetSize[MAX_PROBES]; double sendingTime[MAX_PROBES]; /* sending time of each packet */ double receivingTime[MAX_PROBES]; /* receiving time of each packet */ double receivingTimeAA[MAX_PROBES]; /* receiving time of each packet */ double sendingTimeGap[MAX_PROBES]; /* sending time gap of each packet */ double absSendingTimeGap[MAX_PROBES];/* absolute sending time gap */ double receivingTimeGap[MAX_PROBES]; double absReceivingTimeGap[MAX_PROBES]; double gapDifference[MAX_PROBES]; double absGapDifference[MAX_PROBES]; double bwrLowerBound, bwrUpperBound; 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); /* 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); */ float aprobe(char *host) { float result; noOfMsgs = 10; result = probeLoop(host); printf ("aprobe: probing result=%f\n", result); return result; } 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 = aprobe(argv[1]); exit(0); } /* 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"); } void setupNextIteration(double bwrLowerBound, double bwrUpperBound) { int i; /* initialize receiving time vector */ for (i = 1; i< noOfMsgs; i++) { receivingTimeGap[i] = 0; receivingTime[i] = 0; } /* initialize sendingTime Vector */ sendingTime[1] = 0.01; /* startProbeTime */ printf("sendingTime[1]=%f\n", sendingTime[1]); for (i = 1; i< noOfMsgs; i++) { if (equalBWTimeGap) { sendingTimeGap[i]= msgSize/(bwrLowerBound+i*(bwrUpperBound-bwrLowerBound)/(noOfMsgs-1)); sendingTime[i+1] = sendingTime[i]+sendingTimeGap[i]; printf("sendingTime[%d]=%f\n",i+1, sendingTime[i+1]); } else { double intervalStepA = msgSize*(bwrUpperBound-bwrLowerBound)/(bwrUpperBound*bwrLowerBound*(noOfMsgs-2)); sendingTimeGap[i]= msgSize/bwrLowerBound-intervalStepA*(i-1); sendingTime[i+1] = sendingTime[i]+sendingTimeGap[i]; } } for (i=1; i<=noOfMsgs; i++) { absSendingTimeGap[i] = sendingTime[i]-sendingTime[1]; } for (i=1; i