samuel / python-ping Goto Github PK
View Code? Open in Web Editor NEWPure Python version of ICMP ping
Pure Python version of ICMP ping
Originally from http://svn.pylucid.net/pylucid/CodeSnippets/ping.py This version maintained at http://github.com/samuel/python-ping
Was this program made to run on python 2.7 or 3? There's some syntax problem going on and I have no idea if this is because of the version or what. I'm really thankful if you could help me with this. Thank's!
make a flag in the header packet and then received data by select.select, we can judge the data whether it's the right one.
it was removed today from some reason
Hi @samuel
I would like to use this package to monitor some interfaces using ICMP. A possible scenario is:
a batch of 15 pings executed every 3 seconds (3 seconds delay between two consecutive batches). However pyping, without forcing a specific timeout value, is not possible to do so, because would needs some enhancements:
Is any of the above on your bucket list at the moment?
Cheers,
Mircea
hi,
I noticed that the packets sent in pyping are way too big. After some investigation I found out the padding is 4x larger than expected. It looks like the encoding will add 4 bytes to the datagram for every int in the padBytes array.
I fixed this by changing 'data = bytes(padBytes)' to 'str(bytearray(padBytes))' in /pyping/core.py function 'send_one_ping'.
I understand that bytearray is only available since python 2.6, so to preserve backward compatibility, you may want to use a slightly different method.
I use python 2.7.17 by the way.
regards,
/steven
ps; sorry if i did not put a savvy diff in here. i'm new to this.
we can't run in windows
D:\Program Files\Python3>python ping_new1.py
ping_new1.py:168: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
data = struct.pack("d", default_timer()) + data.encode()
ping_new1.py:130: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
startedSelect = default_timer()
ping_new1.py:132: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
howLongInSelect = (default_timer() - startedSelect)
ping 'heise.de' ... Timeout > 2s
ping 'heise.de' ... Timeout > 2s
ping 'heise.de' ... Timeout > 2s
ping 'heise.de' ... Timeout > 2s
ping 'baidu.com' ... Timeout > 2s
ping 'baidu.com' ... Timeout > 2s
ping 'baidu.com' ... Timeout > 2s
ping 'baidu.com' ... Timeout > 2s
I have much time to solve this problem, I need your help! Thanks !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.