2 releases
| 0.1.2 | Jul 19, 2025 |
|---|---|
| 0.1.0 | Jul 17, 2025 |
#23 in #icmp
35 downloads per month
Used in 3 crates
65KB
1.5K
SLoC
Ping Library
A comprehensive library for network connectivity testing using ICMP, UDP, and TCP protocols.
Features
- ICMP Ping: Traditional ping using ICMP echo requests
- UDP Ping: Connectivity testing using UDP packets with ICMP error responses
- TCP Ping: Connection-based testing using TCP handshakes
- Cross-platform: Works on Unix-like systems with appropriate permissions
- Async Support: Non-blocking operations for high-performance applications
Examples
Simple ICMP ping
use anti_ping::{PingConfig, Pinger, PingMode};
use std::net::Ipv4Addr;
let config = PingConfig {
target: Ipv4Addr::new(8, 8, 8, 8),
count: 4,
..Default::default()
};
let mut pinger = Pinger::new(config, PingMode::Icmp)?;
let results = pinger.ping_all()?;
println!("Ping completed: {} packets sent", results.packets_transmitted);
UDP connectivity test
use anti_ping::{PingConfig, Pinger, PingMode};
use std::net::Ipv4Addr;
let config = PingConfig {
target: Ipv4Addr::new(1, 1, 1, 1),
count: 1,
..Default::default()
};
let mut pinger = Pinger::new(config, PingMode::Udp)?;
let reply = pinger.ping_once()?;
println!("UDP ping RTT: {:?}", reply.rtt);
Dependencies
~0.8–9.5MB
~77K SLoC