JTP is a high-performance, secure image transfer protocol designed for fast delivery of Jason images (or any images) over TCP with optional TLS encryption.
- Rust 1.72+
- Cargo
- On Windows,
CMakemay be required to build TLS dependencies.
git clone https://github.com/punctuations/jtp.git
cd jtp
cargo build --release- Server binary:
target/release/server.exe(Windows) orserver(Linux/macOS) - Client binary:
target/release/client.exe(Windows) orclient(Linux/macOS)
- Start the server:
cargo run --bin server- Listens on
127.0.0.1:8443by default. - Serves images based on
ImageIDrequests.
- Run the client:
cargo run --bin client- Downloads requested images and saves them locally using the filename provided by the LIST catalog, e.g.:
jason1.jpg
jason2.png
- If the catalog does not provide a usable filename, it falls back to:
output_<image_id>.jpg
Purpose: Secure, fast transfer of images using a simple, hash-based request/response protocol.
- TCP (optionally TLS-encrypted).
- Server listens on a configurable port (default
127.0.0.1:8443). - Client initiates connection and negotiates TLS if enabled.
-
Length: 8 bytes (64-bit)
-
Generation:
- Compute
xxHash64of the image bytes (seed = 0). - Use the resulting 64-bit value as the
ImageID.
- Compute
Example (pseudo-code):
image_bytes = read_image("jason.jpg")
image_id_u64 = xxHash64(image_bytes, seed=0)
image_id_bytes = to_be_bytes(image_id_u64) // 8 bytes
- Client uses
ImageIDto request images. - Server uses
ImageIDto identify and respond with the correct image.
JTP supports three request types.
| Field | Size (bytes) | Description |
|---|---|---|
ReqType |
1 | 1 = LIST |
| Field | Size (bytes) | Description |
|---|---|---|
ReqType |
1 | 0 = GET_BY_ID |
Count |
1 | Number of images requested (N) |
ImageID |
8 × N | Hash-based IDs of requested images |
Client sends the IDs it already has; server returns only the missing images.
| Field | Size (bytes) | Description |
|---|---|---|
ReqType |
1 | 2 = BATCH |
HaveCount |
1–5 | Varint-encoded count of ImageIDs (N) |
ImageID |
8 × N | Hash-based IDs the client already has |
| Field | Size (bytes) | Description |
|---|---|---|
Header |
4 | "JTPL" |
Count |
2 | Number of entries (N) |
Entries |
Variable | Repeated N times |
Each entry:
| Field | Size (bytes) | Description |
|---|---|---|
ImageID |
8 | Image ID (u64, big-endian) |
Flags |
1 | bits 0..2=file type, bit3=compressed, bit4=encrypted |
NameLen |
2 | Length of filename in bytes |
Filename |
NameLen |
UTF-8 filename (basename) |
Size |
1–5 | Varint-encoded size of image data (u32) |
| Field | Size (bytes) | Description |
|---|---|---|
Flags |
1 | bits 0..2=file type, bit3=compressed, bit4=encrypted |
Length |
1–5 | Varint-encoded length of image data (u32) |
ImageID |
8 | Echoes requested ImageID (u64, big-endian) |
Data |
Variable | Raw image bytes |
| Field | Size (bytes) | Description |
|---|---|---|
Header |
4 | "JTPB" |
MissingCount |
1–5 | Varint-encoded count of images (M) |
Images |
Variable | Repeated M times (image response) |
Fixed-width integers are big-endian; sizes/lengths are unsigned LEB128 varints. Hex dumps below are spaced by byte.
Request: ReqType = 1 (LIST)
01
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 01 |
ReqType = 1 (LIST) |
Example: Count = 1, one entry for jason1.jpg with Size = 0x00001234.
4A 54 50 4C 00 01
AA BB CC DD EE FF 00 11 01 00 09
6A 61 73 6F 6E 31 2E 6A 70 67 B4 24
| Offset | Bytes | Meaning |
|---|---|---|
| 0..3 | 4A 54 50 4C |
ASCII "JTPL" (LIST response header) |
| 4..5 | 00 01 |
Count = 1 (u16) |
| 6..13 | AA .. 11 |
ImageID (8 bytes) |
| 14 | 01 |
Flags (file type=1 jpg) |
| 15..16 | 00 09 |
NameLen = 9 (u16) |
| 17..25 | 6A 61 73 6F 6E 31 2E 6A 70 67 |
UTF-8 "jason1.jpg" |
| 26..27 | B4 24 |
Size = 0x00001234 (varint u32) |
Example: request one image by ID.
00 01
AA BB CC DD EE FF 00 11
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 00 |
ReqType = 0 (GET_BY_ID) |
| 1 | 01 |
Count = 1 (u8) |
| 2..9 | AA .. 11 |
ImageID (8 bytes) |
Example: jason1.jpg, Length = 4, and Data = DE AD BE EF.
01 04
AA BB CC DD EE FF 00 11
DE AD BE EF
| Offset | Bytes | Meaning |
|---|---|---|
| 0 | 01 |
Flags (file type=1 jpg) |
| 1 | 04 |
Length = 4 (varint u32) |
| 2..9 | AA .. 11 |
ImageID (8 bytes) |
| 10..13 | DE AD BE EF |
Data bytes |
- TLS ensures confidentiality and integrity.
ImageIDprevents collisions and simplifies deduplication.- Optional future enhancements: authentication, metadata, and compression.
- Add new file types by extending the
Flagsbits 0..2 mapping. - Include metadata (dimensions, compression/encryption parameters) in the header.
- Support streaming of very large images in chunks.
Client Server
| |
| -------- LIST request --------> |
| <-------- catalog (JTPL) ------ |
| |
| ---- GET_BY_ID request (IDs) --> |
| |
|<--- Flags+Len+ID+Data (per image) --|
| (repeated per image) |
GNU v3.0