Thread: raw socket to dgram communication

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    1

    raw socket to dgram communication

    This question has probably been asked a few times but my search didn't revel my exact question. OS is Fedora.

    The server app (written by another group) creates a socket using AF_INET and SOCK_DGRAM, binds to INADDR_ANY and a port, and then is using read() to the file descriptor to "attempt" to grab any packets sent to the server interface with the assigned port.

    We have attempted to create our client app with a socket using PF_PACKET, SOCK_RAW, IPPROTO_RAW - PF_INET, SOCK_RAW, IPPROTO_UDP - and several variations. We are calling the connect function to set the default desitination and then the write function to our file descriptor but we can't communicate with the server app (which we don't have the power to change). We have also attempted to use sendto(). The interface control document indicates that we need to be able to plug in a fixed MAC address and a fixed IP that won't be what is assigned to the actual interfaces so this requires us to create a RAW socket.

    My question is if the server stays that way it is created above and we are required to create a RAW socket on our end what is the correct configuration for all of the settings in between along with the correct function calls to allow a socket created RAW talking to a socket created using DGRAM.

  2. #2
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Cole701,

    Sounds like a really good question. Be right back, I'll have to do some reading...pardon me please I haven't done networking in a couple years -- it gets a little sensitive for my tastes.

    Best Regards,

    New Ink -- Henry

  3. #3
    Registered User
    Join Date
    Jul 2010
    Location
    Oklahoma
    Posts
    107
    Cole701,

    It is in Chapter 25 and Chapter 26 of W. Richard Stevens UNIX NETWORK PROGRAMMING: Networking APIs: Sockets and XTI. 2nd Ed. Vol. 1 New Jersey: Prentice Hall 1998. ISBN: 0-13-490012-X.

    The way it's put together there, the idea is to a socket to read from the data link layer of the protocol stack directly (for Linux anyway). Check out SOCK_PACKET (for a keyword search). The filtering is handled at the application layer (the client application) so the implementation is a little more involved than just opening a UDP socket to the server you were talking about. He's rather elaborate with it.... May I ask on what you are working? What sort of system would require such constrained interface control document?

    As for your question: "...what is the correct configuration for all of the settings in between along with the correct function calls to allow a socket created RAW talking to a socket created using DGRAM?" I can put them together, but I am concerned about being involved with gray/black-ware at this point.

    Best Regards,

    New Ink -- Henry
    Last edited by new_ink2001; 09-02-2010 at 02:49 PM. Reason: format bibliography

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Why can't you just bind another IP to the network interface and use a real DGRAM socket? Sounds like the only reason you can't use DGRAM is because you can't bind the right IP onto the interface. Why can't you?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux raw socket programming
    By cnb in forum Networking/Device Communication
    Replies: 17
    Last Post: 11-08-2010, 08:56 AM
  2. Why the local socket program occur core dump?
    By chenayang in forum Linux Programming
    Replies: 16
    Last Post: 08-16-2010, 08:39 AM
  3. Specific ether type with raw socket under linux
    By sinacbe in forum Networking/Device Communication
    Replies: 1
    Last Post: 12-25-2009, 08:04 AM
  4. Raw socket
    By like_no_other in forum Networking/Device Communication
    Replies: 4
    Last Post: 03-28-2009, 02:05 PM
  5. Socket communication hanging
    By zee in forum C Programming
    Replies: 15
    Last Post: 08-05-2004, 11:52 PM