ping/
ping.rs

1use std::{net::Ipv6Addr, str::FromStr, time::Duration};
2
3use anyhow::Result;
4use kratanet::icmp::{IcmpClient, IcmpProtocol};
5
6#[tokio::main]
7async fn main() -> Result<()> {
8    let client = IcmpClient::new(IcmpProtocol::Icmpv6)?;
9    let payload: [u8; 4] = [12u8, 14u8, 16u8, 32u8];
10    let result = client
11        .ping6(
12            Ipv6Addr::from_str("2606:4700:4700::1111")?,
13            0,
14            1,
15            &payload,
16            Duration::from_secs(10),
17        )
18        .await?;
19    println!("reply: {:?}", result);
20    Ok(())
21}