Expand description
§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);Re-exports§
pub use icmp::IcmpPacket;pub use icmp::IcmpSocket;pub use pinger::Pinger;pub use pinger::PingerBuilder;pub use tcp::TcpPinger;pub use udp::UdpPinger;pub use anti_common as common;
Modules§
- icmp
- ICMP ping implementation
- icmp_
constants - ICMP packet constants
- pinger
- Main pinger coordinator module
- ports
- Common UDP ports for testing
- tcp
- TCP ping implementation
- udp
- UDP ping implementation
Structs§
- Ping
Config - Configuration for ping operations
- Ping
Reply - Result of a single ping operation
- Ping
Statistics - Summary statistics for a series of ping operations
Enums§
Constants§
- VERSION
- Library version
Functions§
- calculate_
checksum - Calculate internet checksum for a byte array
- resolve_
hostname - Resolve hostname to IPv4 address
Type Aliases§
- Ping
Result - Result type for ping operations