Unexpected W5500 Sn_SR response to CONNECT command

Sometimes when connecting in client mode to a server using an open socket (Sn_SR = SOCK_INIT) the W5500 Sn_SR doesn’t behave like I’d expect. After the CONNECT command is sent, the W5500 sets Sn_CR to zero, then I record the values of Sn_SR and Sn_IR at 5ms intervals while waiting for the connection to complete. Sn_SR remains SOCK_INIT (0x13) and Sn_IR = 0. Eventually Sn_SR goes to 0 and Sn_IR to 0x08, indicating a timeout.

Sometimes every Sn_SR sample is SOCK_SYNSENT (0x15) instead of SOCK_INIT. I’d tempted to tempted to label this a sample rate issue if it weren’t so absolutely consistent in returning the same Sn_SR value every time when it behaves this way.

Neither case occurs frequently, but I’d like to understand what’s happening and fix it in some more reasonable way than detecting the problem and trying again.

My processor platform is the Adafruit Metro M4, and my Ethernet shield is the red Wiznet W5500 shield. I’m using the Arduino Ethernet 2.0.0 library (Release 2.0.0 · arduino-libraries/Ethernet · GitHub).

Wireshark log is required to figure out what is going on.Timeout in this state means that W5500 did not receive SYN/ACK in time. Either remote device did not send it, or switch decided not to forward it to W5500. Or W5500 settings are invalid (GW address, MAC address).

Even so, shouldn’t Sn_SR change to SOCK_SYNSENT while waiting for the SYN/ACK instead of staying at SOCK_INIT?

I’m figuring out how to make a custom Kali Linux build so I can run WireShark on my ancient laptop since the Windows XP SP3 I have loaded on it apparently blocks use of promiscuous mode. All I see is broadcast traffic using a SharkTap between the development system and router.

It suggests that there’re also problems with ARP.

If you have any device running standard Linux or Windows with two wired network interfaces, setup this device in bridge mode and run Wireshark on it.

You nailed it. I got WireShark running on Kali-Linux using a SharkTap and saw that the problem is due to the client’s failure to respond to an ARP request.

1 Like