Skip to main content

TCP Transport

Reliable, connection-oriented transport protocol implementation.

TCP is the preferred transport when reliability, ordering, and flow control are required. MapsMessaging uses TCP for stateful, long-lived client connections and high-integrity data exchange.


Features

  • Connection-oriented transport
  • Reliable, ordered delivery
  • Flow control and congestion handling
  • Configurable socket buffers
  • Fragmentation detection and mitigation
  • Proxy Protocol support (optional)

When to Use TCP

TCP is recommended when:

  • Message delivery must be reliable
  • Ordering matters
  • Clients maintain long-lived sessions
  • Backpressure handling is required
  • Security is enforced at the transport or protocol layer

If ultra-low latency or fire-and-forget semantics are required, consider UDP instead.


Basic Configuration

transport:
tcp:
type: tcp
port: 1883
backlog: 100

TCP-specific Configuration

transport:
tcp:
type: tcp
port: 1883

receiveBufferSize: 128000
sendBufferSize: 128000
timeout: 60000
backlog: 100

soLingerDelaySec: 10

readDelayOnFragmentation: 100
fragmentationLimit: 5
enableReadDelayOnFragmentation: true

Fields

FieldDescription
receiveBufferSizeSocket receive buffer size in bytes
sendBufferSizeSocket send buffer size in bytes
timeoutConnection timeout in milliseconds
backlogMaximum queued incoming connections
soLingerDelaySecSO_LINGER delay in seconds (0 disables linger)
readDelayOnFragmentationDelay applied when packet fragmentation is detected (ms)
fragmentationLimitMaximum fragmentation events before backoff logic is applied
enableReadDelayOnFragmentationEnable read delay on fragmentation detection

Fragmentation Handling

TCP fragmentation can occur when clients send partial frames or deliberately fragment data. MapsMessaging detects excessive fragmentation and applies adaptive backoff.

Behaviour

  • Fragmentation is tracked per connection
  • Read delays are introduced once the fragmentation limit is exceeded
  • Protects the server against slow-loris style attacks
  • Backoff logic is configurable
enableReadDelayOnFragmentation: true
fragmentationLimit: 5
readDelayOnFragmentation: 100

Common Endpoint Fields

TCP endpoints inherit common settings from EndPointConfigDTO.

transport:
tcp:
type: tcp
port: 1883

discoverable: false
selectorThreadCount: 2
serverReadBufferSize: 10240
serverWriteBufferSize: 10240

proxyProtocolMode: DISABLED
allowedProxyHosts: ""
connectionTimeout: 5000

Fields

FieldDescription
discoverableWhether the endpoint is discoverable
selectorThreadCountNumber of selector threads
serverReadBufferSizeServer read buffer size in bytes
serverWriteBufferSizeServer write buffer size in bytes
proxyProtocolModeProxy Protocol support mode (DISABLED, ENABLED, REQUIRED)
allowedProxyHostsAllowed proxy source addresses (hosts, IPs, CIDR)
connectionTimeoutTime to wait for a client to establish the connection (ms)

Security Notes

  • TCP provides reliable delivery but not encryption
  • Use TLS (ssl endpoint) if encryption is required
  • Fragmentation controls mitigate resource exhaustion attacks
  • Proxy Protocol should only be enabled when required and restricted by source

Operational Notes

  • Larger buffer sizes improve throughput at the cost of memory
  • Smaller buffers reduce memory footprint but may limit throughput
  • Backlog tuning is important for bursty connection patterns
  • Fragmentation detection protects server resources under attack

When NOT to Use TCP

Avoid TCP when:

  • Messages are small and infrequent
  • Latency is more important than reliability
  • Multicast or broadcast semantics are required

Choose the transport that matches the workload.