Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARP requests never succeed (timeout exceeded) #1030

Open
dvdsk opened this issue Jan 5, 2025 · 1 comment
Open

ARP requests never succeed (timeout exceeded) #1030

dvdsk opened this issue Jan 5, 2025 · 1 comment

Comments

@dvdsk
Copy link

dvdsk commented Jan 5, 2025

Stack: Embassy commit a4f8fdd, using the embassy-net-wiznet crate (0.1).

Context:
this happens after about 15 hours of working perfectly though that period is not fixed.

What I need:
Some help debugging this. Is there a place in smolltcp I should add extra tracing? I tried some already but I did not get wiser from it. I might also need some reading up on ARP etc, forgotten most of that stuff now. Is there a resource you can recommend?

source snippet:

pub async fn handle(
    stack: &Stack<'_>,
    publish: &Queues,
    led: LedHandle<'_>,
    driver_orderers: &slow::DriverOrderers,
) {
    let mut rx_buffer = [0; 1024];
    let mut tx_buffer =
        [0; max(SensMsg::ENCODED_SIZE, ErrorReport::ENCODED_SIZE) * 2];

    let mut socket = TcpSocket::new(*stack, &mut rx_buffer, &mut tx_buffer);
    socket.set_timeout(Some(Duration::from_secs(5)));
    socket.set_keep_alive(Some(Duration::from_secs(1)));
    let host_addr = Ipv4Address::new(192, 168, 1, 43);
    let host_port = 1234;

    debug!("Configured socket and connecting");
    loop {
        debug!("socket state: {:?}", socket.state());
        if let Err(e) = socket.connect((host_addr, host_port)).await {
            warn!("connect error: {}", e);
            Timer::after_secs(5).await;
            continue;
        }

        info!("(re-)connected");
        // Prevent out-dated data from being send
        publish.clear().await;

        let (reader, writer) = socket.split();
        match select(
            send_messages(writer, publish),
            receive_orders(reader, &led, &driver_orderers),
        )
        .await
        {
            select::Either::First(e) => {
                warn!("Error while sending messages: {}", e)
            }
            select::Either::Second(e) => warn!("Error receiving orders: {}", e),
        };
        // Or the socket will hang for a while waiting to close this makes sure
        // we can reconnect instantly
        socket.abort();
        Timer::after_secs(60).await; // Experiment: does this help?
    }
}

send_messages and receive_orders are rather simple. The former using socket.write_all() then socket.flush() the latter only does socket.read().

trace:
(note I edited the paths /home/david/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smoltcp-0.12.0/src/macros.rs:18 becomes smoltcp/src/macros.rs:18

WARN  connect error: ConnectionReset
└─ large_bedroom_sensor_node::network::handle::{async_fn#0} @ src/network.rs:103
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG socket state: Closed
└─ large_bedroom_sensor_node::network::handle::{async_fn#0} @ src/network.rs:95
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
DEBUG timeout exceeded
└─ smoltcp::socket::tcp::{impl#9}::dispatch @ smolltcp/src/macros.rs:18
DEBUG address 192.168.1.43 not in neighbor cache, sending ARP request
└─ smoltcp::iface::interface::{impl#2}::lookup_hardware_addr @ smolltcp/src/macros.rs:18
WARN  connect error: ConnectionReset
@Dirbaio
Copy link
Member

Dirbaio commented Jan 5, 2025

this is more likely a bug in embassy-net-wiznet. Do you have a packet capture from the other host that would show whether the ARP requests are coming through or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants