Updates to USTP-Secure USTP-Secure (USTPS), a UDP-based secure transport protocol, has entered beta with authenticated packet protection, optional congestion control, and support for multiple AEAD ciphers. The protocol uses X25519 key exchange, per-client session keys, and TOFU for server key verification, targeting streaming applications over unordered UDP delivery. USTPS means UDP Speedy Transmission Protocol Secure . USTP-Secure keeps USTP on UDP and adds authenticated packet protection. By default, USTPS uses AEAD for DATA . It also supports an optional negotiated cleartext + HMAC mode for DATA , where payload bytes are visible on the wire but tampering is detected and rejected. USTPS now supports an optional congestion controller called USTPS Congestion . It is still UDP-first and still keeps unordered delivery, but it can optionally slow down and ramp back up when the path starts showing congestion signals. Status: Beta USTPS is no longer just a proof of concept. It is currently in the Beta phase. USTPS can be used for many kinds of applications and transports. This repository, however, is focused specifically on streaming over USTPS . - Built with Codex using GPT-5.4 Low . - Verified without freezing at --loss 33 . - Test path: Brazil - Canada with about 140ms RTT. - Transport remains UDP no TCP tunnel - AEAD ciphers: chacha20 = CHACHA20 POLY1305 aes-256-gcm = AES 256 GCM aes-128-gcm = AES 128 GCM - Default AEAD cipher: chacha20 - Default DATA protection mode is AEAD. - Optional DATA protection mode is cleartext + per-packet HMAC. - In cleartext mode, payload bytes are not encrypted, but modifications are detected and invalid packets are discarded. - Transport control packets HELLO , ACK , RETRANSMIT REQUEST , CLOSE stay plaintext on purpose. - Control packets are serialized as ASCII transport records. ACK and NACK / RETRANSMIT REQUEST remain plaintext, but are authenticated with a per-session HMAC tag.- This prevents off-path forged ACK/NACK control packets from forcing ACK attacks or retransmission DoS after the secure session is established. DATA packets use a binary frame format named UPACK UPAK on the wire .- No static PSK is used. - Each client performs an X25519 key exchange when it joins. - Each client gets a separate AEAD session key. - Servers support multiple clients. - The server validates the client with a challenge round-trip on the source IP:port . - If --cipher is set on the server, the server uses that exact cipher. - If --cipher is omitted or set to auto , the server uses the cipher requested by the client. - Clients reject unexpected cipher negotiation. DATA protection mode is negotiated separately from cipher choice:- server: --cleartext auto|on|off - client: --cleartext on|off - server default: auto - client default: off - server: - With server auto , the server follows the client request. - With server on , the server forces cleartext + HMAC. - With server off , the server forces AEAD. - TOFU Trust On First Use is enabled on the client to detect unexpected server key changes after the first connection. - The server keeps a persistent X25519 host key in ~/.ustps host key by default so TOFU remains stable across reconnects and restarts. - A normal server restart does not change the host key. - Use --regen-key on the server only when you intentionally want to rotate that host key. ACK: , NACK: , HELLO: , and CLOSE: are the plaintext control record prefixes. USS1 means UDP Speedy Secure , version 1. USC1 means UDP Speedy Clear , version 1. UPAK is the binary UPACK DATA frame marker.- In USTPS, plaintext control is human-readable ASCII such as ACK: 10 , NACK: 42 , HELLO: ... , and CLOSE: . - In USTPS, UPAK identifies binary DATA packets after decryption. - In USTPS, USS1 is the outer secure AEAD envelope format. - In USTPS, USC1 is the outer cleartext+HMAC DATA envelope format. - So, on the wire you normally see: USS1... for AEAD-protected DATA USC1... for cleartext+HMAC DATA - readable control lines for transport control - USTPS is reliable over UDP, but it is unordered by design . - USTPS can run with optional USTPS Congestion , negotiated during the handshake. - Packets carry both a transport seq and an application-facing stream pos . seq is used for ACK, loss detection, retransmission, and RTT sampling. stream pos tells the application where the payload belongs in the logical byte stream.- In the current implementation, seq is a 32-bit counter that starts at 1 for each fresh session. - In the current implementation, stream pos is a 64-bit byte counter that starts at 0 for each fresh logical stream. - The receiver accepts out-of-order packets immediately instead of blocking delivery behind one missing packet. Example: - Physical arrival: 1 2 3 5 6 - Packet 4 is missing, so the receiver buffers the gap information and sends RETRANSMIT REQUEST for 4 . - Packets 5 and 6 are still accepted immediately. - When packet 4 arrives later, the application can reconstruct the logical order by using stream pos , not by trusting arrival order. - The client starts with a plaintext transport HELLO carrying its X25519 public key, requested cipher, requested congestion-control mode on or off , and requested DATA protection mode cleartext on|off . - The server does not send media immediately. It first sends a plaintext challenge containing: - a random retry token - a generated Base64 session id - the selected cipher - the negotiated congestion-control mode - the negotiated DATA protection mode - the server public key - The client must answer with that exact same token and session metadata. - Only after that token round-trip succeeds does the server create the session and begin sending DATA . - After validation, the session is bound to the source IP:port that completed the challenge. session id is still used as a session label, but it is not accepted from a different IP:port . - USTPS uses a plaintext retry-token step before any encrypted media session is accepted. - Flow: - client sends HELLO - server replies with USTPS-CHALLENGE1 carrying token , session id , selected cipher, negotiated congestion-control mode, negotiated DATA protection mode, and server public key - client echoes that token back in USTPS-CHALLENGE-REPLY1 - only then does the server create the session and send USTPS-SESSION1 - client sends - Purpose: - prove that the sender at that source IP:port can actually receive packets there - avoid sending encrypted media immediately to an unvalidated source address - bind the final session creation to the endpoint that completed the round-trip - prove that the sender at that source - The retry token is not the session key. - It is only a reachability proof and handshake gate before the real USTPS session is created. - It is also not used as a nonce, not used as an ACK/NACK MAC key by itself, and not reused as packet payload state. - Current UPACK DATA payload limit: 1200 bytes. UPACK fixed header: 20 bytes.- Outer USS1 secure envelope overhead in AEAD mode: 4 bytes magic 1 byte cipher id 12 bytes AEAD nonce 16 bytes AEAD tag - So the encrypted USTPS DATA datagram is about 1253 bytes before IP/UDP headers. - Outer USC1 cleartext envelope overhead in cleartext mode: 4 bytes magic 16 bytes HMAC tag - So the cleartext USTPS DATA datagram is about 1240 bytes before IP/UDP headers. - With IPv4 + UDP headers, that is about 1281 bytes on the wire. - With IPv6 + UDP headers, that is about 1301 bytes on the wire. - USTPS currently does not implement transport-level fragmentation. - USTPS currently does not implement PMTU discovery. - The implementation instead uses a fixed conservative payload ceiling. - If IP fragmentation still happens underneath and one fragment is lost, the whole UDP datagram is lost and USTPS recovers it with normal selective retransmission. - Duplicate packets inside the current session are ignored after their seq was already accepted. - Very old packets can age out of the receiver history window and then be ignored as stale. - Old ACK/NACK packets for data that has already been retired from the retransmission buffer are ignored. - A stale control packet does not recreate an already-finished packet in the sender. DATA encryption uses a fresh random 12 -byte AEAD nonce per encrypted packet.- The nonce is generated randomly, not derived from seq . - Nonce reuse with the same session key is forbidden. seq is for transport reliability. stream pos is for logical application ordering. nonce is only for AEAD packet protection.- Cleartext+HMAC mode does not use an AEAD nonce because it does not use AEAD encryption for DATA . USTPS Congestion is optional.- It does not change USTPS into an ordered transport and it does not add TCP-style HoL blocking. - It only changes how aggressively the sender injects packets into the network. - Negotiation model: - server: --congestion-control auto|on|off - client: --congestion-control on|off - server: - Default behavior: - server default is auto - client default is off - with server auto , the server follows what the client asked for - with server on , congestion control is forced on even if the client asked for off - with server off , congestion control is forced off even if the client asked for on - server default is - Runtime behavior: - starts at a normal send rate - gradually increases the effective send window and burst size while the path stays healthy - watches measured RTT , retransmission timeout events RTO , and explicit retransmit requests NACK - if RTT inflates, RTO starts happening, or loss/retransmit pressure rises, it backs off - once the path stabilizes again, it slowly ramps back up - The sender still uses selective retransmission for missing packets only. USTPS Congestion controls rate pressure, not reliability semantics. - Automatic network/path migration has been removed from this implementation. - If the client changes network and its source IP:port changes, the current session is expected to end and the client should reconnect cleanly. - The migration implementation was removed because it caused practical reliability and security problems: - repeated migration floods when NAT or mobile networks changed paths quickly - stale sessions that looked recovered but no longer delivered media - long silent periods followed by GAP-only behavior - ambiguity between a real roaming client and spoofed packets claiming an existing session id - complex recovery state that could reset stream ordering or retransmission state at the wrong time - The current model is intentionally simpler: prove reachability with a challenge on the current IP:port , bind the session to that endpoint, and reconnect if the endpoint changes. ACK is serialized like ACK: 10 MAC: