43 |
#include <stdio.h> |
#include <stdio.h> |
44 |
#include <ctype.h> |
#include <ctype.h> |
45 |
#include <errno.h> |
#include <errno.h> |
|
#include <math.h> |
|
46 |
#include <limits.h> |
#include <limits.h> |
47 |
|
|
48 |
#include "getopt.h" |
#include "getopt.h" |
582 |
out->tv_sec -= in->tv_sec; |
out->tv_sec -= in->tv_sec; |
583 |
} |
} |
584 |
|
|
585 |
|
double |
586 |
|
nsqrt (double a, double prec) |
587 |
|
{ |
588 |
|
double x0, x1; |
589 |
|
|
590 |
|
if (a < 0) |
591 |
|
return 0; |
592 |
|
if (a < prec) |
593 |
|
return 0; |
594 |
|
x1 = a/2; |
595 |
|
do |
596 |
|
{ |
597 |
|
x0 = x1; |
598 |
|
x1 = (x0 + a/x0) / 2; |
599 |
|
} |
600 |
|
while (fabs (x1 - x0) > prec); |
601 |
|
|
602 |
|
return x1; |
603 |
|
} |
604 |
|
|
605 |
int |
int |
606 |
echo_finish () |
echo_finish () |
614 |
double vari = ping_stat->tsumsq / total - avg * avg; |
double vari = ping_stat->tsumsq / total - avg * avg; |
615 |
|
|
616 |
printf ("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", |
printf ("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", |
617 |
ping_stat->tmin, |
ping_stat->tmin, |
618 |
avg, |
avg, |
619 |
ping_stat->tmax, |
ping_stat->tmax, |
620 |
sqrt (vari)); |
nsqrt (vari, 0.0005)); |
621 |
} |
} |
622 |
exit (ping->ping_num_recv == 0); |
exit (ping->ping_num_recv == 0); |
623 |
} |
} |