So-called synchronization protocol (SP) is used in current TCP daemon’s implementation. It is used for synchronizing spool directory contents between two nodes.
It is aimed to be very simple and effective. It uses reliable transport like TCP connections. It must be effective both on single-duplex and full-duplex links: for example satellites have very high throughput but high-delay links, so acknowledging of each received packet, like XMODEM does, causes unacceptable performance degradation.
SP works on top of
Noise_IK_25519_ChaChaPoly_BLAKE2b
protocol. Each Noise packet
are sent inside XDR envelope:
+-----------------+ | MAGIC | PAYLOAD | +-----------------+
XDR type | Value | |
---|---|---|
Magic number | 8-byte, fixed length opaque data | NNCPS0x10x00x00 |
Payload | variable length opaque data | Noise packet itself |
Peers static keys are specified as noisepub
configuration entry.
Payload inside Noise packets has maximum size of 65 KiB - 256 B =
65280 B
. It is sent immediately in the first message by each side. The
very first payload (that is carried inside handshake messages) is always
padded to the maximum size with HALT
packets (read below), for
hiding actual number of INFO
packets (number of files available
for transmission).
Each SP payload is a concatenation of SP packets. Each packet has XDR-encoded header and then corresponding XDR-encoded body. Header is just an unsigned integer telling what body structure follows.
HALT
Stop file transmission, empty sending queue on the remote side.
Actually HALT
packet does not have any body, only the header
with the type. It is also used in the first payload for padding to
the maximum size.
INFO
Information about the file we have for transmission.
+--------------------+ | NICE | SIZE | HASH | +--------------------+
XDR type | Value | |
---|---|---|
Niceness | unsigned integer | 1-255, file niceness level |
Size | unsigned hyper integer | File size |
Hash | 32-byte, fixed length opaque data | Unique file identifier, its checksum |
FREQ
File transmission request. Ask remote side to queue the file for transmission.
+---------------+ | HASH | OFFSET | +---------------+
XDR type | Value | |
---|---|---|
Hash | 32-byte, fixed length opaque data | Unique file identifier, its checksum |
Offset | unsigned hyper integer | Offset from which remote side must transmit the file |
FILE
Chunk of file.
+-------------------------+ | HASH | OFFSET | PAYLOAD | +-------------------------+
XDR type | Value | |
---|---|---|
Hash | 32-byte, fixed length opaque data | Unique file identifier, its checksum |
Offset | unsigned hyper integer | Offset from which transmission goes |
Payload | variable length opaque data | Chunk of file itself |
DONE
Signal remote side that we have successfully downloaded the file.
+------+ | HASH | +------+
XDR type | Value | |
---|---|---|
Hash | 32-byte, fixed length opaque data | Unique file identifier, its checksum |