Skip to content

Add node simulator test script for TCP push testing #8

Description

@jonnyspicer

Summary

Create a standalone Python script that simulates a radar node pushing detection frames over TCP, for use in testing and debugging the TCP push pipeline.

Context

Depends on #6 (TcpServer + TcpReceiver) being complete to test against.

See design spec: docs/superpowers/specs/2026-03-11-tcp-push-detection-forwarding-design.md in the retina monorepo.

Deliverable

tests/simulate_node.py

A CLI tool that connects to tracker-host's TCP server and sends detection frames. Serves as both a test fixture and a manual debugging tool.

Scenarios to support

  • Normal stream — send synthetic detection frames at configurable CPI rate (default 0.5s)
  • Disconnect/reconnect — close socket after N frames, reconnect after configurable delay
  • Multiple nodes — simulate N concurrent nodes with different node_ids
  • Invalid token — connect with wrong token, verify rejection
  • Malformed JSON — send garbage data, verify server handles gracefully
  • Buffer burst — simulate reconnect with a burst of buffered frames (rapid send of N frames)
  • Heartbeat only — connect and send only heartbeats, no detections

CLI interface

# Basic: single node, continuous stream
python tests/simulate_node.py --host localhost --port 30050 --node-id radar-test --token secret

# Multiple nodes
python tests/simulate_node.py --host localhost --port 30050 --nodes 3 --token secret

# Disconnect/reconnect scenario
python tests/simulate_node.py --host localhost --port 30050 --node-id radar-test --token secret --disconnect-after 10 --reconnect-delay 5

# Buffer burst on reconnect
python tests/simulate_node.py --host localhost --port 30050 --node-id radar-test --token secret --disconnect-after 10 --reconnect-delay 5 --buffer-burst 50

Detection frame format

Generate realistic synthetic frames with:

  • Monotonically increasing timestamps
  • 1-5 random detections per frame (random delay/doppler/snr values in plausible ranges)
  • Optional synthetic ADS-B matches

Acceptance criteria

  • Script connects and sends valid newline-delimited JSON frames
  • All scenarios listed above are supported via CLI flags
  • Frames include node_id and token
  • Heartbeats sent during idle periods
  • Clean disconnect handling
  • Useful log output showing what's being sent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions