#signal #transfer #protocols #audio-devices #data-transfer #frame

sonar

Simple data transfer protocol using audio signals

2 releases

0.0.2 Feb 1, 2025
0.0.1 Feb 1, 2025

#104 in Audio

Download history 3/week @ 2024-12-08 140/week @ 2025-01-26 110/week @ 2025-02-02

250 downloads per month

MIT license

71KB
908 lines

Sonar Icon
Sonar

GitHub Crates.io Docs.rs

Features

  • Air-Gap Data Transfer: Enable secure data transmission across air-gapped systems using audio signals
  • Real-time Signal Processing: Monitor and visualize audio signals during transmission
  • Modular Encoding Support: Flexible architecture supporting multiple encoding schemes (FSK, future: PSK, ASK)
  • Error Detection & Correction: Built-in CRC and ECC for reliable data transfer
  • Cross-platform Compatibility: Hardware-agnostic design working with standard audio devices
  • Configurable Parameters: Adjustable frequency, sample rate, and transmission speed
  • Protocol Stack Architecture: Layered design with frames, packets, and segments
  • Signal Strength Analysis: Real-time monitoring of transmission quality

Tech Stack

  • Core Protocol:
    • Rust for robust and efficient implementation
    • cpal for cross-platform audio I/O
    • bytes for efficient byte manipulation
  • Signal Processing:
    • rustfft for Fast Fourier Transform
    • Custom FSK implementation for digital encoding
  • Error Handling:
    • Built-in CRC16 for error detection
    • Reed-Solomon ECC for error correction

Protocol Stack

┌─────────────────┐
│    Message      │ High-level container
├─────────────────┤
│     Frame       │ Transmission units
├─────────────────┤
│    Packet       │ Data organization
├─────────────────┤
│    Segment      │ Raw data handling
└─────────────────┘

Installation

  1. Clone the repository:
git clone https://github.com/Yrrrrrf/sonar.git
cd sonar
  1. Build the project:
cargo build --release
  1. Run tests:
cargo test

Usage

Basic Example

use sonar::{audio::{AudioDev, capture::AudioCapture, playback::AudioPlayback}, encoding::FSKEncoder};

// Initialize audio devices
let capture = AudioCapture::default();
let playback = AudioPlayback::new(Box::new(FSKEncoder::default()))?;
let device = AudioDev::new(capture, playback)?;

// Send data
let data = b"Hello, World!";
let stream = device.send(data)?;

// Receive data
let (stream, received) = device.listen()?;

Signal Monitoring

use sonar::audio::signal::SignalMonitor;

let mut monitor = SignalMonitor::new(48, Box::new(FSKEncoder::default()));
monitor.print_header();
monitor.process_samples(&samples);

Current Implementation Status

Our modular architecture includes:

  • ✅ Core audio I/O system
  • ✅ FSK encoding/decoding
  • ✅ Frame-level protocol
  • ✅ Basic error detection
  • ✅ Signal monitoring
  • 🔄 Advanced error correction
  • 🔄 Flow control
  • 🔄 Session management

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit changes: git commit -m 'Add some feature'
  4. Push to branch: git push origin feature/your-feature
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~4–32MB
~469K SLoC