First, RST introduction
RST marks a reset, an exception to the closed connection.
1. Send the RST packet off the connection, do not have to wait for the buffer packets are sent out, directly discard the buffer in the packet, send rst.
2. The receiving end receives the RST packet and does not have to send an ACK packet to confirm it.
Second, when to send rst bag
1. Establish a connected Syn to reach a port, but there is no service on the port that is listening.
2. TCP receives a section on a connection that does not exist at all.
3. The request timed out. Set the Recv timeout by using the setsockopt so_rcvtimeo option. When a data timeout is received, the RST package is sent.
Third, try to manually send rst bag
1. Use shutdown, close closes socket, send is fin, not rst.
2. Use sleep before the socket closes. To run the program CTRL + C, will send fin, not rst.
3. Before the socket closes, perform return, exit (0), exit (1), and send fin, not rst.
None of the above methods can send RST packets. To send the RST packet, you need to spoof the packet to send it yourself.
Test code: http://blog.csdn.net/guowenyan001/article/details/11742621
Resources:
RST attack: http://baike.baidu.com/view/1044719.htm
The presence of RST in several connections: http://my.oschina.net/costaxu/blog/127394