← All posts
Series NearWave Series — Part 6 of 6

Performance, Tradeoffs, and Real-World Constraints

·
nearwaveperformancebenchmarkingsystems

NearWave works in controlled conditions. This post examines what happens in real environments — how the three profiles perform, what limits throughput, where hardware matters, and what tradeoffs define the system.

Profile Comparison

NearWave ships three profiles, each targeting a different point in the speed–reliability space:

graph TD
    A[Reliable] -->|50 sym/s · BFSK| B[High error tolerance<br/>Noisy environments]
    C[Fast] -->|100 sym/s · 4-MFSK| D[Balanced throughput<br/>Clean environments]
    E[Ultrasonic] -->|500 sym/s · BFSK| F[Inaudible transfer<br/>Ideal conditions]
ProfileSymbol RateModulationRaw ThroughputEffective (after FEC)Use Case
Reliable50 sym/sBFSK~50 bps~29 bpsNoisy rooms, long range
Fast100 sym/s4-MFSK~200 bps~114 bpsQuiet rooms, close range
Ultrasonic500 sym/sBFSK~500 bps~286 bpsSilent transfer, very close

The “effective” column accounts for Hamming(7,4) overhead — every 4 data bits require 7 transmitted bits, so effective throughput is $\frac{4}{7} \approx 57%$ of raw.

FEC Overhead

Hamming(7,4) is the dominant overhead factor. For a 100-byte payload:

StageSize
Raw payload100 bytes (800 bits)
After Hamming(7,4)175 bytes (1400 bits)
Frame header (FEC’d)~16 bytes
Preamble + footer6 bytes
Total on wire~197 bytes (1576 bits)

The frame overhead (preamble, header, footer) is fixed per transmission. For small payloads, this fixed cost is significant relative to the data. For larger payloads, Hamming overhead dominates.

At 50 bps (reliable profile), transmitting 197 bytes takes ~31.5 seconds. At 200 bps (fast profile), ~7.9 seconds. This is the reality of acoustic data transfer — it’s measured in seconds per hundred bytes, not milliseconds per megabyte.

Hardware Variance

The audio path through real hardware introduces variability that doesn’t exist in WAV-mode testing:

Speaker frequency response — Most laptop speakers roll off below 200 Hz and above 15 kHz. Desktop speakers may extend further. The ultrasonic profile (18+ kHz) is only viable on hardware that can actually produce and capture those frequencies. Many consumer microphones attenuate heavily above 16 kHz.

Microphone sensitivity — Cheap microphones have uneven frequency response. A tone at 4 kHz might be captured cleanly while 3.5 kHz is attenuated by 6 dB, affecting MFSK detection where tones are close together.

DAC/ADC quality — Low-end audio hardware introduces quantization noise and clock jitter. This shows up as reduced Goertzel magnitude and occasional bit errors.

Volume levels — Too quiet and the signal drops below the noise floor. Too loud and the speaker distorts, creating harmonics that interfere with tone detection.

NearWave doesn’t auto-calibrate for hardware. Profile selection is the user’s responsibility. The reliable profile’s wide tone spacing and slow symbol rate compensate for most hardware deficiencies. The fast profile assumes decent hardware.

Ambient Noise

Sound-based transmission shares the medium with everything else producing sound:

  • Speech — Human voice energy (100–4000 Hz) overlaps directly with the audible profiles
  • HVAC — Low-frequency hum (50–500 Hz) raises the noise floor
  • Music — Broadband interference across the entire audible spectrum
  • Office equipment — Fans, keyboards, notifications

Bandpass filtering (Part 4) helps by attenuating out-of-band noise. But in-band noise — sound at the same frequencies as the FSK tones — directly reduces detection accuracy.

The reliable profile tolerates moderate ambient noise because:

  • Wider tone spacing makes it harder for noise to be mistaken for the “wrong” tone
  • Longer symbol duration gives Goertzel more samples to accumulate signal energy
  • BFSK (2 tones) has the widest possible separation between frequencies

The ultrasonic profile avoids most ambient noise by operating above the audible range, but requires hardware capable of producing and capturing those frequencies.

Distance and Attenuation

Sound attenuates with distance. In a quiet room, NearWave works reliably at 1–3 meters with the reliable profile. At 5+ meters, signal strength drops enough that the fast profile becomes unreliable.

The ultrasonic profile is effectively limited to <1 meter. High-frequency sound attenuates much faster than low-frequency sound, and most speakers have significantly reduced output above 18 kHz.

Reflections (echoes) can help or hurt. In a small room, reflected sound adds energy at the receiver. In a large room with hard surfaces, multipath interference can cause destructive cancellation at specific frequencies.

What Works

Based on testing across multiple hardware configurations:

Reliable scenarios:

  • Laptop to phone, same desk, quiet room → fast or reliable
  • Terminal to terminal, 2m apart, office → reliable
  • Encrypted token transfer, same desk → any profile

Marginal scenarios:

  • Across a conference room (5m+) → reliable only, expect retries
  • Near a running dishwasher → reliable with reduced accuracy
  • Phone speaker to laptop mic → reliable (phone speakers have limited frequency response)

Unreliable scenarios:

  • Outdoor with wind → preamble detection fails frequently
  • Playing music in the same room → in-band interference overwhelms the signal
  • Ultrasonic through a phone speaker → most phone speakers can’t produce 18+ kHz

Debug Mode

When things fail, --debug reveals where:

go run ./cmd/nsdt receive --input noisy.wav --debug

Output includes:

  • Per-symbol detected frequencies and magnitudes
  • Preamble correlation scores (did it trigger correctly?)
  • Bitstream before and after Hamming decode (where did errors occur?)
  • CRC32 pass/fail (was the data intact after FEC?)

A typical failure pattern: Goertzel magnitudes are low and close together for multiple symbols, Hamming corrects some but not all, CRC fails. This indicates insufficient signal-to-noise ratio — either move the devices closer, increase volume, or switch to the reliable profile.

Performance Targets

EnvironmentProfileExpectedNotes
Audible, quietFast~200 bps rawBest case for MFSK
Audible, moderate noiseReliable~50 bps rawFEC compensates
Ultrasonic, idealUltrasonic~500 bps rawHardware-dependent
Ultrasonic, real hardwareUltrasonic~300 bps rawSpeaker/mic rolloff

These are raw throughput numbers. After FEC overhead, multiply by $\frac{4}{7}$ for effective data rate.

What’s Next

Areas under active development:

  • Adaptive profiles — Runtime adjustment of symbol duration and tone spacing based on detected noise floor
  • Multi-channel encoding — Transmitting multiple tones simultaneously (OFDM-like) to increase throughput without reducing symbol duration
  • Higher-order modulation — 8-FSK and 16-FSK for environments with high SNR
  • Compression — Pre-compressing payloads to reduce transmission time
  • Bidirectional mode — Using two devices with alternating transmit/receive for ACK-based reliability

NearWave is a protocol and a system. The current implementation proves the concept at production quality. The constraints are physics, not software — and pushing those boundaries is the interesting part.