Magenta Telemetry Format
Ultra-lightweight binary telemetry serialization for low-resource African SME environments
Overview
Magenta Telemetry Format is a highly optimized binary serialization format designed for IoT and telemetry data transmission in bandwidth-constrained environments. It achieves 50-80% size reduction compared to JSON while maintaining cross-platform compatibility and schema evolution.
Key Features
- Compact Binary Encoding: Custom wire format optimized for telemetry data
- LZ4 Compression: Optional fast compression for additional size reduction
- Delta Encoding: Only transmit changed fields to minimize bandwidth
- Multi-Platform: Rust core, WASM for browsers, Python bindings
- Offline Relay: Support for LAN proxying through neighbor devices
- Time-Series Ready: Preserves hardware metrics and temporal patterns
- Fast: < 1ms encode/decode for typical telemetry packets
Architecture
┌─────────────────┐
│ Magenta Agent │
│ (Rust) │
└────────┬────────┘
│ Collect telemetry
▼
┌─────────────────┐
│ MTF Encoder │
│ (Rust core) │
└────────┬────────┘
│ Compressed bytes
▼
┌─────────────────────────────┐
│ Transport: QUIC/HTTP │
│ ┌─────────────────────┐ │
│ │ Direct → Backend │ │
│ │ OR │ │
│ │ LAN Proxy → Backend │ │
│ └─────────────────────┘ │
└─────────────────────────────┘
│
▼
┌─────────────────┐ ┌──────────────────┐
│ Backend │ │ Dashboard │
│ (Python/Rust) │ │ (WASM/Browser) │
│ Decode → JSON │ │ Live Decode │
└─────────────────┘ └──────────────────┘
Quick Start
Installation
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build all components
cargo build --release
# Run tests
cargo test --all
# Run benchmarks
cargo bench
Using the CLI
# Encode JSON to MTF binary
magenta-cli encode input.json -o output.mtf
# Decode MTF binary to JSON
magenta-cli decode output.mtf -o output.json
# Inspect MTF file
magenta-cli inspect output.mtf
# Stress test
magenta-cli stress-test --count 10000 --delta
Rust API
use magenta_telemetry_core::{TelemetryData, encode, decode, CompressionType};
// Create telemetry data
let telemetry = TelemetryData {
device_id: "device-001".to_string(),
timestamp: 1735686690000,
cpu_usage_percent: 45.2,
memory_used: 8589934592, // 8GB
// ... other fields
};
// Encode with LZ4 compression
let bytes = encode(&telemetry, CompressionType::Lz4)?;
// Decode
let decoded = decode(&bytes)?;
Python API
from magenta_telemetry import TelemetryData, encode, decode
# Create telemetry
telemetry = TelemetryData(
device_id="device-001",
timestamp=1735686690000,
cpu_usage_percent=45.2,
memory_used=8589934592,
)
# Encode
data = encode(telemetry, compression="lz4")
# Decode
decoded = decode(data)
WASM (Browser/Node.js)
import { TelemetryData, encode, decode } from 'magenta-telemetry-wasm';
// Create telemetry
const telemetry = {
deviceId: 'device-001',
timestamp: 1735686690000,
cpuUsagePercent: 45.2,
memoryUsed: 8589934592,
};
// Encode
const bytes = encode(telemetry, 'lz4');
// Decode
const decoded = decode(bytes);
Format Specification
See FORMAT_SPEC.md for detailed binary format documentation.
Packet Structure Overview
┌──────────────────────────────────────────────────────────┐
│ HEADER (15 bytes fixed) │
├──────────────────────────────────────────────────────────┤
│ Version │ 1 byte │ Format version (0x01) │
│ Flags │ 1 byte │ Compression, delta, proxy │
│ Timestamp │ 8 bytes │ Unix timestamp (milliseconds) │
│ Sequence │ 4 bytes │ Sequence number │
│ Device ID Len │ 1 byte │ Length of device ID (0-255) │
├──────────────────────────────────────────────────────────┤
│ VARIABLE DATA │
├──────────────────────────────────────────────────────────┤
│ Device ID │ N bytes │ UTF-8 device identifier │
│ UUID │ 16 bytes│ 128-bit UUID │
│ Payload │ M bytes │ Encoded telemetry data │
│ Checksum │ 4 bytes │ CRC32 checksum │
└──────────────────────────────────────────────────────────┘
Benchmarks
Preliminary results show significant improvements over standard formats:
| Format | Size (bytes) | Encode (μs) | Decode (μs) | Reduction |
|---|---|---|---|---|
| JSON | 1,247 | 125 | 95 | baseline |
| JSON Lines | 1,198 | 118 | 92 | 3.9% |
| MessagePack | 687 | 45 | 52 | 44.9% |
| CBOR | 712 | 48 | 55 | 42.9% |
| MTF | 312 | 18 | 22 | 75.0% |
| MTF+LZ4 | 198 | 28 | 31 | 84.1% |
Run cargo bench to see actual results on your hardware.
Project Structure
magenta-telemetry-format/
├── core/ # Rust core library (encoder/decoder)
├── wasm/ # WebAssembly bindings
├── python/ # Python bindings (PyO3)
├── cli/ # Command-line tools
├── benches/ # Benchmark suite
└── examples/ # Usage examples
Development
Prerequisites
- Rust 1.70+ (stable)
- wasm-pack (for WASM builds)
- Python 3.8+ (for Python bindings)
- maturin (for Python builds)
Build WASM
cd wasm
wasm-pack build --target web
Build Python Package
cd python
maturin develop # Development build
maturin build --release # Production wheel
Run Tests
cargo test --all --verbose
Generate Documentation
cargo doc --no-deps --open
Use Cases
- IoT Telemetry: Collect metrics from low-power devices
- Mobile Apps: Efficient telemetry from mobile agents in areas with expensive data
- Edge Computing: Local aggregation before cloud transmission
- Offline-First: Store-and-forward architecture for intermittent connectivity
- Real-Time Monitoring: Live dashboards with WASM decoding
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
Author
Built with ❤️ for the Magenta project by the Magenta Research Team.
Status: Under active development
Metadata
Release files for magenta-telemetry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| magenta_telemetry-0.1.0.tar.gz | 23.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| magenta_telemetry-0.1.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
Total release size: 199.9 kB
Release files / magenta_telemetry-0.1.0.tar.gz
| Download URL | magenta_telemetry-0.1.0.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abceb3f3b129d60639342a781968e363879fcc92cd707f43e4173453eaaf2394
|
|
BLAKE2b-256 checksum How to use checksums |
da6bc8c465ba65fae642e46c8c73d5e3934cc40c907b176c99861a55af37713e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.10.2
|
Release files / magenta_telemetry-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | magenta_telemetry-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 176.6 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4ba15ff4d48ea557656a064c2a8f9c6c7d54701c1b56ebfe5cf340ccabcaf0d6
|
|
BLAKE2b-256 checksum How to use checksums |
100d61abba3dfd77f44d6692cd1e1da9e16eb513ca6452ea596e70bbcb99278a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.10.2
|
Security for magenta-telemetry 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.