Educational Guide

How KSP Works

Kush Secure Protocol is a layered protocol built on TCP. Follow the sequence below to understand how bytes are serialized, encrypted, multiplexed, and transmitted across the network.

KSP builds directly on TCP rather than implementing UDP reliability from scratch. By listening on the default port 9876/tcp, the server accepts incoming connections to begin the session lifecycle.

Protocol Sequence / Topology Diagram
Client Server │ │ │─── TCP SYN ──────────────────────────────→│ (Port 9876) │←── TCP SYN-ACK ───────────────────────────│ │─── TCP ACK ──────────────────────────────→│ │ │ ▼ ══════════ TRANSPORT ESTABLISHED ════════ ▼
Rust Implementation Sketch
src/protocol/tcp.rs
// Accept standard TCP stream
let listener = TcpListener::bind("0.0.0.0:9876").await?;
while let Ok((socket, addr)) = listener.accept().await {
    // Pass TCP stream into KSP engine
    tokio::spawn(async move {
        let mut session = KspServer::accept(socket, config).await;
    });
}

Deep Dive: Using TCP guarantees ordered, error-free packet delivery, which simplifies KSP's framing design. KSP adds its own security, multiplexing, and session recovery layers on top of this reliable transport.

Read RFC Chapter