Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, (Let me first of all state that I am a newbie to any form of programming.) I have been trying to create an IP header + TCP header and ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    2

    raw socket not sending packets

    Hi,

    (Let me first of all state that I am a newbie to any form of programming.)
    I have been trying to create an IP header + TCP header and send this to another machine on my network. (using C)
    I used the normal stuff: two structures for the headers, a sockaddr_in structure, call to function socket with SOCK_RAW, setsockopt with HDRINCL and call to sendto.

    All functions seem to return fine (values other then -1) the function that I have used to calculate the checksum for the IPheader matches the value that I manually calculated.
    I just don’t see the anything coming out of the interface on whireshark.
    I assumed that it had something do with my piece of code so I used two examples (including mixter void ru rawip html A brief programming tutorial in C for raw sockets[/url]). They show exactly the same thing functions return fine but no packets being send.

    I use Ubuntu 9.04 2.6.28-14-generic
    The machine has two interfaces one with an ip address the other interface is in promiscuous mode. (both interfaces connected to a switch with port mirroring) I can see all normal traffic in/out.

    I am starting to think that it might have something to do with the system rather then with the pieces of code.
    Does anyone have any suggestion where I can start to look?

  2. #2
    Just Joined!
    Join Date
    Mar 2010
    Posts
    2
    hmm it seems that i am getting closer to the problem myself. it seems that i am being stupid somehow.
    Just send the packet to the loopback interface. Then it does show up on whireshark. the IPheader looks fine however half the TCP header seems to be missing. dont know why yet but should be able to work that out (i hope).
    apologies for any time wasted on reading this.

  3. #3
    Just Joined! KPolulak's Avatar
    Join Date
    Feb 2009
    Location
    New Jersey, USA
    Posts
    42
    Try removing one of your NIC's and see if you can replicate your problem. Things can get really frustrating when dealing with multiple interfaces.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...