「🏗️」 wip: kinda working
This commit is contained in:
22
src/utils.c
22
src/utils.c
@ -1,4 +1,7 @@
|
||||
#include <ping.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -43,3 +46,22 @@ double get_stddev_rtt(void) {
|
||||
double stddev = 0;
|
||||
return stddev;
|
||||
}
|
||||
|
||||
bool check_for_timeout(struct timeval start, options_t opt) {
|
||||
struct timeval end;
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
double span =
|
||||
(end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) / 1000000.0;
|
||||
if (span > opt.timeout)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void print_stats(void) {
|
||||
printf("--- %s ping statistics ---", address);
|
||||
printf("%d packets transmitted, %d packets received, %f%% packet loss",
|
||||
tx_count, rx_count, (tx_count - rx_count / 2.0) * 100);
|
||||
printf("round-trip min/avg/max/stddev = %f/%f/%f/%f", get_min_rtt(),
|
||||
get_avg_rtt(), get_max_rtt(), get_stddev_rtt());
|
||||
}
|
||||
|
Reference in New Issue
Block a user