Comments (2)
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 msie, 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.
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)
- rebar compile won't work HOT 6
- Match error with [{:error, 'google.com', :nxdomain}] HOT 1
- Build on OS X HOT 3
- How to make use of Elapsed value in response HOT 1
- get timeout in tracert:host({8,8,8,8}). HOT 1
- Sending packets via specific network interfaces HOT 4
- :gen__icmp.ping crashes on CentOS 7 HOT 4
- Trouble running via elixir releases HOT 4
- Works on ubuntu v20 (x86_64); timeouts on custom ARM 32-bit Linux distro. HOT 2
- ipv6 works on linux, but not on mac HOT 2
- ipv6 support HOT 2
- Build fails with current pkt master HOT 1
- Running gen_icmp in iex mix project HOT 3
- Deprecation of erlang:now() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gen_icmp.