add ttl error when verbose is active

This commit is contained in:
2025-06-03 00:43:19 +02:00
parent c2a00ab4b3
commit 71ec3ea4d2
4 changed files with 93 additions and 29 deletions

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/26 19:54:25 by tomoron #+# #+# */
/* Updated: 2025/06/01 22:09:27 by tomoron ### ########.fr */
/* Updated: 2025/06/02 22:10:42 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -60,7 +60,8 @@ void ping_end_print(t_settings *set, char *host, t_stats *stats)
printf("--- %s ping statistics ---\n", host);
percent = ((double)(stats->sent - stats->received) / stats->sent) * 100.0;
printf("%lu packets transmitted, %lu packets received, %d%% packet loss\n", stats->sent, stats->received, percent);
printf("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", stats->min, stats->avg, stats->max, stddev);
if(stats->received)
printf("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n", stats->min, stats->avg, stats->max, stddev);
}
int ping_host(t_settings *set, char *host)
@ -88,10 +89,10 @@ int ping_host(t_settings *set, char *host)
if(tmp)
waitlist_add(&wl, tmp);
usleep(100);
receive_icmp(set, info, &wl, &stats);
receive_icmp(set, &wl, &stats);
}
while(wl && !g_stop && timediff(&set->last_send_time) < set->linger)
receive_icmp(set, info, &wl, &stats);
receive_icmp(set, &wl, &stats);
ping_end_print(set, host, &stats);
freeaddrinfo(info);
waitlist_free(wl);