static void handle_stagger_timer(void * ptr) { int rand_time; uip_ipaddr_t *dest; dest=(uip_ipaddr_t *)ptr; probe_output(dest); printf("probe %d ADDR=%02x%02x \n",probe_number,((uint8_t *)dest)[14], ((uint8_t *)dest)[15]); probe_total++; //printf("probe %d ADDR=%02x%02x \n",probe_number,((uint8_t *)dest)[14], ((uint8_t *)dest)[15]); //printf("UNJA"); //printf("stagger-rand_timer=%d", rand_time); rand_time=(random_rand()*CLOCK_SECOND)*2/RANDOM_RAND_MAX; //rand_time=1*CLOCK_SECOND; index++; if (index<3 && pt_parents[index].rank !=INFINITE_RANK ) { dest=pt_parents[index].ipaddr; ctimer_set(&stagger_timer, rand_time, &handle_stagger_timer, dest); } else { if(probe_number==(PROBE_NUM_THRESHOLD)) { probe_number=0; adjust_ETX_th(); printf("\nprobe_total=%d\n",probe_total); } } }
int main(int argc, char **argv) { int c; int err; const char *ofields = NULL; ofmt_status_t ofmterr; ofmt_field_t *fields = NULL; uint_t ofmtflags = 0; ipmp_handle_t ih; ipmp_qcontext_t qcontext = IPMP_QCONTEXT_SNAP; ipmpstat_cbfunc_t *cbfunc; ipmpstat_walker_t *walker; char errbuf[OFMT_BUFSIZE]; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else progname++; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); while ((c = getopt(argc, argv, "nLPo:agipt")) != EOF) { if (fields != NULL && strchr("agipt", c) != NULL) die("only one output format may be specified\n"); switch (c) { case 'n': opt |= IPMPSTAT_OPT_NUMERIC; break; case 'L': /* Undocumented option: for testing use ONLY */ qcontext = IPMP_QCONTEXT_LIVE; break; case 'P': opt |= IPMPSTAT_OPT_PARSABLE; ofmtflags |= OFMT_PARSABLE; break; case 'o': ofields = optarg; break; case 'a': walker = walk_addr; cbfunc = info_output_cbfunc; fields = addr_fields; break; case 'g': walker = walk_group; cbfunc = info_output_cbfunc; fields = group_fields; break; case 'i': walker = walk_if; cbfunc = info_output_cbfunc; fields = if_fields; break; case 'p': fields = probe_fields; break; case 't': walker = walk_if; cbfunc = targinfo_output_cbfunc; fields = targ_fields; break; default: usage(); break; } } if (argc > optind || fields == NULL) usage(); /* * Open a handle to the formatted output engine. */ ofmterr = ofmt_open(ofields, fields, ofmtflags, IPMPSTAT_NCOL, &ofmt); if (ofmterr != OFMT_SUCCESS) { /* * If some fields were badly formed in human-friendly mode, we * emit a warning and continue. Otherwise exit immediately. */ (void) ofmt_strerror(ofmt, ofmterr, errbuf, sizeof (errbuf)); if (ofmterr != OFMT_EBADFIELDS || (opt & IPMPSTAT_OPT_PARSABLE)) die("%s\n", errbuf); else warn("%s\n", errbuf); } /* * Obtain the window size and monitor changes to the size. This data * is used to redisplay the output headers when necessary. */ (void) sigset(SIGWINCH, sighandler); if ((err = ipmp_open(&ih)) != IPMP_SUCCESS) die_ipmperr(err, "cannot create IPMP handle"); if (ipmp_ping_daemon(ih) != IPMP_SUCCESS) die("cannot contact in.mpathd(1M) -- is IPMP in use?\n"); /* * If we've been asked to display probes, then call the probe output * function. Otherwise, snapshot IPMP state (or use live state) and * invoke the specified walker with the specified callback function. */ if (fields == probe_fields) { probe_output(ih, ofmt); } else { if ((err = ipmp_setqcontext(ih, qcontext)) != IPMP_SUCCESS) { if (qcontext == IPMP_QCONTEXT_SNAP) die_ipmperr(err, "cannot snapshot IPMP state"); else die_ipmperr(err, "cannot use live IPMP state"); } (*walker)(ih, cbfunc, ofmt); } ofmt_close(ofmt); ipmp_close(ih); return (EXIT_SUCCESS); }