MEHS / Knowledge base

MEHS configuration contract

Status: This document describes design guidance and proposed tuning, not a configuration schema. Some examples or recommendations below may describe behavior that is not implemented and are not accepted JSON keys. The implemented client and server schemas, strict unknown-field behavior, defaults, and evolution rules are defined only in the configuration reference.

1. Configuration lifecycle

2. Connection pools

connection_count is per carrier:

If the public configuration retains a single connection_count field for compatibility, define it as a per-carrier limit and document this clearly; the preferred schema uses separate tcp_connection_count and udp_connection_count fields to avoid ambiguity.

FieldDefaultMeaning
modeautoSelect among server-allowed transports
tcp_connection_count1Concurrent TCP-carried candidate/data connections
udp_connection_count1Concurrent QUIC-carried candidate/data connections
connect_timeout_seconds15Candidate connection setup timeout
server_unreachable_seconds15If all allowed paths cannot reach the server for this duration, stop attempts and report terminal failure
health_check_seconds30Trigger general reachability and authenticated MEHS path-health checks
keepalive_seconds15Idle path keepalive interval; tune per platform/server policy
migration_drain_timeout_seconds60Maximum old-path drain time; unacknowledged data must be retransmitted, not discarded
migration_cooldown_seconds10Avoid repeated switches unless the active path fails
selection_improvement_percent15Minimum sustained improvement to switch from a healthy path
selection_windows_required2Number of consecutive windows that must confirm improvement
rtt_probe_samples5Minimum RTT samples per candidate
throughput_probe_samples3Minimum bounded throughput samples per candidate
session_negotiation_ttl_seconds120Validity of temporary negotiation session ID
transport_cache_ttl_seconds86400Transport-selection cache lifetime
max_frame_payload_bytes65536Initial maximum MEHS frame payload
max_reassembly_bytes_per_flow1048576Initial reassembly limit per flow
max_unacked_bytes_per_direction8388608Initial retransmission-buffer limit per direction
tls_versionTLS 1.3No downgrade to older TLS versions
is_hot_change_availabletrueEnables live TCP↔QUIC migration in auto mode

All numeric values are initial engineering defaults. Server policy can lower resource/time limits; it must not raise client hard safety ceilings without an explicit protocol version/capability agreement.

These are starting points to benchmark, not guaranteed universal optima.

ProfileModeTCP countUDP/QUIC countHealth checkKeepaliveDrain
Balancedauto1130 s15 s60 s
Latency-sensitiveauto1215–20 s10 s20–30 s
Bandwidth-focusedauto2230 s15 s60 s
TCP-onlytcp_tls1030 s15 sn/a
QUIC-onlyQUIC0120–30 s15 sn/a

The latency-sensitive profile uses more than one UDP/QUIC candidate to compare paths only if the server/network can provide meaningfully distinct routes or connection conditions. Multiple connections to the same endpoint on the same route do not necessarily provide path diversity.

5. Selection and cache

The current selector's version-1 score uses integer arithmetic: 50% packet loss (ppm, capped at 100%), 30% median RTT (capped at 1 s), 15% median absolute deviation of RTT (capped at 500 ms), and 5% throughput (capped at 100 MB/s, higher is better). It requires at least five RTT samples and three throughput samples, rejects unauthenticated/unpermitted candidates, uses a 15% sustained improvement across two windows to leave a healthy path, and applies a 10-second cooldown. An active-path failure bypasses hysteresis/cooldown. The client consumes these measurements: it probes each carrier with authenticated Probe frames (5 RTT probes and 3 throughput probes per window), ranks them with the score above, and applies the improvement/cooldown rules. The CLI therefore supports auto: the choice is cached per configuration for transport_cache_ttl_seconds, a standby link is kept on the other carrier, and migration is make-before-break.

6. Server policy resolution

Server policy may allow, deny, cap, or pin:

For implemented mode and carrier-count negotiation, the server response contains the compatibility parameter plus path, requested value, effective value, and machine-readable reason_code. The client applies a pinned mode, verifies the effective pool before finalization, checks the finalized mode, and exposes corrections through its client API. Other settings are applied locally by the client.

7. Unsupported profiles

xhttp, trusttunnel, and notmehs carry MEHS frames in HTTP-shaped streams and are not interoperable with third-party servers. Unknown names fail closed; there is no profile fallback.

9. Client mode: proxy or TUN

client_mode selects how applications reach MEHS:

Control and data server addresses are automatically excluded from the tunnel. TUN requires root/administrator (Windows also needs wintun.dll beside the executable). The server must have IPv6 egress for IPv6 destinations to work; connections to private addresses are refused by the server. CLI flags (--mode, --tun-*) override the file.

8. Credential and secret handling