Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How do I increase the TTL on a socket?

( #11334=categorized question: print w/ replies, xml ) Need Help??
Contributed by c-era on May 12, 2000 at 21:42 UTC
Q&A  > network programming


Description:

I have to write an ICMP program, and the TTL is 1. Does anyone know how to change the TTL?
use Socket; $host="somehost"; socket(SOCK,PF_INET, SOCK_RAW, getprotobyname('icmp')) || die $!; send (SOCK, pack("C2 S5", 17, 0, 0xc898,0x2667,0,0,0), 0x04,sockaddr_i +n (0,inet_aton($host)) ) || die $!;

Answer: How do I increase the TTL on a socket?
contributed by c-era

I found my own answer:

use Socket; $host="somehost"; socket(SOCK,PF_INET, SOCK_RAW, getprotobyname('icmp')) || die $!; send (SOCK, pack("C2 S5", 17, 0, 0xc898,0x2667,0,0,0),0,sockaddr_in (0 +,inet_aton($host))) || die $!; ^
The flag was just set wrong, I also found out how to change the TTL (at least for Solaris):
setsockopt (SOCK,0,4,<TTL>);

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (7)
    As of 2014-08-21 09:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (129 votes), past polls