diff --git a/src/device_finders/arp.rs b/src/device_finders/arp.rs index 9ed6b71..0b221e3 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, timeout}; +use tokio::time::{Duration, sleep, timeout}; mod packet_send_receive; @@ -59,6 +59,7 @@ pub async fn find(interface: &str) -> Vec { let send_result = timeout( Duration::from_secs(2), send_packet(sender, send_interface, ipv4_net, mac), + // test_timeout(), ) .await; match send_result { @@ -66,15 +67,15 @@ pub async fn find(interface: &str) -> Vec { Err(_) => println!("Sender timed out"), }; - let receive_result = timeout( - Duration::from_secs(5), - listen_for_packets(receiver, ipv4_net), - ) - .await; - match receive_result { - Ok(_) => println!("Receiver done"), - Err(_) => println!("Receiver timed out"), - }; + // let receive_result = timeout( + // Duration::from_secs(5), + // listen_for_packets(receiver, ipv4_net), + // ) + // .await; + // match receive_result { + // Ok(_) => println!("Receiver done"), + // Err(_) => println!("Receiver timed out"), + // }; // println!("Spawning receiver threads"); // let reciever_thread = thread::spawn(move || { @@ -103,6 +104,6 @@ pub async fn find(interface: &str) -> Vec { devices } -// async fn test_timeout() { -// sleep(Duration::from_secs(10)).await; -// } +async fn test_timeout() { + sleep(Duration::from_secs(10)).await; +} diff --git a/src/device_finders/arp/packet_send_receive.rs b/src/device_finders/arp/packet_send_receive.rs index f237e4d..468e0d5 100644 --- a/src/device_finders/arp/packet_send_receive.rs +++ b/src/device_finders/arp/packet_send_receive.rs @@ -4,6 +4,7 @@ use pnet::packet::arp::{ArpHardwareTypes, ArpOperations, ArpPacket, MutableArpPa use pnet::packet::ethernet::{EtherTypes, EthernetPacket, MutableEthernetPacket}; use pnet::packet::{MutablePacket, Packet}; use pnet::util::MacAddr; +use tokio::time::{Duration, sleep, timeout}; pub async fn send_packet( mut tx: Box, @@ -46,6 +47,7 @@ pub async fn send_packet( ); // thread::sleep(Duration::from_millis(2)); } + sleep(Duration::from_secs(5)).await; // thread::sleep(Duration::from_millis(2)); } }