<p align="center">
  <img src="assets/linux/com.github.vlisivka.EguiPinger.svg" width="128" height="128" alt="egui_pinger logo">
</p>

# egui_pinger

A powerful network diagnostic tool with a graphical interface designed for Windows and Linux, built with Rust and egui. It is specifically optimized for detecting and diagnosing network issues that affect **IP telephony (VoIP/SIP)** quality.

## Features

- **Multi-host Monitoring**: Periodically ping multiple servers (e.g., Google DNS, Cloudflare, and your SIP server) simultaneously.
- **Full IPv6 Support**: Monitor both IPv4 and IPv6 addresses seamlessly.
- **Intelligent Diagnostics**:
  - **Traceroute (📍)**: View the full network path to any host with a single click.
  - **Automated Breakdown Detection**: Automatically pinpoint which router in the chain is failing during a connection drop.
  - **Unified Ping Pool**: Efficiently monitor shared network hops across multiple targets without redundant traffic.
- **Advanced Network Analysis**:
  - **RTP Jitter (RFC 3550)**: Standard industrial jitter calculation used in VoIP.
  - **MOS (Mean Opinion Score)**: Estimated voice quality score (1.0 - 4.5).
  - **Latency Metrics**: Real-time tracking of Mean, Median, P95, StdDev, and Min/Max RTT.
  - **Outlier Detection**: Automatic identification of "lags" (packets with >3*StdDev deviation).
- **Privacy & Security**:
  - **Interval Jitter**: Randomized delays (±10%) to break traffic periodicity and avoid fingerprinting.
  - **Packet Padding**: Configurable and randomized packet sizes to mask the nature of ICMP traffic.
- **Visual Excellence**:
  - **Sparkline Charts**: Real-time history for the last 300 pings with a 150ms "warning" line.
  - **Dynamic Coloring**: Color-blind friendly palette (Okabe-Ito) for status and latency alerts.
  - **Rich Tooltips**: Detailed explanations and data for every metric on hover.
- **Power-User UI**:
  - **Drag & Drop**: Reorder host rows easily.
  - **Column Customization**: Select which metrics to display for each host individually.
  - **Theme Support**: Adaptive dark/light mode following system settings.
- **Data Persistence**: Automatically saves host lists and individual display settings.
- **System Tools (🔧)**: Built-in window for running common network diagnostic commands (`ip addr`, `ss`, `dig`, `ipconfig`, `netstat`, etc.) directly from the GUI, with a step-by-step troubleshooting guide.
- **Standalone CLI Utility (`mos`)**: A lightweight command-line tool to process standard `ping` output and calculate advanced metrics in real-time.


## Roadmap & Progress

- [x] **Phase 1: Core**: Async ICMP, Multi-host, Persistence.
- [x] **Phase 2: Advanced Logic**: RFC 3550 Jitter, MOS Score, Outlier detection.
- [x] **Phase 3: Privacy & VPN**: Packet padding, interval jittering, traffic masking.
- [x] **Phase 4: UI/UX**: Drag & Drop, Sparklines, Theme support, Column customization.
- [x] **Phase 5: I18n**: Support for English and Ukrainian.
- [x] **Phase 6: Native Diagnostics**: Integrated Traceroute and automated hop-by-hop failure detection.
- [x] **Phase 7: System Tools**: Built-in network diagnostic commands with troubleshooting guide.
- [x] **Phase 8: CLI Utility**: Standalone `mos` tool for processing ping output.


## Technical Stack

- **Language**: [Rust](https://www.rust-lang.org/) (Edition 2024)
- **UI Framework**: [egui](https://github.com/emilk/egui) / [eframe](https://github.com/emilk/egui/tree/master/crates/eframe)
- **Async Runtime**: [Tokio](https://tokio.rs/)
- **I18n**: `tr` crate with `mo-translator` (Pure Rust backend for Windows).
- **CLI Component**: Pure Rust implementation of statistics calculation logic, shared between GUI and CLI.

## Standalone CLI Utility: `mos`

The project includes a lightweight command-line utility called `mos`. It is designed to be used in a pipe with the standard `ping` command to provide real-time advanced statistics without the need for a GUI.

### Usage

```bash
ping google.com | mos
```

### Features

- Processes standard `ping` output from `stdin`.
- Calculates **RFC 3550 Jitter**, **MOS (Mean Opinion Score)**, **P95**, **Median**, and more.
- Uses a sliding window for calculations (default: 300 samples).
- Zero dependencies, ultra-fast, and portable.

### Options

- `-n, --number-of-lines NUM`: Set the sliding window size (default: 300).
- `-e, --enable STAT`: Enable a specific field (e.g., `jitter_mean`, `stddev`, `streak`).
- `-d, --disable STAT`: Disable a specific field.
- `-h, --help`: Show all available statistics and options.


## Building from Source

### Native Build (Linux/Windows)
Ensure you have the Rust toolchain installed.

```bash
git clone https://github.com/vlisivka/egui_pinger && \
cd egui_pinger && \
cargo run --release
```

*Note: On Linux, you may need to allow unprivileged ICMP sockets:*
```bash
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
```
*Alternatively, you can grant `CAP_NET_RAW` capabilities to the binary:*
```bash
sudo setcap cap_net_raw+ep target/release/egui_pinger
```

### Cross-Compilation (Linux to Windows MSVC)
The project includes a `build-releases.sh` script that supports cross-compilation using `cargo-xwin` for MSVC targets.

**Requirements**: `clang`, `lld`, `llvm` (providing `llvm-lib`).

```bash
# On AlmaLinux/Fedora/RHEL:
sudo dnf install clang lld llvm
# Run the release script:
./build-releases.sh
```

## Installation on Linux (User-specific)

You can install the pre-built Linux release into your local home directory without root privileges. This will integrate the app into your system menu and provide an icon.

1.  Download the `x86_64-unknown-linux-gnu-vX.X.X.tar.gz` archive.
2.  Unpack it into `~/.local`:
    ```bash
    tar -xf x86_64-unknown-linux-gnu-0.2.0.tar.gz -C ~/.local
    # Update system databases
    update-desktop-database ~/.local/share/applications
    gtk-update-icon-cache ~/.local/share/icons/hicolor
    ```
3.  Ensure `~/.local/bin` is in your `PATH` (add `export PATH="$HOME/.local/bin:$PATH"` to your `.bashrc` or `.zshrc` if needed).
4.  The application will now appear in your system menus as "egui_pinger".

*Note: You may still need to grant raw network capabilities if you don't run as root:*
```bash
sudo setcap cap_net_raw+ep ~/.local/bin/egui_pinger
```
