This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 426cc840d apps/ping: fix ping statistics error problem
426cc840d is described below
commit 426cc840d87334acc95837f2746da6160e1962b9
Author: zhouliang3 <[email protected]>
AuthorDate: Sun Apr 24 14:09:02 2022 +0800
apps/ping: fix ping statistics error problem
nsh> ping 192.168.31.162
PING 192.168.31.162 56 bytes of data
56 bytes from 192.168.31.162: icmp_seq=0 time=8 ms
56 bytes from 192.168.31.162: icmp_seq=1 time=27 ms
56 bytes from 192.168.31.162: icmp_seq=2 time=17 ms
56 bytes from 192.168.31.162: icmp_seq=3 time=14 ms
56 bytes from 192.168.31.162: icmp_seq=4 time=16 ms
56 bytes from 192.168.31.162: icmp_seq=5 time=14 ms
56 bytes from 192.168.31.162: icmp_seq=6 time=8 ms
56 bytes from 192.168.31.162: icmp_seq=7 time=87 ms
WARNING: Received after timeout
56 bytes from 192.168.31.162: icmp_seq=8 time=1003 ms
56 bytes from 192.168.31.162: icmp_seq=8 time=6 ms
56 bytes from 192.168.31.162: icmp_seq=9 time=5 ms
10 packets transmitted, 11 received, 4294967287% packet loss, time 10011 ms
Signed-off-by: zhouliang3 <[email protected]>
---
netutils/ping/icmp_ping.c | 14 ++++++--------
netutils/ping/icmpv6_ping.c | 14 ++++++--------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/netutils/ping/icmp_ping.c b/netutils/ping/icmp_ping.c
index 89740d8f2..b02c6e148 100644
--- a/netutils/ping/icmp_ping.c
+++ b/netutils/ping/icmp_ping.c
@@ -329,19 +329,17 @@ void icmp_ping(FAR const struct ping_info_s *info)
ntohs(inhdr->seqno));
retry = true;
}
+ else if (ntohs(inhdr->seqno) < result.seqno)
+ {
+ icmp_callback(&result, ICMP_W_SEQNOSMALL,
+ ntohs(inhdr->seqno));
+ retry = true;
+ }
else
{
bool verified = true;
long pktdelay = elapsed;
- if (ntohs(inhdr->seqno) < result.seqno)
- {
- icmp_callback(&result, ICMP_W_SEQNOSMALL,
- ntohs(inhdr->seqno));
- pktdelay += info->delay * USEC_PER_MSEC;
- retry = true;
- }
-
icmp_callback(&result, ICMP_I_ROUNDTRIP, pktdelay);
/* Verify the payload data */
diff --git a/netutils/ping/icmpv6_ping.c b/netutils/ping/icmpv6_ping.c
index ad9bb875d..96bdae10d 100644
--- a/netutils/ping/icmpv6_ping.c
+++ b/netutils/ping/icmpv6_ping.c
@@ -328,19 +328,17 @@ void icmp6_ping(FAR const struct ping6_info_s *info)
ntohs(inhdr->seqno));
retry = true;
}
+ else if (ntohs(inhdr->seqno) < result.seqno)
+ {
+ icmp6_callback(&result, ICMPv6_W_SEQNOSMALL,
+ ntohs(inhdr->seqno));
+ retry = true;
+ }
else
{
bool verified = true;
long pktdelay = elapsed;
- if (ntohs(inhdr->seqno) < result.seqno)
- {
- icmp6_callback(&result, ICMPv6_W_SEQNOSMALL,
- ntohs(inhdr->seqno));
- pktdelay += info->delay * USEC_PER_MSEC;
- retry = true;
- }
-
icmp6_callback(&result, ICMPv6_I_ROUNDTRIP, pktdelay);
/* Verify the payload data */