WIZnet Developer Forum

Understanding the tcp/ip algorithm state blocking of the rx data

This is a supplement to my previous question and warrants it’s own thread. I have not read all your previous documents on all your products, however, I have read the w5500 cover to cover, and written many notes in the pages that describe the socket registers and commands and status. I am seeing a clearly odd state with communications. Since code is too difficult to follow, I have shown 6 lines of C code (2,4,6,8,10) with alternating lines showing W5500 status regs (3,5,7,9,11,13)
Step 3 shows the SnSR = 19 (0x13) as expected, and after Step 4 the SnSR becomes 23 (0x17)
This is completely expected, the socket is Established, connected, and waiting to do something.
Step 6 is the actual Send operation, when the other side of the connection receives the 8 bytes, it immediately doubles the bytes, adds two, then sends it back with virtually no delay. Here is where the process gets wonky and needs some kind of explanation.
Previously, I was monitoring the RSR register for the 18 bytes that were expected in and this remained zero until my process failed and I simply disconnected and closed the socket. You pointed this out to me when you mentioned the 500ms delay between the ACK, and the FIN,ACK. Then the remote connection bytes were received. To test this, I immediately jumped to Step 8 and disconnect right after I send data. As you can see in the registers listed in Step 9 the RSR now has the 18 bytes and can receive them in with Step 10…BUT SnSR is 0, this means the SOCK_CLOSED is the status of the socket, how can this be?? I didn’t assert the close() until step 12
Why does the w5500 block the receive data until the socket is closed?? This makes no sense?
All the code to do this is based on my previous question. Everything operates correctly, but it shouldn’t, because the socket is closed. Why does Disconnect() need to be used? Maybe this is covered in a different product manual?

Thank You

Ray

Step 1) Data to send: 01ff0407
Step 2) Establish socket if((ret=socket(sn, Sn_MR_TCP, any_port++, SF_TCP_NODELAY)) == sn)
Step 3) read regs PreC SOCKET RSR(0) SnSR(19) SnMR(33) RX_RD(0) IMR(18)
Step 4) connect to remote if( (ret = connect(sn, destip, destport)) == SOCK_OK)
Step 5) read regs PreSend SOCKET RSR(0) SnSR(23) SnMR(33) RX_RD(0) IMR(18)
Step 6) Send 8 bytes ret = send(sn, buf, len);
Step 7) read regs PreD SOCKET RSR(0) SnSR(23) SnMR(33) RX_RD(0) IMR(18)
Step 8) disconnect to allow Rx if((ret=disconnect(sn)) == SOCK_OK)
Step 9) read regs PostD SOCKET RSR(18) SnSR(0) SnMR(33) RX_RD(0) IMR(18)
Step 10) Rx18 bytes wiz_recv_data(sn, buf, ret);
Step 11) read regs SOCKET RSR(0) SnSR(0) SnMR(33) RX_RD(18) IMR(18)
Step 12) close socket close(sn); // socket close
Step 13) read regs SOCKETClose RSR(0) SnSR(0) SnMR(33) RX_RD(18) IMR(18)

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.