Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple ping implementation [closed]

I need simple ping that will return some float number or None if destination unreachable. I am using Python 3 and windows and don't want to use standart ping, cause i have to decode bytes from shell and parse results. I know nothing about implementation of ICMP protocol so ready to use library is the best choice.

like image 992
m9_psy Avatar asked Apr 11 '26 12:04

m9_psy


2 Answers

You could use a pure Python implementation like the following:

https://pypi.python.org/pypi/ping

or if you prefer this one:

http://www.python.org/~jeremy/python.html

and also take a look here, because they are discussing about the subject and you may find it useful:

python non-privileged ICMP

UPDATE

Without the need of patching for Py 3, a very simple example:

https://github.com/volftomas/pyicmp

like image 149
asalic Avatar answered Apr 13 '26 01:04

asalic


Active State Recipes is always the first place when I want to find such tiny/common/useful code snippets.

Here's one:

icmplib (Python recipe)

It works in Python3,

like image 42
Leonardo.Z Avatar answered Apr 13 '26 00:04

Leonardo.Z



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!