0
votes

I use raw socket to build a tcp client program and run it on machine A and I run a regular tcp server program on machine B

the raw socket-based client program first send a SYN packet and then it receives a SYN/ACK packet from the remote tcp server then the kernel of machine A sends a RST to the remote tcp server

the sequence number and ack-sequence number is fine what are potential reasons?
and how to deal with it? thanks!

BTW: I used tcpdump to capture packets on the remote machine B and it shows "TCP port numbers reused" for the SYN packet from client, actually before the client send the SYN, I used

netstat -tnp

to check on-going tcp sessions, and it shows nothing

1

1 Answers

1
votes

This is perfectly normal. If a machine receives a SYN/ACK packet it doesn't expect, it should respond with a RST to let the other side know that it has no knowledge of or interest in that connection. The kernel sent a RST because that's what it's supposed to do -- it has no idea what your program is doing.

If you're trying to run your own TCP stack on a machine that already has a TCP stack, you'll have to prevent the regular TCP stack from responding to machines your stack is trying to talk to -- otherwise, they'll be talking to two TCP stacks which can't possibly work.