Python implementation of TWAMP/TWAMP-light (RFC 5357) and STAMP (RFC 8762)
twampy is a network measurement tool for latency, jitter, and packet loss testing. Originally developed to validate Nokia SR OS and SR Linux TWAMP implementations, it provides a standards-compliant implementation of the Two-Way Active Measurement Protocol and Simple Two-Way Active Measurement Protocol.
- ✅ Multiple Operation Modes - Controller, Control Client, Session Sender, Reflector
- ✅ Dual Stack - IPv4 and IPv6 support
- ✅ QoS Testing - DSCP/TOS marking for quality of service validation
- ✅ Flexible Sizing - Custom padding, jumbo frames, IMIX traffic patterns
- ✅ RFC Compliant - Implements RFC 5357 (TWAMP), RFC 8762 (STAMP), RFC 8972 (STAMP Extensions)
- ✅ No Dependencies - Uses Python standard library only
# Clone and install
git clone https://github.com/nokia/twampy
cd twampy
pip install -e .# Start a reflector
twampy responder :862
# Run a test (from another terminal/host)
twampy controller 192.168.1.100Example output:
===============================================================================
Direction Min Max Avg Jitter Loss
-------------------------------------------------------------------------------
Outbound: 92.89ms 196.63ms 95.15ms 576us 0.0%
Inbound: 0us 0us 0us 0us 0.0%
Roundtrip: 339us 103.53ms 1.91ms 638us 0.0%
-------------------------------------------------------------------------------
Jitter Algorithm [RFC1889]
===============================================================================
| Command | Description |
|---|---|
controller |
Full TWAMP controller (control + sender) |
sender |
TWAMP light session sender |
responder |
TWAMP light reflector |
controlclient |
TWAMP control client only |
dscptable |
Display DSCP/QoS reference table |
# Send 1000 packets at 10ms intervals with DSCP EF marking
twampy sender 192.168.1.100 --count 1000 --interval 10 --dscp ef
# Run controller with verbose logging
twampy controller 192.168.1.100 --verbose
# Start reflector on custom port
twampy responder :20000- Python 3.11 or higher (tested with 3.11 and 3.14)
- No external dependencies (standard library only)
📚 Full Documentation (or see docs/)
- Installation Guide - Detailed installation instructions
- Usage Guide - Examples and use cases
- Configuration Reference - All parameters explained
- Error Codes - Protocol error reference
- DSCP Table - QoS values reference
| Platform | Status | Notes |
|---|---|---|
| Linux | ✅ Full | All features supported |
| Windows | ✅ Full | Requires registry mod for DSCP |
| macOS | DF flag not supported | |
| FreeBSD | DF flag not supported |
- Software timestamping only (typical accuracy: 100μs - 2ms)
- Unauthenticated mode only (no encryption/authentication)
This project is licensed under the BSD-3-Clause license - see the LICENSE.
twampy can be imported and used in Python programs:
import twampy
# Your code here (API documentation coming soon)Contributions are welcome! Please feel free to submit issues or pull requests.
Licensed under the BSD-3-Clause License. See LICENSE for details.
Sven Wisotzky - Nokia