Hi there,

I am working on a network application using ICMP packets over a raw AF_INET socket and was wondering if anyone knows how to set the TTL for the transmission?

It looks like in C++ and other languages you can but can't find any way of setting it in PHP.

What I need to do is set a socket option for the IP protocol (getprotobyname("ip")) for the option IP_TTL but IP_TTL isn't defined anywhere. It looks like being 4 on most UNIX systems but if I try this manually (not a good idea anyway) no joy.

I'm creating the socket as: $socket=socket_create(AF_INET,SOCK_RAW,1);

When I get a reply including the IP header the TTL is contained but I can find no options to read/write this value.

I hope I have been clear - any help is much appreciated.

Regards,

Dave.

    This documentation bug report seem to indicate that it is indeed impossible to set TTL.

    bug reporter wrote:

    The traceroute example does not seem right because it is not possible to
    set a TTL value of an ip packet in PHP.

    with a followup of

    response wrote:

    This bug has been fixed in the documentation's XML sources.

      Hi johanafm,

      Thanks for your response.

      Drat! I thought that might well be the case but thought it worth an ask.

      I will have to see about raising it as a request or something.

      Thanks for the info.

      Regards,

      Dave.

        Write a Reply...