Architecture & Wire Protocol
LocalMetro is built around a lean, open, length-prefixed JSON protocol over standard TCP. No proprietary cloud stacks.
Protocol & Connection Architecture
Zero proprietary black boxes. LocalMetro uses standard length-prefixed JSON frames over raw TCP sockets, advertised over mDNS and UDP.
4-Tier Connection Fallback (ADR-010)
LocalMetro tries faster and more direct physical links first before falling back to network broadcasts:
Direct USB-C cable link (192.168.42.x subnet). Works in airplane mode, zero Wi-Fi interference, maximum transfer speed.
Discovers the Mac's _localmetro._tcp service via Apple Bonjour & Android NsdManager. Zero configuration.
When phone provides hotspot to Mac, mDNS is blocked by Android AP isolation. LocalMetro uses UDP gateway beaconing to :47655 to bridge.
End-to-end encrypted WebSocket tunnel when devices are on separate cellular connections.
{
"v": 1,
"id": "e4f8b1a2-3c4d-4e5f-a6b7-c8d9e0f1a2b3",
"type": "clipboard",
"sentAt": "2026-11-15T13:37:00Z",
"payload": {
"text": "https://github.com/0xdps/local-metro",
"format": "text/plain",
"sourceDevice": "Pixel-9-Pro"
}
}just protocol-check● 100% Type-SafeWire Framing Specification
Every transmission consists of a 4-byte big-endian unsigned integer indicating the length of the subsequent payload, followed immediately by UTF-8 encoded JSON.
// Header: 4 bytes BE length
uint32_be payload_length = htonl(json_bytes.len());
// Body: UTF-8 JSON up to 256 KB
write_all(&payload_length);
write_all(&json_bytes);
mDNS & Bonjour Discovery
On macOS, NWListener binds port 47655 and advertises service _localmetro._tcp. On Android, NsdManager queries for this service type.
// Service registration
Service: _localmetro._tcp.local
Port: 47655 (TCP)
TXT: deviceId=<uuid>, name=<hostname>
One-Time Cryptographic QR Pairing
When pairing for the first time, the Mac generates a cryptographically random token with a strict 2-minute expiration window. The QR code displays an URI:
The Android device connects directly to the IP and port, passes the one-time token in a pair-request envelope. Once validated, both devices persist the trusted device ID into secure local storage. Subsequent sessions connect automatically without user intervention.