Skip to main content

Network time-delay simulation with statistical analysis and plotting

Project description

pydelay

pydelay is a Python package for simulating and analysing network time delays. It supports two statistical delay models, a Gaussian long-distance model and an exponential short-distance model, and produces publication-ready plots of the delay distribution and signal pulse train.

Installation

pip install pydelay

Quick Start

As a library

import pydelay

# Run a long-distance (Gaussian) delay simulation
result = pydelay.delay("l", n_packets=5000, simulation_time=120.0, seed=42)

print(f"Mean delay : {result.mean_delay:.3f} s")
print(f"Std  delay : {result.std_delay:.3f} s")
print(f"Min  delay : {result.min_delay:.3f} s")

# Plot the results
fig, axes = pydelay.plot(result, show=True)

# Save the figure
pydelay.plot(result, save="delay_plot.png")

As a command-line tool

# Long-distance model, default settings
pydelay l

# Short-distance model, custom packet count and seed
pydelay s --npack 10000 --stime 60 --seed 0

# Skip writing the CSV output file
pydelay l --no-csv

Delay Models

Flag Model Distribution
l Long-distance Gaussian μ = 1.50 s, σ = 0.50 s
s Short-distance Exponential min ≈ 1 ms, mean ≈ 2 ms

API Reference

pydelay.delay(model, *, n_packets, simulation_time, seed, output_csv)

Run the delay simulation and return a SimulationResult.

Parameter Type Default Description
model "l" or "s" Delay model
n_packets int 5000 Number of packets to simulate
simulation_time float 120.0 Time horizon in seconds
seed int | None None Random seed for reproducibility
output_csv str | Path | None "delay_data.csv" Path to save CSV; None to skip

pydelay.plot(result, *, zoom_start, zoom_stop, show, save)

Plot the pulse train and delay distributions.

Returns (fig, (ax_signal, ax_dist, ax_dist2)).

SimulationResult

Attribute Description
.send_time Packet send timestamps (ndarray)
.simulated_delay Sampled delays (ndarray)
.pulse_time / .pulse_values Pulse train arrays
.min_delay Minimum delay
.mean_delay Mean delay
.std_delay Standard deviation of delay
.simdelay Dict of {time, signals} for external use

Requirements

  • Python ≥ 3.10
  • numpy ≥ 1.24
  • matplotlib ≥ 3.7
  • scipy ≥ 1.10

License

MIT © Parham Kebria

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

pydelay-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

pydelay-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pydelay-0.1.2.tar.gz.

File metadata

  • Download URL: pydelay-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydelay-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8ab3ac022e3c20190122e6deb6ce42aa33b6b3412fb5c0af0f54526c75e3d341
MD5 cda50870bb7afb31c56efd4ce5a7e947
BLAKE2b-256 a25262a8df6fd43ab9aec7fe22cf1500c6f2ea1a9b7e792a8cef22a3a4abf1eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydelay-0.1.2.tar.gz:

Publisher: publish.yml on parhamkebria/pydelay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydelay-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pydelay-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydelay-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 04ce03f13c9e34c53cc59db651ed9a57e35170882280746614d354475e4fd313
MD5 66c30cfcb0bc6d83c39c627cfc749d2e
BLAKE2b-256 b69fad4f155b054d00ff443e886d06dd2125ed4eb821bfad2aa3dde50594e63e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydelay-0.1.2-py3-none-any.whl:

Publisher: publish.yml on parhamkebria/pydelay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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