Sending Hop Limited UDP packets

Discussion in 'Java' started by Ashoka!, Apr 10, 2007.

  1. Ashoka!

    Ashoka! Guest

    Is there a way to send a UDP packet with a specific TTL however it
    must be a unicast address instead of multicast address. Any ideas?

    Usman Ismail
    Ashoka!, Apr 10, 2007
    1. Advertisements

  2. I think you would have to write your own DatagramSocketImpl. But I'm
    curious as to why you would want a TTL on a unicast UDP packet. Do you
    not want it to get to it's address?
    Knute Johnson, Apr 10, 2007
    1. Advertisements

  3. It's one way of implementing traceroute, but I can't think of any
    other uses.


    Gordon Beaton, Apr 10, 2007
  4. Ashoka!

    Esmond Pitt Guest

    Use a MulticastSocket so you get the setTimeToLive() API and just send
    to a unicast address.
    Esmond Pitt, Apr 11, 2007
  5. Does that actually work?

    I was going to make the same suggestion earlier, but tested first and
    couldn't see (with Wireshark) that the setting had any effect on
    unicast packets. The documentation seems to confirm this:

    "Set the default time-to-live for *multicast* packets sent [...]"


    Gordon Beaton, Apr 11, 2007
  6. Ashoka!

    Esmond Pitt Guest

    oops, err, hmm, maybe not ... on investigation it turns out that there
    are both IP_TTL and IP_MULTICAST_TTL, and
    MulticastSocket.setTimeToLive() sets the latter, and the OP wants the
    former ...

    so you can't do it in Java.
    Esmond Pitt, Apr 12, 2007
  7. Ashoka!

    Ashoka! Guest

    I am trying to implement the tailgating algorithm to measure internet
    Ashoka!, Apr 26, 2007
    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.