CIP Protocol on W5500

I would like to adapt CIP protocol to my MCU-based project. I have set up the MCU, with W5500 connected, as the server; and my computer as the client. Communication protocol is TCP. The problem I am encountering is, after the connection is established (SYN, SYN ACK, ACK), the client sends a request to my MCU to register a session. W5500 automatically sends back a TCP frame with the PSH and ACK flags set. How do I tell it not to do that? I need to send back to the client a response to open a session and exchange data, according to CIP protocol.

To my understanding any TCP packet, by the design of the TCP protocol, is being acknowledged with ACK. And this action does not depend on higher level protocols.

CIP is located at layers 5-7, above TCP, the ACK response you are talking about is at the layer 4 (TCP).

Maybe I will just send back the response after the ACK.
Also, what is the proper method to read the receive buffer? This is what I have right now:
uint8_t* readBuf;
if (getSn_RX_RSR(2))
uint16_t length = getSn_RX_RSR(2);
wiz_recv_data(2, readBuf, length);
for(int i =0; i <length; i ++)
The output printed on the terminal doesn’t match what I see on Wireshark. Am I missing something?

See W5100 datasheet chapter 4 on the low-level buffer data access method. I do not know how to properly use wiz_recv_data system call from your library (if it handles circularity of the buffer or you must handle it in your application). Check the sources of library you use.

This function is from W5500.h, there are also 2 more read functions in socket.h. I have to see how they differ and which is the right function to use.

I have another question about the registers used for receiving process. Sn_RX_RSR returns the numbers of new receiving data in bytes. Sn_RX_RD returns the address where I should start reading the buffer to get the data. So start reading from Sn_RX_RD address for Sn_RX_RSR bytes gives me the latest received data Am I understanding this correctly? How do I clear the buffer after reading it? Or will it keep adding data until the end of the memory allocated for it, then goes back to the beginning and overwrite the old data?

Yes, correct, but you must do the reading within circular buffer therefore may require 2 transactions to read the data if data spans the boundary.

You do not need to. It will be rewritten by the new data.

Absolutely. In such a circular manner. Writing for sending works in very similar way, but uses different register set and different RAM space.

Thanks Eugeny. This does clear things up a lot.