Giter Club home page Giter Club logo

icmp.cr's Issues

Arithmetic overflow

Hi,

I get the following when I try to run the example in the readme. I'm using crystal 0.32.1 on Ubuntu Server 16.04 LTS.

Unhandled exception: Arithmetic overflow (OverflowError)
from lib/icmp/src/icmp/packet.cr:0:16 in 'calculate_checksum'
from lib/icmp/src/icmp/request.cr:29:19 in 'initialize'
from lib/icmp/src/icmp/request.cr:14:5 in 'new'
from lib/icmp/src/icmp.cr:54:9 in '__crystal_main'
from /usr/share/crystal/src/crystal/main.cr:97:5 in 'main_user_code'
from /usr/share/crystal/src/crystal/main.cr:86:7 in 'main'
from /usr/share/crystal/src/crystal/main.cr:106:3 in 'main'
from __libc_start_main
from _start
from ???

Thanks,
-G

Look into spec failure, setup CI

Per @joatca on #4, specs are failing on master.

Possibly an intermittent failure? I can't reproduce, but possibly it will reproduce on CI.

By the way, your final test "sequence number" always fails on my system. The first two pings seem to both come back with sequence number 0.

Operation not permitted unless I'm root, even though /proc/sys/net/ipv4/ping_group_range is set

Nice library! Was worried I'd have to code ping myself. :-)

I can't get it to work on Linux unless I'm root, even though I think I have /proc/sys/net/ipv4/ping_group_range set correctly. Any idea what might be wrong?

$ cat /proc/sys/net/ipv4/ping_group_range 
0	2147483647
$ uname -r
4.15.3-2-ARCH
$ id
uid=1000(fraser) gid=1000(fraser) groups=1000(fraser),10(wheel),14(uucp),100(users),614(adbusers)
$ crystal run test.cr 
failed to create socket:: Operation not permitted (Errno)
  from /usr/lib/crystal/socket.cr:0:5 in 'initialize'
  from /usr/lib/crystal/socket.cr:69:3 in 'initialize'
  from IPSocket
  from lib/icmp/src/icmp.cr:44:9 in 'initialize'
  from lib/icmp/src/icmp.cr:26:5 in 'new'
  from test.cr:16:14 in '__crystal_main'
  from /usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'
  from /usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'
  from /usr/lib/crystal/crystal/main.cr:101:7 in 'main'
  from /usr/lib/crystal/crystal/main.cr:135:3 in 'main'
  from __libc_start_main
  from _start
  from ???
$ sudo crystal run test.cr 
0 valid_response took 2ms
1 valid_response took 1ms
2 valid_response took 1ms

The code is just your example modified with a local IP address (although 8.8.8.8 obviously doesn't work either):

require "icmp"

statistics = ICMP::Ping.new("192.168.0.5").ping(count: 3) do |request|
  puts "#{request.sequence} #{request.status} took #{request.roundtrip_time}ms"
end
p statistics

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.