🏗️」 wip: don't understand whats going on

This commit is contained in:
2025-08-16 18:53:02 +02:00
parent 162de73a21
commit b548965d2e
7 changed files with 61 additions and 32 deletions

View File

@ -1,8 +1,8 @@
#include <ping.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
void append_time(double time) {
@ -39,6 +39,9 @@ double get_avg_rtt(void) {
avg += times[i];
}
avg = avg / rx_count;
if (avg < 0) {
avg = 0;
}
return avg;
}
@ -58,10 +61,18 @@ bool check_for_timeout(struct timeval start, options_t opt) {
return false;
}
void print_stats(void) {
printf("--- %s ping statistics ---", address);
printf("%d packets transmitted, %d packets received, %f%% packet loss",
void print_stats(void) {
printf("--- %s ping statistics ---\n", address);
printf("%d packets transmitted, %d packets received, %.0f%% packet loss\n",
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());
printf("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f\n",
get_min_rtt(), get_avg_rtt(), get_max_rtt(), get_stddev_rtt());
}
bool check_for_count(options_t opt) {
if (opt.count == -1)
return false;
if (tx_count > opt.count)
return true;
return false;
}