Closed robko23 closed 8 months ago
My further attempts on debugging this revealed that the same sometimes happens with ARP and does not even get to the SYN part.
INFO Initializing spi
INFO Initializing enc28j60 driver
INFO Initializing smoltcp
INFO smoltcp initialized
TRACE [0]: adding
TRACE state=Closed=>SynSent
INFO Initialized
TRACE outgoing segment will send data or flags
TRACE sending SYN
DEBUG address 192.168.128.81 not in neighbor cache, sending ARP request
TRACE SocketHandle(0): neighbor 192.168.128.81 missing, silencing until t+1.000s
INFO connected: SynSent
TRACE SocketHandle(0): neighbor 192.168.128.81 silence timer expired, rediscovering
TRACE outgoing segment will send data or flags
TRACE sending SYN
DEBUG address 192.168.128.81 not in neighbor cache, sending ARP request
TRACE SocketHandle(0): neighbor 192.168.128.81 missing, silencing until t+1.000s
TRACE SocketHandle(0): neighbor 192.168.128.81 silence timer expired, rediscovering
TRACE outgoing segment will send data or flags
TRACE sending SYN
DEBUG address 192.168.128.81 not in neighbor cache, sending ARP request
TRACE SocketHandle(0): neighbor 192.168.128.81 missing, silencing until t+1.000s
TRACE SocketHandle(0): neighbor 192.168.128.81 silence timer expired, rediscovering
TRACE outgoing segment will send data or flags
TRACE sending SYN
DEBUG address 192.168.128.81 not in neighbor cache, sending ARP request
TRACE SocketHandle(0): neighbor 192.168.128.81 missing, silencing until t+1.000s
TRACE SocketHandle(0): neighbor 192.168.128.81 silence timer expired, rediscovering
TRACE outgoing segment will send data or flags
TRACE sending SYN
check that get_ephemeral_port()
is returning a different port every run, for example from a hardware RNG. If it returns the same port after a reboot, you can get fun issues when the same 4-tuple is reused, because the state for it on the PC side is left over from previous runs.
Otherwise it might be a bug in the enc28j60 driver, check if it's dropping packets. if it is I'd suggest filing an issue against it, since it's not a smoltcp issue.
If it's this one, it's unmaintained since 2019. Embassy has another newer, maintained driver based of a fork of the japaric one, See example (for nRF, you can port it to stm32 combining it with stm32 spi). I can personally confirm that one works well, I've been using in production for a few years.
Thanks for the ideas!
I found out that get_ephemeral_port()
was always returning the same port, so I changed it to be somewhat random (my MCU doesn't have HW RNG). However, it still doesn't work.
I will try to change the library (I am using japaric's) and hopefully it will start working
I have ported my app to embassy and can confirm the driver is working
Hi, this might be an error on my side, but it seems weird. I have following code:
It is basically the "client" example merged with enc28j60 driver. On my computer I have a nc process listening on port 9999. In wireshark, I can see SYN sent to my PC and nc responding with ACK, however, smoltcp is not registering this and is "flooding" my PC with SYN packets. The entire wireshark pcap is here: https://www.mediafire.com/file/fs7g7tffyb917l9/smoltcp.pcap/file (will be deleted on 28/10/23) Here are the logs from the MCU:
The physical connection to the enc28j60 is working, I added a log statement every time a packet is received. The fun part is that this setup is working in like 1/20 runs. Any idea why this is happening? What I have done wrong?