How to receive UDP and ICMP packet using one UDP socket, (Path MTUD)

Discussion in 'Linux Networking' started by Rajat, May 27, 2004.

  1. Rajat

    Rajat Guest

    Dear All,

    Can we configure one socket to receive two different protocols packet.
    Like how can we made a UDP socket to receive udp as well as icmp

    Actually I am implementing Path MTUD, so for that I sent some udp
    probs to destination host, now I want that the same socket at client
    side must be able to receive both udp response and icmp error
    messages(like host unreachable, port unreachable etc).

    Another approach is that, we will use two sockets for both source and
    destination, form source we will send udp probs(through udp socket)
    while at destination host, after receiving that prob(through udp
    socket), application will make an icmp packet and sent it back to the
    source host (using ICMP socket). And here at source host, that message
    and other icmp error messages will be received by icmp socket.

    But this approch dosen't look efficient to me, what u people say? If
    Any one has another approch plz let me know.

    Eagerly waiting for some +ve pings.
    Rajat, May 27, 2004
    1. Advertisements

  2. Rajat

    Cameron Kerr Guest

    You need to use two sockets and select() on them for readability. The
    ICMP socket will need to be a RAW IP socket, IIRC, and will require root

    Get yourself a copy of Unix Network Programming (3rd version is
    the latest). I have the 2nd version, which I used for teaching network
    programming last year. Its a truly great book that everyone will refer
    you to in newsgroups.

    You might also want to have a look to see what error (if any) you get on
    your UDP packet when fragmentation is needed, but Don't Fragment is set.
    You may need to use the recvmsg functions for this, plus maybe set some
    socket options to turn on Don't Fragment.

    Actually, I think UNP covers how to do Path MTUD in one of the
    exercises, IIRC (it's at work, I can't currently check.)
    Cameron Kerr, May 27, 2004
    1. Advertisements

  3. Rajat

    James Knott Guest


    You don't!


    Fundamentalism is fundamentally wrong.

    To reply to this message, replace everything to the left of "@" with
    James Knott, May 27, 2004
  4. Rajat

    Andrew Keith Guest

    i think you cant ..

    since UDP and ICMP are really different binds, i dont think you can
    make a socket from both at the same time. (SOCKET_UDP, SOCKET_RAW)

    Andrew Keith, May 29, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.