TCP socket uncontrolled reset


I have a question regarding uncontrolled resets that are occuring on my TCP socket. I am opening socket and few times per minute a socket reset is automatically triggered by my W5500 chip and I am wondering if anyone had a simillair problem. Between receiving a TCP stream of packets W5500 sends automatically a packet RST, ACK which resets the socket and asks for a new handshake. I have a KPALVTR register set on 2 everytime after my software puts it in SOCK_ESTABLISHED state.

Bellow I am adding a wireshark screenshot where is W5500 and is my PC. They are connected via router into a LAN network. PC is sending W5500 a stream through TCP socket as i mentioned eariler.

Many thanks,

RST packet means that remote node is no more ready receiving the data. W5500 says that it is not willing to receive any more data on this connection (port). Look into W5500 code why it closes the socket. Or perform tracing/debugging looking at the socket status and data being transferred.

I have debugged a bit in the w5500 library code and discovered that the socket is closed in recv() function because the return of getSn_SR(0) suddenly appears to be SOCK_CLOSED (line of code 426). RX buffer is for sure not filled up because the value of RSR is 42 in decimal. Do you have any idea on what I could do next to discover why status register of socket is sudenly of value SOCK_CLOSED in recv function? Which registers would you check?

Hard to say if incoming data is liable for this without looking at the last packet exchange internals, but Wireshark does not show FIN, therefore closure must not happen. Please check what your code does, most probably at some point it writes to wrong register or there’s some signal/condition causing code to close the socket. In other words, put debug output before any action being done on the W5500 (registers) and then analyze the log sequence what has been actually done on it and where writes/reads were performed.

By now I have figured out that w5500 is not reseting because the MR register is set correctly at the time of closing TCP socket so I am exluding power supply issues. In my loop that is being executed I am writing only to Sn_IR register. Could writing to Sn_IR with numbers larger than 0x1F be reseting the TCP socket? Is there any other registers that I could check?

Actually no I am not writing to Sn_IR registers with larger numbers because setSn_IR is doing the & 0x1F AND operation and like this handling larger numbers.