Skip to main content

Pure Python ICMP ping with statistics and hop count for Linux

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, and estimated number of hops.

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)
  • Customizable parameters: count, timeout, interval

Installation

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

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=19.3,
    max=21.1,
    mean=20.2,
    median=20.0,
    jitter=0.7,
    rtt_list=[19.3, 19.7, 20.0, 20.8, 21.1],
    ttl=57,
    hops=8
)

or as dict

{
    'sent': 5,
    'received': 5,
    'loss': 0.0,
    'min': 19.3,
    'max': 21.1,
    'mean': 20.2,
    'median': 20.0,
    'jitter': 0.7,
    'rtt_list': [19.3, 19.7, 20.0, 20.8, 21.1],
    'ttl': 57,
    'hops': 8
}

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.1.0.tar.gz (16.3 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.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyminiping-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc87b02b83d4ee8dfe0181b4eff0cfcee06481f44c8b7a806fa5843570e75738
MD5 fc6a04785aa793e16793ca3033b3827e
BLAKE2b-256 a644ee96cf33ae709c13a1165f40699a62e6c1bc1dd22a13a80379f2de0823ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyminiping-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6562e67a69c118830e01cd8685225a53c7ca8eb3ac83a5b850e769a9f4613b7
MD5 4caa5bd79bdc7c7bdb87ed8be048f4b5
BLAKE2b-256 9ce3d0279c9ed1c87c131fcba7eb28ccadcbfdc4ea68e0dcc9e4df5b69575f01

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