VSTP (Vishu's Secure Transfer Protocol) is a binary, application-layer protocol designed for secure and efficient data transfer. It provides a clean abstraction over TCP and UDP transports with built-in security features.
VSTP frames have a fixed header structure followed by variable-length header and payload sections:
| Field | Size | Description |
|---|---|---|
| MAGIC | 2 bytes | Protocol identifier (0x56 0x54) |
| VER | 1 byte | Protocol version (0x01) |
| TYPE | 1 byte | Frame type (see Frame Types) |
| FLAGS | 1 byte | Bit flags (see Flags) |
| HDR_LEN | 2 bytes | Header section length (little-endian) |
| PAY_LEN | 4 bytes | Payload length (big-endian) |
| HEADERS | Variable | Header section (see Headers) |
| PAYLOAD | Variable | Payload data |
| CRC32 | 4 bytes | Checksum (optional) |
āāāāāāāāāāā¬āāāāāā¬āāāāāāā¬āāāāāāāā¬āāāāāāāāāā¬āāāāāāāāāā¬āāāāāāāāāā¬āāāāāāāāāā¬āāāāāāā
ā MAGIC ā VER ā TYPE ā FLAGS ā HDR_LEN ā PAY_LEN ā HEADERS ā PAYLOAD ā CRC32 ā
ā 2 bytes ā 1B ā 1B ā 1B ā 2B LE ā 4B BE ā var ā var ā 4B ā
āāāāāāāāāāā“āāāāāā“āāāāāāā“āāāāāāāā“āāāāāāāāāā“āāāāāāāāāā“āāāāāāāāāā“āāāāāāāāāā“āāāāāāāVSTP defines several frame types for different purposes:
| Type | Name | Direction | Description |
|---|---|---|---|
| 0x01 | HELLO | Client ā Server | Start of session |
| 0x02 | WELCOME | Server ā Client | Server acceptance |
| 0x03 | DATA | Both | Application data |
| 0x04 | PING | Both | Keepalive request |
| 0x05 | PONG | Both | Keepalive response |
| 0x06 | BYE | Both | Graceful close |
| 0x07 | ACK | Both | Acknowledgement |
| 0x08 | ERR | Both | Error frame |
VSTP uses bit flags to indicate frame properties:
| Bit | Flag | Description |
|---|---|---|
| 0x01 | REQ_ACK | Request acknowledgment |
| 0x02 | CRC | Include CRC32 checksum |
| 0x04 | FRAG | Fragmented frame |
| 0x08 | COMP | Compressed payload |
VSTP supports custom headers in a simple key-value format:
// Header format
struct Header {
key_len: u16, // Key length (little-endian)
key: [u8], // Key bytes
value_len: u16, // Value length (little-endian)
value: [u8], // Value bytes
}
// Example headers
"content-type" -> "application/json"
"session-id" -> "abc123"
"priority" -> "high"VSTP provides security through multiple mechanisms:
VSTP supports both TCP and UDP transports with different characteristics: