I am packing my own tcp packets and send it to another ubuntu machine. SYN and SYN-ACK can be successfully sent and received. However after receiving SYN-ACK, a RST packet is sent. The following is how I use the socket:
SYN:
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)
#prepare customized ip header
#prepare customized tcp header
packet = ip_header + tcp_header + user_data
s.sendto(packet, (dest_ip , 0))
ACK for SYN-ACK:
#update the tcp header
packet = ip_header + tcp_header + user_data
s.sendto(packet, (dest_ip , 0))
After the first SYN is sent and the SYN-ACK is received, the initiating machine will send a RST packet.
I am guessing the client socket is closed but am not sure how to confirm and fix that. Thank you in advance!