pub fn ping() {
    /*
     */
    println!("Opening packet capturing library");
    let lib = open_best_library().expect("Could not open any packet capturing library");
    println!("Library opened, version is {}", lib.version());
    let interf_name = "eth0"; //replace with whatever is available on your platform
    println!("Opening the {} interface", interf_name);
    let mut interf = lib
        .open_interface(&interf_name)
        .expect("Could not open network interface");
    println!("Interface opened, data link: {}", interf.data_link());

    //send some packets
    println!("Sending 5 packets:");
    for i in 0..5 {
        println!("Sending ICMP ping packet no {}", i);
        interf.send(&ICMP_PACKET).expect("Could not send packet");
    }

    //receive some packets.
    println!("Receiving 5 packets:");
    for _ in 0..5 {
        let packet = interf.receive().expect("Could not receive packet");
        println!("Received packet: {}", packet);
    }
}
/// This example shows automatic choosing of the best underlying library
/// available on your system and dynamic dispatch of calls to the right
/// implementation.
///
/// For most applications this is the recommended approach.
This example shows automatic choosing of the best underlying library
available on your system and dynamic dispatch of calls to the right
implementation.

For most applications this is the recommended approach.
This example shows automatic choosing of the best underlying library available on your system and dynamic dispatch of calls to the right implementation . For most applications this is the recommended approach .
pub fn ping() {
    /*
     */
    println!("Opening packet capturing library");
    let lib = open_best_library().expect("Could not open any packet capturing library");
    println!("Library opened, version is {}", lib.version());
    let interf_name = "eth0"; //replace with whatever is available on your platform
    println!("Opening the {} interface", interf_name);
    let mut interf = lib
        .open_interface(&interf_name)
        .expect("Could not open network interface");
    println!("Interface opened, data link: {}", interf.data_link());
    //send some packets
    println!("Sending 5 packets:");
    for i in 0..5 {
        println!("Sending ICMP ping packet no {}", i);
        interf.send(&ICMP_PACKET).expect("Could not send packet");
    }
    //receive some packets.
    println!("Receiving 5 packets:");
    for _ in 0..5 {
        let packet = interf.receive().expect("Could not receive packet");
        println!("Received packet: {}", packet);
    }
}
pub fn ping ( ) { /*
     */ println ! ( " " ) ; let lib = open_best_library ( ) . expect ( " " ) ; println ! ( " " lib version ( ) ) ; let interf_name = " " ; //replace with whatever is available on your platform println ! ( " " interf_name ) ; let mut interf = lib . open_interface ( & interf_name ) . expect ( " " ) ; println ! ( " " interf data_link ( ) ) ; //send some packets println ! ( " " ) ; for i in 0 .. 5 { println ! ( " " i ) ; interf . send ( & ICMP_PACKET ) . expect ( " " ) ; } //receive some packets. println ! ( " " ) ; for _ in 0 .. 5 { let packet = interf . receive ( ) . expect ( " " ) ; println ! ( " " packet ) ; } }
This example shows automatic choosing of the best underlying library
available on your system and dynamic dispatch of calls to the right
implementation.
This example shows automatic choosing of the best underlying library available on your system and dynamic dispatch of calls to the right implementation .