diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -203,6 +203,7 @@ static int interval = 1000; /* interval between packets, ms */ static int waittime = MAXWAIT; /* timeout for each packet */ static long nrcvtimeout = 0; /* # of packets we got back after waittime */ +static uint16_t lastseq; /* the latest seq # for the received packets */ /* timing */ static int timing; /* flag to do timing */ @@ -985,6 +986,10 @@ (npackets && nreceived >= npackets)) break; } + if (n == 0 && (options & F_FLOOD) == 0 && + (nreceived == 0 || ntransmitted - 1 > lastseq)) + printf("Request timeout for icmp_seq %u\n", + (uint16_t)(ntransmitted - 1)); if (n == 0 || options & F_FLOOD) { if (sweepmax && sntransmitted == snpackets) { if (datalen + sweepincr > sweepmax) @@ -1230,7 +1235,7 @@ timing = 0; } - seq = ntohs(icp.icmp_seq); + seq = lastseq = ntohs(icp.icmp_seq); if (TST(seq % mx_dup_ck)) { ++nrepeats; diff --git a/sbin/ping/ping6.c b/sbin/ping/ping6.c --- a/sbin/ping/ping6.c +++ b/sbin/ping/ping6.c @@ -250,6 +250,7 @@ static int interval = 1000; /* interval between packets in ms */ static int waittime = MAXWAIT; /* timeout for each packet */ static long nrcvtimeout = 0; /* # of packets we got back after waittime */ +static uint16_t lastseq; /* the latest seq # for the received packets */ /* timing */ static int timing; /* flag to do timing */ @@ -1253,6 +1254,10 @@ (npackets > 0 && nreceived >= npackets)) break; } + if (n == 0 && (options & F_FLOOD) == 0 && + (nreceived == 0 || nreceived - 1 > lastseq)) + printf("Request timeout for icmp_seq %u\n", + (uint16_t)(ntransmitted - 1)); if (n == 0 || (options & F_FLOOD)) { if (npackets == 0 || ntransmitted < npackets) pinger(); @@ -1638,7 +1643,7 @@ } if (icp->icmp6_type == ICMP6_ECHO_REPLY && myechoreply(icp)) { - seq = ntohs(icp->icmp6_seq); + seq = lastseq = ntohs(icp->icmp6_seq); ++nreceived; if (timing) { memcpy(&tpp, icp + 1, sizeof(tpp));