I am currently developping a TCP/IP stack ; I am running under Linux and I use libnet (for transmitting) and libpcap (for capturing Ethernet frames ) to simulate the link layer.
I have started to work on TCP, more specifically on the active opening of a connection. Basically, I send a SYN packet, the remote host responds with a SYN-ACK which I must acknowledge by an ACK. The problem is immediately after I receive a SYN-ACK, a RST packet is sent to the server, probably by the kernel, not by my own program anyway. I think the packets captured by libpcap and analysed by my network stack are also captured by the kernel who doesn't understand why he has received a SYN-ACK packet from a host he never tried to connect to and thus sends a RST to cancel the connection.
So basically, the connection is reset while it has even not been established, making it difficult for me to try other tests.
How could I solve this problem ? Thanks in advance.