go-ping / ping

ICMP Ping library for Go
MIT License
1.31k stars 344 forks source link

ping multiple hosts #213

Closed yuzhichang closed 1 year ago

yuzhichang commented 2 years ago

Need an util based on go-ping/ping which ping multihost and show statistics like nping and fping :

$ sudo nping -c 2 --icmp scanme.nmap.org google.com
Starting Nping 0.7.80 ( https://nmap.org/nping ) at 2022-05-15 16:35 CST
SENT (0.0654s) ICMP [192.168.1.11 > 45.33.32.156 Echo request (type=8/code=0) id=12242 seq=1] IP [ttl=64 id=48567 iplen=28 ]
RCVD (0.3496s) ICMP [45.33.32.156 > 192.168.1.11 Echo reply (type=0/code=0) id=12242 seq=1] IP [ttl=52 id=14125 iplen=28 ]
SENT (1.0656s) ICMP [192.168.1.11 > 45.33.32.156 Echo request (type=8/code=0) id=12242 seq=2] IP [ttl=64 id=48567 iplen=28 ]
RCVD (1.3479s) ICMP [45.33.32.156 > 192.168.1.11 Echo reply (type=0/code=0) id=12242 seq=2] IP [ttl=52 id=14377 iplen=28 ]
SENT (2.0667s) ICMP [192.168.1.11 > 45.33.32.156 Echo request (type=8/code=0) id=12242 seq=2] IP [ttl=64 id=48567 iplen=28 ]
RCVD (2.3492s) ICMP [45.33.32.156 > 192.168.1.11 Echo reply (type=0/code=0) id=12242 seq=2] IP [ttl=52 id=14628 iplen=28 ]
SENT (3.0680s) ICMP [192.168.1.11 > 172.217.163.46 Echo request (type=8/code=0) id=39652 seq=2] IP [ttl=64 id=48567 iplen=28 ]

Statistics for host scanme.nmap.org (45.33.32.156):
 |  Probes Sent: 2 | Rcvd: 3 | Lost: -1  (922337203685477580800.00%)
 |_ Max rtt: 1282.405ms | Min rtt: 282.347ms | Avg rtt: 616.309ms
Statistics for host google.com (172.217.163.46):
 |  Probes Sent: 2 | Rcvd: 0 | Lost: 2  (100.00%)
 |_ Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
Raw packets sent: 4 (112B) | Rcvd: 3 (138B) | Lost: 1 (25.00%)
Nping done: 2 IP addresses pinged in 4.11 seconds

$ sudo fping -a -A -c 5 -I tun0 192.168.110.16 192.168.110.8
192.168.110.16 : xmt/rcv/%loss = 5/5/0%, min/avg/max = 8.75/23.5/42.4
192.168.110.8  : xmt/rcv/%loss = 5/5/0%, min/avg/max = 8.53/17.8/33.6
SuperQ commented 2 years ago

PRs welcome.