Giter Club home page Giter Club logo

Comments (2)

msantos avatar msantos commented on July 30, 2024

On Sat, May 19, 2012 at 02:11:41AM -0700, Benoit Chesneau wrote:

Hi, Any idea how I could return something like :

$ ping friendpaste.com
PING friendpaste.com (94.23.221.113): 56 data bytes
64 bytes from 94.23.221.113: icmp_seq=0 ttl=54 time=36.183 ms
64 bytes from 94.23.221.113: icmp_seq=1 ttl=54 time=321.526 ms

ie, how can I get the ttl ? and packet size (for the last one I guess the payload lenght is OK) .

I checked the source for BSD ping. For the packet size, it is printing
out the size of the packet with the ICMP header removed (by default,
64-8). If you calculate the length from the packet contents that are
returned to you, it won't be exactly as in your example:

1> gen_icmp:ping("google.com").
[{ok,"google.com",
 {74,125,226,0},
 {{3275,0,382786},
  <<" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJK">>}}]
2> byte_size(<<"!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJK">>).
44

The packet is 64 bytes = 8 bytes (ICMP header) + 12 bytes timestamp (3 *
sizeof(u_int32_t), the result from erlang:now()) + 44 bytes payload.

As for ttl, gen_icmp only sees the ICMP header and payload. The TTL
is in the IP header so, at the moment, there is no way to retrieve it.
You could get a value for the TTL by using tracert.

from gen_icmp.

msantos avatar msantos commented on July 30, 2024

I was wrong about the TTL. The inet driver returns the whole IPv4 packet so gen_icmp can get the value. But for IPv6, only the ICMPv6 + payload is returned. Haven't decided what to do here yet (gen_icmp could do the socket handling itself, like tracert), so leaving this issue open.

from gen_icmp.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.