LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-04-2004, 06:51 AM   #1
wrongman
Member
 
Registered: May 2004
Location: Italy
Distribution: Debian Unstable 64bit
Posts: 99

Rep: Reputation: 15
Question 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
 
Old 05-04-2004, 09:58 AM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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.
 
Old 05-04-2004, 01:34 PM   #3
wrongman
Member
 
Registered: May 2004
Location: Italy
Distribution: Debian Unstable 64bit
Posts: 99

Original Poster
Rep: Reputation: 15
no way to block this packet from the program itself?
 
Old 05-04-2004, 02:17 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pblm in Raw Sockets fpfernando Linux - Software 1 10-08-2005 01:04 AM
Raw Sockets for Alternate Protocols thomas.dean Linux - Networking 4 02-08-2005 03:28 PM
Raw Ethernet Sockets alanwolfen Programming 2 01-06-2005 06:51 PM
can I use mmap with raw sockets? kanth Programming 2 02-28-2004 12:42 PM
raw sockets BashTin Programming 1 06-07-2003 06:34 AM


All times are GMT -5. The time now is 02:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration