rperf3-rs
rperf3-rs is a network throughput measurement tool written in Rust, inspired by iperf3. It aims to provide bandwidth testing for TCP and UDP protocols with a focus on memory safety, async I/O, and ease of use both as a command-line tool and as a library.
What is rperf3-rs?
rperf3-rs allows you to measure the maximum achievable bandwidth between two network endpoints. Whether you're diagnosing network performance issues, validating infrastructure upgrades, or benchmarking network equipment, rperf3-rs provides detailed, real-time statistics about your network's capabilities.
Built from the ground up in Rust, rperf3-rs leverages modern async I/O (via Tokio) to achieve high throughput while maintaining memory safety guarantees. Unlike traditional C-based tools, rperf3-rs eliminates entire classes of bugs (buffer overflows, use-after-free, data races) through Rust's compile-time checks.
Key Capabilities
- Accurate Bandwidth Measurement: Measure TCP and UDP throughput with sub-second interval reporting
- Bidirectional Testing: Test both normal mode (client → server) and reverse mode (server → client)
- Detailed TCP Statistics: On Linux, get comprehensive TCP metrics including retransmits, RTT, congestion window, and PMTU
- UDP Metrics: Track packet loss, jitter, and out-of-order packets for UDP flows
- Dual Interface: Use as a standalone CLI tool or integrate as a Rust library with full async support
- Real-time Callbacks: Monitor test progress programmatically with event-driven callbacks
- JSON Output: Machine-readable output compatible with automation and monitoring systems
- Cross-Platform: Native support for Linux, macOS, and Windows across multiple architectures
Why rperf3-rs?
Performance: Built on Tokio's async runtime with zero-copy buffer management, rperf3-rs achieves 25-30 Gbps throughput on localhost tests.
Safety: Rust's ownership system eliminates memory safety bugs at compile time, making rperf3-rs more reliable than C-based alternatives.
Developer-Friendly: Clean API design with builder patterns, comprehensive error handling, and extensive documentation make integration straightforward.
Modern Architecture: Async/await syntax, modular design, and thread-safe statistics collection provide a solid foundation for network testing applications.
Features
- TCP and UDP Testing: Measure throughput for both TCP and UDP protocols
- Bidirectional Testing: Normal mode (client sends) and reverse mode (server sends)
- Real-time Statistics: Periodic interval reporting with bandwidth measurements
- Progress Callbacks: Get real-time updates during test execution via callbacks
- Multiple Streams: Support for parallel stream testing
- JSON Output: Machine-readable output format for automation
- Library and Binary: Use as a Rust library or standalone CLI tool
- Async I/O: Built on Tokio for high-performance async operations
Quick Start
Installation
Build from source:
The binary will be available at target/release/rperf3.
Basic Usage
Start a server:
Run a client test:
Example test:
# Terminal 1 - Start server
# Terminal 2 - Run 10-second test
Usage
Server Mode
Start a server on the default port (5201):
Custom port and UDP:
# TCP server on port 8080
# UDP server
# Bind to specific address
Client Mode
Basic TCP test:
Common options:
# 30-second test
# UDP test with 100 Mbps target bandwidth
# Reverse mode (server sends data)
# Custom buffer size and parallel streams
# JSON output for automation
# Custom interval reporting (every 2 seconds)
Library Usage
Add to your Cargo.toml:
[]
= { = "https://github.com/arunkumar-mourougappane/rperf3-rs" }
= { = "1", = ["full"] }
Client Example
use ;
use Duration;
async
Client with Progress Callback
Monitor test progress in real-time using callbacks:
use ;
use Duration;
async
Server Example
use ;
async
Detailed JSON Output
When using the --json flag, rperf3 outputs comprehensive test results in a structured JSON format similar to iperf3. This includes:
TCP Mode:
- Connection Information: Socket FD, local/remote addresses and ports
- System Information: OS version, hostname, timestamp
- Test Configuration: Protocol, stream count, buffer size, duration, direction
- Interval Statistics: Per-second measurements with bytes and throughput
- TCP Statistics: Retransmits, congestion window, RTT, RTT variance, PMTU (Linux only)
- Summary Results: Sender/receiver totals with min/max/mean statistics
- CPU Utilization: Host and remote CPU usage percentages (when available)
- Congestion Algorithm: TCP congestion control algorithm in use
UDP Mode:
- Connection Information: Socket FD, local/remote addresses and ports
- System Information: OS version, hostname, timestamp
- Test Configuration: Protocol, stream count, buffer size, duration, direction
- Interval Statistics: Per-second measurements with bytes, throughput, and packet counts
- UDP Statistics: Jitter (ms), lost packets, packet count, loss percentage, out-of-order packets
- Summary Results: Aggregated statistics with jitter and packet loss metrics
Example JSON Output
TCP Mode:
Sample output structure:
UDP Mode:
Sample UDP output:
Platform-Specific Features
Linux: Full TCP statistics including retransmits, RTT, congestion window, and PMTU via TCP_INFO socket option.
Other Platforms: Basic statistics without TCP-specific metrics.
Command-Line Reference
Server Options
| Option | Description | Default |
|---|---|---|
-p, --port <PORT> |
Port to listen on | 5201 |
-b, --bind <ADDRESS> |
Bind to specific address | All interfaces |
-u, --udp |
Use UDP instead of TCP | TCP |
Client Options
| Option | Description | Default |
|---|---|---|
<SERVER> |
Server address to connect to | Required |
-p, --port <PORT> |
Port to connect to | 5201 |
-u, --udp |
Use UDP instead of TCP | TCP |
-t, --time <SECONDS> |
Test duration | 10 |
-b, --bandwidth <MBPS> |
Target bandwidth (UDP only) | Unlimited |
-l, --length <BYTES> |
Buffer size | 131072 |
-P, --parallel <NUM> |
Number of parallel streams | 1 |
-R, --reverse |
Reverse mode (server sends) | Normal mode |
-J, --json |
JSON output format | Human-readable |
-i, --interval <SECONDS> |
Report interval | 1 |
Architecture
The project uses a modular design with clear separation of concerns:
┌─────────────────────────────────────────┐
│ rperf3-rs │
├─────────────────────────────────────────┤
│ CLI Binary │ Library API │
│ (clap + main) │ (public modules) │
├─────────────────────────────────────────┤
│ Client │ Server │ Protocol │
│ Module │ Module │ Module │
├─────────────────────────────────────────┤
│ Config │ Measurements │ Error │
│ Module │ Module │ Module │
├─────────────────────────────────────────┤
│ Tokio Runtime (Async I/O) │
└─────────────────────────────────────────┘
Module Responsibilities
- protocol: Message format and serialization for client-server communication
- client: Client implementation for initiating tests and collecting results
- server: Server implementation for handling connections and running tests
- config: Configuration structures with builder pattern
- measurements: Thread-safe statistics collection and calculation
- error: Custom error types and conversions
Performance
Built with performance in mind:
- Async I/O: Non-blocking operations using Tokio
- Zero-copy: Efficient buffer management
- Thread-safe: Lock-free where possible, using Arc/Mutex when needed
- Optimized builds: Release builds with full optimizations
Typical throughput on localhost: 25-30 Gbps for TCP tests.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development
# Clone and build
# Run tests
# Format code
# Lint
# Run examples
Comparison with iperf3
| Feature | iperf3 | rperf3-rs |
|---|---|---|
| TCP Testing | ✅ | ✅ |
| UDP Testing | ✅ | ✅ |
| Reverse Mode | ✅ | ✅ |
| JSON Output | ✅ | ✅ |
| Parallel Streams | ✅ | ✅ |
| Library API | Limited | Full-featured |
| Language | C | Rust |
| Memory Safety | Manual | Guaranteed |
| Async I/O | No | Yes (Tokio) |
Roadmap
Planned Features
- UDP packet loss and jitter measurement
- Enhanced parallel stream support
- IPv6 improvements
- SCTP protocol support
- TCP retransmission statistics
- CPU utilization monitoring
- Additional output formats (CSV, XML)
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgments
Inspired by iperf3 - the industry-standard network performance testing tool.
Author: Arunkumar Mourougappane
Repository: https://github.com/arunkumar-mourougappane/rperf3-rs