I wanted to implement the three-way handshake using python.And here is what I did:
1-I created syn packet .
2-I send the packet to the destination .
3-I created a function that will listen to all the traffic that pass through my NIC .it's kinda like sniffer.If this function were to find a packet that is destined to my IP address and the same port that I send the syn packet through, it will parse it .
4-If the flags in the captured packet are set to syn+ack,the function will generate a TCP packet with the ack flag set.
The problem is, before I send the ack packet the system send RST packet . So , what is the meaning of the behaviour?? Is there anyway to stop it??
Note: I am not implementing the three-way handshake for production purposes.I just want to understand how the protocol TCP work.