Sorry for reposting.. here i mentioned it worked for me. Means it worked without using the MSG_DONTROUTE option. Why am mentioning is it will be helpful for "Net"ters who are looking into the archive ( As me ;-) ). Thanks, Ramesh -------- Original Message -------- Subject: Re: Building IP header Date: Mon, 24 Dec 2001 17:15:57 +0530 From: S Ramesh <rashanmu@npd.hcltech.com> Organization: HCL Technologies Limited To: Mike Ricketts <mike@earth.li> CC: Net <linux-net@vger.kernel.org> References: <Pine.LNX.4.10.10112241048061.6289-100000@oakley.chf> HI Mike, Thanks for the response. It worked for me. I just tried with some other options. 1. First i changed the protocol field to IPPROTO_ICMP so that i tought of sending ICMP echo packets. 2. Then i built a ICMP packet, which is encapsulated in the IP header which is also given my me. Here i gave a IP address which is not a IP address of any of my interfaces ( I gave 1.2.3.4 ). 3. Now i bind the socket to a interface ( some IP address of the interface in my box ). 4. I sent the packet using sendto ( Remember this is a ICMP echo packet). 5. In my same box i opened a RAW socket with IPPROTO_ICMP as protocol. Here i tried to see the ICMP packet sent by me with source IP 1.2.3.4. I got the packet. It worked. BUT, i want to know that when i give the protocol ( IP hdr ) field to some value between 132-255 ( unassigned ) it is taken as zero. Here comes the problem. I want to sent a message with some protocol field which is unassigned. I used htons(140) but the field is filled with value zero. What i have to do to make it work with my protocol number. Any pointers?? Also will your tool support this( Unassigned protocol - both sending and reception ), yet to check out. Project Purple is nice. TIA, Ramesh Mike Ricketts wrote: > On Sun, 23 Dec 2001, S Ramesh wrote: > > > I want to build a packet with a source IP address and dest ip address ( > > usual case ) given by me and the protocol field in the IP hdr is a > > unassigned protocol number ( i used 140 ). I built the IP header by > > opening a RAW socket and by setting the IP_HDRINCL option. The source IP > > address i gave is not the IP address in any of the interfaces of my > > machine. ( I gave 1.2.3.4 ). I bind the raw socket to a local interface > > ( my ip address is 192.168.100.242 ) and sent the packet using sendto. > > > I think I know what is happening, but my understanding of this is a little > flakey - maybe somebody else can confirm it... > Because you are sending to a local interface, the kernel sends the packet > over the loopback interface rather than sending out and in again, so your > recvfrom is missing it. I think that if you specify MSG_DONTROUTE when > sending the packet, it will behave as you expect and you should see the > packet. > > <shameless plug> > You could be using SendIP > (http://www.earth.li/projectpurple/progs/sendip.html) to send the packet, > without needing to write any code. > sendip -p ipv4 -is <source addr> -id <dest addr> -d data dest_ip > </shameless plug> > > -- > Mike Ricketts <mike@earth.li> http://www.earth.li/~mike/ > > Beware of self-styled experts: an ex is a has-been, and a spurt is a > drip under pressure. - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html