ping-async

Crates.ioping-async
lib.rsping-async
version0.1.1
sourcesrc
created_at2024-03-17 08:53:17.928369
updated_at2024-06-12 20:02:15.324362
descriptionUnprivileged Async Ping
homepagehttps://lib.rs/crates/ping-async
repositoryhttps://github.com/hankbao/ping-async
max_upload_size
id1176319
size46,254
Hank Bao (hankbao)

documentation

https://docs.rs/ping-async

README

ping-async

This crate can send unprivileged ICMP echo requests and receive echo replies asynchronously on both Windows and macOS. On Linux, it requires the net.ipv4.ping_group_range sysctl parameters to allow unprivileged users to create the ICMP sockets.

On Windows, it uses the IcmpSendEcho2Ex and Icmp6SendEcho2 win32 API. On macOS and Linux, it uses the ICMP sockets with the help of tokio. Due to the latter's asynchronous nature, the time accuracy could be affected by the system's load.

Example

$ cargo run --example ping 1.1.1.1
Reply from 1.1.1.1: status = Success, time = 8.133ms
Reply from 1.1.1.1: status = Success, time = 8.92ms
Reply from 1.1.1.1: status = Success, time = 10.653ms
Reply from 1.1.1.1: status = Success, time = 8.456ms

$ cargo run --example ping 2606:4700:4700::1111
Reply from 2606:4700:4700::1111: status = Success, time = 8.454ms
Reply from 2606:4700:4700::1111: status = Success, time = 9.307ms
Reply from 2606:4700:4700::1111: status = Success, time = 9.056ms
Reply from 2606:4700:4700::1111: status = Success, time = 9.408ms
Commit count: 23

cargo fmt