Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A pure python ping implementation using raw sockets.

Note that ICMP messages can only be sent from processes running as root (in Windows, you must run this script as ‘Administrator’).

Original Version from Matthew Dixon Cowles

  • copyleft 1989-2011 by the python-ping team, see AUTHORS for more details.

  • license: GNU GPL v2, see LICENSE for more details.

usage

~/python-ping$ sudo ./ping.py google.com

PYTHON-PING google.com (209.85.148.99): 55 data bytes
64 bytes from google.com (209.85.148.99): icmp_seq=0 ttl=54 time=56.2 ms
64 bytes from google.com (209.85.148.99): icmp_seq=1 ttl=54 time=55.7 ms
64 bytes from google.com (209.85.148.99): icmp_seq=2 ttl=54 time=55.5 ms

----google.com PYTHON PING Statistics----
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip (ms)  min/avg/max = 55.468/55.795/56.232

TODOs

  • refactor ping.py

  • create a CLI interface

  • add a “suprocess ping”, with output parser

contribute

Fork this repo on GitHub and send pull requests. Thank you.

Revision history

May 1, 2014

  • Python 3 support added to ping and the project was renamed to python3-ping

January 26, 2012

  • Fixing BUG #4 - competability with python 2.x [tested with 2.7]- Packet data building is different for 2.x and 3.x.’cose of the string/bytes difference.

  • Fixing BUG #10 - the multiple resolv issue.- When pinging domain names insted of hosts (for exmaple google.com)you can get different IP every time you try to resolv it, we shouldresolv the host only once and stick to that IP.

  • Fixing BUGs #3 #10 - Doing hostname resolv only once.

  • Fixing BUG #14 - Removing all ‘global’ stuff.- You should not use globul! Its bad for you…and its not thread safe!

  • Fix - forcing the use of different times on linux/windows formore accurate mesurments. (time.time - linux/ time.clock - windows)

  • Adding quiet_ping function - This way we’ll be able to use this scriptas external lib.

  • Changing default timeout to 3s. (1second is not enought)

  • Switching data syze to packet size. It’s easyer for the user to ignore thefact that the packet headr is 8b and the datasize 64 will make packet with

Oct. 17, 2011

Oct. 12, 2011

Merge sources and create a seperate github repository:

Add a simple CLI interface.

September 12, 2011

Bugfixes + cleanup by Jens Diemer Tested with Ubuntu + Windows 7

September 6, 2011

Cleanup by Martin Falatic. Restored lost comments and docs. Improved functionality: constant time between pings, internal times consistently use milliseconds. Clarified annotations (e.g., in the checksum routine). Using unsigned data in IP & ICMP header pack/unpack unless otherwise necessary. Signal handling. Ping-style output formatting and stats.

August 3, 2011

Ported to py3k by Zach Ware. Mostly done by 2to3; also minor changes to deal with bytes vs. string changes (no more ord() in checksum() because >source_string< is actually bytes, added .encode() to data in send_one_ping()). That’s about it.

March 11, 2010

changes by Samuel Stauffer: replaced time.clock with default_timer which is set to time.clock on windows and time.time on other systems.

November 8, 2009

Fixes by George Notaras, reported by Chris Hallman:

Improved compatibility with GNU/Linux systems.

Changes in this release:

Re-use time.time() instead of time.clock(). The 2007 implementation worked only under Microsoft Windows. Failed on GNU/Linux. time.clock() behaves differently under the two OSes.

May 30, 2007

little rewrite by Jens Diemer:

  • change socket asterisk import to a normal import

  • replace time.time() with time.clock()

  • delete “return None” (or change to “return” only)

  • in checksum() rename “str” to “source_string”

December 4, 2000

Changed the struct.pack() calls to pack the checksum and ID as unsigned. My thanks to Jerome Poincheval for the fix.

November 22, 1997

Initial hack. Doesn’t do much, but rather than try to guess what features I (or others) will want in the future, I’ve only put in what I need now.

December 16, 1997

For some reason, the checksum bytes are in the wrong order when this is run under Solaris 2.X for SPARC but it works right under Linux x86. Since I don’t know just what’s wrong, I’ll swap the bytes always and then do an htons().

Metadata

Release files for python3-ping 2014.05.01.022aa83

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python3-ping 2014.05.01.022aa83
File Size Uploaded Provenance Actions
python3-ping-2014.05.01.022aa83.tar.gz 11.4 kB Without provenance Details for python3-ping-2014.05.01.022aa83.tar.gz

Release files / python3-ping-2014.05.01.022aa83.tar.gz

Download URL python3-ping-2014.05.01.022aa83.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
92f103426d2b60397733f94b29bb34dc52276671f0760d8a2b82013fa248cebf
BLAKE2b-256 checksum
How to use checksums
453bb3024e1014b2253f93db3088b23b3e5004cc57dd3eaa9187aa1b8f8c952f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python3-ping 2014.05.01.022aa83

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page