Crate anti_ping

Crate anti_ping 

Source
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§

PingConfig
Configuration for ping operations
PingReply
Result of a single ping operation
PingStatistics
Summary statistics for a series of ping operations

Enums§

PingError
Errors that can occur during ping operations
PingMode
Type of ping operation

Constants§

VERSION
Library version

Functions§

calculate_checksum
Calculate internet checksum for a byte array
resolve_hostname
Resolve hostname to IPv4 address

Type Aliases§

PingResult
Result type for ping operations