raw sockets and C
I'm trying to write an application in C that estabilish a TCP connection
"the hard way", I mean, using raw sockets and so filling up all the ip and tcp headers fields... after some days I'm almost finished but i've a problem: i send the first packet (the SYN one), the host B answer me with a packet with flags SYN ACK, and until here, all goes well, but i can't send the third packet with the last ACK... i sniffed with ethereal and i see this: # TCP 1234 > 6666 [SYN] Seq=3926704143 Ack=0 Win=32767 Len=0 # TCP 6666 > 1234 [SYN, ACK] Seq=3741741959 Ack=3926704144 Win=32767 Len=0 MSS=16396 # TCP [TCP ZeroWindow] 1234>6666 [RST] Seq=3926704144 Ack=0 Win=0 Len=0 # TCP [TCP Previous segment lost] 1234>6666 [ACK] Seq=281021674 Ack=2289239775 Win=32767 Len 0 # TCP [TCP ZeroWindow] 1234>6666 [RST] Seq=2289239775 Ack=0 win=0 Len=0 to send the data i tried to use the same socket used for the first packet, then i tried creating another one... but the result is the same... someone knows if I'm missing something? thanks for the help wrongman |
your host A tcp is responding to the SYN|ACK from host B with a RESET, as according to the TCP protocol. port 1234 on host A is not open, so it is not expecting to recieve random SYN|ACK packets, so when it recieve the reply it properly sends a RST. you can't do anything about that unless u hack up the protocol stack. or perahps u can use a iptables rule to drop outgoing RST packets from host A while u do ur testing.
|
no way to block this packet from the program itself?
|
the KERNEL LEVEL NETWORK PROTOCOL STACK, in follownig the tcp protocol, will SEND A RST whenever it receives a SYN|ACK on a closed port, or on an open port when it is not expecting to receive a SYN|ACK. when the client B computer receives this RST, it will then take the socket out of the SYN received state and put it back into LISTEN state. unless u make an iptables rules on client B that drops all incoming RST's , i dont see how to accomplish what you are doing.
|
All times are GMT -5. The time now is 07:04 AM. |