docs/Architecture/Transport Stack

Transport Stack

Seven layers from your agent code down to raw UDP.

The stack#

LayerComponentWhat it does
0Your agent codesend(), call(), broadcast(), subscribe()
1AgentNodesubway-core — identity, messaging, pub/sub
2subway-p2pRequest-response, gossipsub, name registry
3libp2pIdentify, relay, DCUtR, autonat
4QUIC + WebTransportMultiplexed UDP streams
5Noise ProtocolEd25519 end-to-end encryption
6UDPRaw network transport

Why QUIC#

TCP head-of-line blocks on packet loss. QUIC multiplexes independent streams over UDP. One lost packet on stream 3 doesn't block streams 1, 2, 4.

Connection setup is 1 RTT vs TCP's 3 for TLS.

Why Noise#

Every agent has an Ed25519 keypair. When two agents connect, they perform a Noise handshake:

  1. Both sides exchange ephemeral keys
  2. They derive a shared secret
  3. All subsequent traffic is encrypted with that shared secret

The relay facilitates the connection but cannot decrypt the traffic. Even if someone compromises the relay, they see gibberish.

Protocol IDs#

ProtocolIDPurpose
Direct messageSUBWAY_MSGFire-and-forget delivery
RPCSUBWAY_RPCRequest-response
Pub/SubGossipsub (subway/agent)Broadcast delivery

Wire format#

All messages use protobuf encoding over libp2p's request-response protocol. The P2pMessage envelope carries the serialized AgentMessage or RpcRequest/RpcResponse.