Skip to main content

Pure Python ICMP ping with statistics and hop count

Project description

pyminiping

pyminiping is a pure Python ICMP ping library for Linux servers.

It sends one or more ICMP echo packets and provides detailed statistics: min, max, mean, median, jitter, TTL, estimated number of hops, and an OS family guess based on TTL.

Features

  • Pure Python ICMP Echo (RAW socket, requires root or CAP_NET_RAW)
  • Statistics: min, max, mean, median, jitter (standard deviation)
  • Sent/received packet count and loss percentage
  • TTL and estimated hop count (hops)
  • Operating system family guess (os_guess) based on received TTL
  • Customizable parameters: count, timeout, interval, size
  • IPv4 and IPv6 supporting

Installation

git clone https://github.com/roxy-wi/pyminiping.git
cd pyminiping
python3 -m pip install .

Example usage

from pyminiping import ping

try:
    result = ping('8.8.8.8', count=5, timeout=1, interval=0.2)
    print(result)
    print(result.as_dict())
except Exception as e:
    print(f"Ping failed: {e}")

Example Output

PingResult(
    sent=5,
    received=5,
    loss=0.0,
    min=0.0044,
    max=0.0062,
    mean=0.0048,
    median=0.0045,
    jitter=0.0007,
    rtt_list=[0.0062, 0.0044, 0.0045, 0.0044, 0.0045],
    ttl=110,
    hops=19,
    os_guess='Windows'
)

or as dict

{
    'sent': 5,
    'received': 5,
    'loss': 0.0,
    'min': 0.0044,
    'max': 0.0062,
    'mean': 0.0048,
    'median': 0.0045,
    'jitter': 0.0007,
    'rtt_list': [0.0062, 0.0044, 0.0045, 0.0044, 0.0045],
    'ttl': 110,
    'hops': 19,
    'os_guess': 'Windows'
}

Notes

Requires root privileges or CAP_NET_RAW capability (e.g., sudo python3 yourscript.py)

Linux only (tested on Ubuntu/Debian)

The hop count (hops) is calculated using common initial TTL values (64, 128, 255). For most Linux servers this is accurate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyminiping-0.3.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyminiping-0.3.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file pyminiping-0.3.0.tar.gz.

File metadata

  • Download URL: pyminiping-0.3.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyminiping-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0b6d88bb61fac4698c5e82dae6fe42e414ea11c72b2044483bbb7e2e2cba4171
MD5 98408a963952aa5b1830e624531d4736
BLAKE2b-256 f04b8c5677c879d5321ae9536d91383a94f1b863ddf14411ae00f0f5892af88d

See more details on using hashes here.

File details

Details for the file pyminiping-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pyminiping-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyminiping-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9f7e6ea10806da81a5ca11a1cf6eee1004b2b2944b72e6491d689f6f19fd93c
MD5 28259b792f43cacd342c8e598e7c99c2
BLAKE2b-256 6eba64a55c95d150ab62411fb8cf34225d22c39b2691c8264ab435adccbb846e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page