Skip to contentSkip to conversation

Print received packets as icmp_seq

PATCH New Alexander Graf 1 participant 2 messages Aug 7, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Print received packets as icmp_seq

Now, ping and ping6 print the packets which are actually received, too, not only the amount of sent packets.

It has the format:
icmp_seq=received/seq

---
 ping_common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ping_common.c +1 -1
index be36cbd..83be553 100644
@@ -711,7 +711,7 @@ restamp:
 	} else {
 		int i;
 		__u8 *cp, *dp;
-		printf("%d bytes from %s: icmp_seq=%u", cc, from, seq);
+		printf("%d bytes from %s: icmp_seq=%li/%u", cc, from, nreceived, seq);
 
 		if (hops >= 0)
 			printf(" ttl=%d", hops);
Signature · 1 line
1.5.2.4
#1 lore raw

PATCH 1/1 Print packet loss with more precision

---
 ping_common.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
ping_common.c +3 -3
index 83be553..49acab2 100644
@@ -795,9 +795,9 @@ void finish(void)
 	if (nerrors)
 		printf(", +%ld errors", nerrors);
 	if (ntransmitted) {
-		printf(", %d%% packet loss",
-		       (int) ((((long long)(ntransmitted - nreceived)) * 100) /
-			      ntransmitted));
+		printf(", %f%% packet loss",
+		       (((long long)(ntransmitted - nreceived)) * 100.0) /
+			      ntransmitted);
 		printf(", time %ldms", 1000*tv.tv_sec+tv.tv_usec/1000);
 	}
 	putchar('\n');
Signature · 1 line
1.5.2.4