Skip to main content
The transport section configures the underlying protocol used for communication between client and server. Currently, paqet only supports the KCP protocol.

Transport Protocol

transport.protocol
string
default:"kcp"
Transport protocol to use. Currently only "kcp" is supported.

Connection Settings

transport.conn
integer
default:"1"
Number of parallel connections (1-256). Multiple connections can improve throughput on high-latency networks.Client restriction: If the client port is explicitly set (non-zero) in network.ipv4.addr, only 1 connection is allowed.
transport.tcpbuf
integer
default:"8192"
TCP buffer size in bytes
transport.udpbuf
integer
default:"4096"
UDP buffer size in bytes

KCP Protocol Configuration

KCP is a fast and reliable ARQ protocol that can achieve higher throughput and lower latency than TCP, especially on lossy or high-latency networks.

KCP Modes

transport.kcp.mode
string
default:"fast"
Predefined KCP mode preset. Choose based on your network conditions and performance requirements:
  • normal: Conservative TCP-like behavior with congestion control
  • fast: Balanced mode for general use (recommended)
  • fast2: More aggressive mode for better performance
  • fast3: Most aggressive mode for maximum speed
  • manual: Use custom parameters defined below
Each mode configures the underlying KCP parameters differently:
ModenodelayintervalresendnocongestionUse Case
normal04020Stable networks, TCP-like behavior
fast13021General use, balanced performance
fast212021Low-latency networks
fast311021Maximum performance, high bandwidth
manualcustomcustomcustomcustomFull control over all parameters

Manual Mode Parameters

When mode is set to "manual", you can configure individual KCP parameters:
transport.kcp.nodelay
integer
Enable or disable nodelay mode:
  • 0: Disable (TCP-like conservative behavior)
  • 1: Enable (lower latency and aggressive retransmission)
transport.kcp.interval
integer
Internal update timer interval in milliseconds (10-5000ms).Lower values increase responsiveness but raise CPU usage. Typical values:
  • 10ms: Maximum responsiveness, higher CPU
  • 20ms: Good balance
  • 40ms: Conservative, lower CPU
transport.kcp.resend
integer
Fast retransmit trigger (0-2):
  • 0: Disabled (wait for timeout only)
  • 1: Most aggressive (retransmit after 1 ACK skip)
  • 2: Aggressive (retransmit after 2 ACK skips)
transport.kcp.nocongestion
integer
Congestion control setting:
  • 0: Enable TCP-like fair congestion control (slow start, congestion avoidance)
  • 1: Disable congestion control for maximum speed
transport.kcp.wdelay
boolean
Write batching behavior:
  • false: Flush immediately (low latency, recommended for real-time applications)
  • true: Batch writes until next update interval (higher throughput)
transport.kcp.acknodelay
boolean
ACK sending behavior:
  • true: Send ACKs immediately when packets are received (lower latency)
  • false: Batch ACKs (more bandwidth efficient)

MTU and Window Settings

transport.kcp.mtu
integer
default:"1350"
Maximum transmission unit in bytes (50-1500).
Default is 1350 to avoid fragmentation. Only increase if you’re certain your network path supports larger MTUs.
transport.kcp.rcvwnd
integer
default:"512 (client) / 1024 (server)"
Receive window size (1-32768).Controls how many packets can be in flight. Larger windows improve throughput on high-latency networks.
transport.kcp.sndwnd
integer
default:"512 (client) / 1024 (server)"
Send window size (1-32768).Controls how many packets can be sent before waiting for ACKs. Larger windows improve throughput.

Buffer Settings

transport.kcp.smuxbuf
integer
default:"4194304"
SMUX multiplexing buffer size in bytes (minimum 1024). Default is 4MB.
transport.kcp.streambuf
integer
default:"2097152"
Stream buffer size in bytes (minimum 1024). Default is 2MB.

Keepalive Settings

transport.kcp.smuxkalive
integer
default:"2"
SMUX keepalive interval in seconds. How often to send keepalive probes.
transport.kcp.smuxktimeout
integer
default:"8"
SMUX keepalive timeout in seconds. Connection is considered dead after this timeout.

Encryption

Encryption is configured within the KCP section. See Encryption Configuration for details.
transport.kcp.block
string
default:"aes"
Encryption algorithm to use. See Encryption Configuration for available options.
transport.kcp.key
string
required
Encryption key. Must match between client and server. Generate using paqet secret.

Forward Error Correction (FEC)

FEC is currently disabled in paqet. The parameters below are reserved for future use.
transport.kcp.dshard
integer
Data shards for FEC (currently disabled)
transport.kcp.pshard
integer
Parity shards for FEC (currently disabled)

Configuration Examples

transport:
  protocol: "kcp"
  conn: 1
  kcp:
    mode: "fast"
    key: "your-secret-key-here"

Manual Mode for Low-Latency

transport:
  protocol: "kcp"
  conn: 1
  kcp:
    mode: "manual"
    nodelay: 1
    interval: 10
    resend: 2
    nocongestion: 1
    wdelay: false
    acknodelay: true
    mtu: 1350
    rcvwnd: 512
    sndwnd: 512
    key: "your-secret-key-here"

Multiple Connections for High-Latency Networks

transport:
  protocol: "kcp"
  conn: 4  # Use 4 parallel connections
  kcp:
    mode: "fast2"
    rcvwnd: 1024
    sndwnd: 1024
    key: "your-secret-key-here"

Performance Tuning

  • Use mode: "fast2" or mode: "fast3"
  • Increase window sizes: rcvwnd: 1024, sndwnd: 1024
  • Consider multiple connections: conn: 2 or conn: 4
  • Increase buffers: smuxbuf: 8388608, streambuf: 4194304
  • Use mode: "fast" (default)
  • Keep default window sizes
  • Single connection is usually sufficient: conn: 1
  • Lower interval for responsiveness: interval: 10 (manual mode)
  • Use mode: "fast2" or mode: "fast3"
  • Increase retransmission: resend: 2 (manual mode)
  • Enable aggressive ACKs: acknodelay: true (manual mode)
  • Consider FEC when it becomes available
  • Use mode: "normal" or mode: "fast"
  • Increase interval: interval: 40 (manual mode)
  • Reduce connections: conn: 1
  • Enable write batching: wdelay: true (manual mode)

See Also

Build docs developers (and LLMs) love