diff --git a/.gitignore b/.gitignore index 722d5e7..b1097a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.vscode +*.o +a.out +.vscode \ No newline at end of file diff --git a/main.c b/main.c index 9aca163..a42f27f 100644 --- a/main.c +++ b/main.c @@ -42,7 +42,7 @@ void ft_recv(int sock, uint16_t seq, char *ip, double start) time = (get_timestamp() - start) * 1000; checksum = icmp_hdr->checksum; icmp_hdr->checksum = 0; - if (icmp_hdr->seq != seq || calculate_checksum((uint16_t *)icmp_hdr, sizeof(*icmp_hdr)) != checksum) + if (icmp_hdr->seq != seq || calculate_checksum((uint16_t *)icmp_hdr, sizeof(*icmp_hdr)) != checksum) // if checksum or sequence is invalid return; fill_timestamp_array(&stats, time); stats.n_packet_recv++; diff --git a/utils.c b/utils.c index 7bfb413..34a91d1 100644 --- a/utils.c +++ b/utils.c @@ -68,6 +68,8 @@ double get_avg(double *timestamp_array) double avg = 0; int i = 0; + if (timestamp_array[0] == 0) + return (0); while (timestamp_array[i]) { avg += timestamp_array[i];