diff --git a/src/device_finders/arp.rs b/src/device_finders/arp.rs index 0b221e3..b682db1 100644 --- a/src/device_finders/arp.rs +++ b/src/device_finders/arp.rs @@ -7,7 +7,7 @@ use pnet::{ ipnetwork::IpNetwork, }; use tokio::task; -use tokio::time::{Duration, sleep, timeout}; +use tokio::time::{Duration, Instant, sleep, timeout}; mod packet_send_receive; @@ -55,17 +55,21 @@ pub async fn find(interface: &str) -> Vec { let send_interface = network_interface.clone(); println!("Starting sender"); + let start = Instant::now(); let send_result = timeout( - Duration::from_secs(2), + Duration::from_millis(10), send_packet(sender, send_interface, ipv4_net, mac), - // test_timeout(), ) .await; match send_result { Ok(_) => println!("Sender done"), Err(_) => println!("Sender timed out"), }; + println!( + "Sender took {} millisecs", + (Instant::now() - start).as_millis() + ); // let receive_result = timeout( // Duration::from_secs(5), diff --git a/src/device_finders/arp/packet_send_receive.rs b/src/device_finders/arp/packet_send_receive.rs index 468e0d5..11b26b3 100644 --- a/src/device_finders/arp/packet_send_receive.rs +++ b/src/device_finders/arp/packet_send_receive.rs @@ -45,10 +45,8 @@ pub async fn send_packet( ðernet_packet.to_immutable().packet(), Some(interface.clone()), ); - // thread::sleep(Duration::from_millis(2)); } - sleep(Duration::from_secs(5)).await; - // thread::sleep(Duration::from_millis(2)); + // sleep(Duration::from_millis(1)).await; } } diff --git a/src/main.rs b/src/main.rs index ea227df..0c50f2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ mod device_finders; #[tokio::main] async fn main() { - let devices = device_finders::arp::find("eno1").await; + let devices = device_finders::arp::find("wlp1s0").await; for device in devices.iter() { println!("{}", device);