🏗️」 wip: kinda working

This commit is contained in:
2025-08-15 23:49:43 +02:00
parent 057fb25cf7
commit 162de73a21
5 changed files with 114 additions and 18 deletions

View File

@ -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());
}