librecast/lcsync
2
3
Fork
You've already forked lcsync
1
Multicast File Syncing https://librecast.net/lcsync.html
  • C 92.1%
  • Shell 6.1%
  • Makefile 1.3%
  • M4 0.5%
Brett A C Sheffield c7997978b4 Change --batchmode option to --batch
The long option form of -b was --batchmode, but the documentation
incorrectly said it was --batch.
Change --batchmode option to --batch to match documentation.
Fixes: https://todo.sr.ht/~librecast/lcsync/48
Reported-by: Vagrant Cascadian <vagrant@debian.org>
Signed-off-by: Brett A C Sheffield <bacs@librecast.net>
2025年10月07日 07:53:27 +02:00
doc documentation: update man pages 2025年03月08日 11:34:54 +01:00
src Change --batchmode option to --batch 2025年10月07日 07:53:27 +02:00
test fixes to test 0031 2025年06月18日 09:47:46 +00:00
.gitignore split lcshare and lcsync programs 2023年09月22日 12:15:14 +02:00
CHANGELOG.md v0.3.2 release 2025年03月08日 13:02:38 +01:00
CODE_OF_CONDUCT.md licensing, code of conduct, contributing docs etc. 2022年05月16日 11:06:26 +02:00
config.guess autotools 2022年08月12日 14:59:26 +02:00
config.sub autotools 2022年08月12日 14:59:26 +02:00
configure v0.3.2 release 2025年03月08日 13:02:38 +01:00
configure.ac v0.3.2 release 2025年03月08日 13:02:38 +01:00
CONTRIBUTING.md licensing, code of conduct, contributing docs etc. 2022年05月16日 11:06:26 +02:00
COPYING more explicit license wording in COPYING 2022年05月24日 21:17:45 +02:00
install-sh autotools 2022年08月12日 14:59:26 +02:00
LICENSE.GPL-2.0-only licensing, code of conduct, contributing docs etc. 2022年05月16日 11:06:26 +02:00
LICENSE.GPL-3.0-only licensing, code of conduct, contributing docs etc. 2022年05月16日 11:06:26 +02:00
Makefile.in make testloop - repeating tests 2023年09月29日 09:57:59 +02:00
README.md README: 2^112 groups, not 2112 2025年03月26日 11:31:29 +01:00
TODO merging various APIs into librecast 2023年06月26日 16:18:00 +02:00

lcsync - Librecast Multicast Sync Tool

lcsync logo

Librecast file and data syncing tool.

https://librecast.net/lcsync.html

Compare data with merkle trees, sync via multicast.

Work in progress.

File Syncing

Coverity Scan Build Status

Packaging status

Data is compared by generating a merkle tree using BLAKE3 hashes.

For local file syncing we walk the trees and compare the hashes to find which data blocks are different.

To sync remote files, each file is split into blocks and a merkle tree is built by hashing the blocks using BLAKE3. On the sending/server side, this tree is sent on Librecast Channel (IPv6 multicast group) that is formed from the hash of the filename. The receiver/client joins this channel, and receives the tree. If the client already has some data to compare, it builds a merkle tree of the destination file and uses this to quickly compare which blocks differ. It builds a bitmap with this information, and then joins the Channel(s) for the block(s) required which are sent by the server.

Forward Error Correction (FEC) is enabled by default using RaptorQ (RFC 6330) from the Librecast LCRQ library.

Symmetric encryption is provided using the XSalsa20 stream cipher from libsodium with Poly1305 MAC authentication tags. A keyfile can be provided, or a key can be derived from a user-supplied password.

There is no unicast communication with the server. There are no requests sent, and the server can sit behind a firewall which is completely closed to inbound TCP and UDP traffic. Instead, the server listens on a raw socket for Multicast Listener Discovery (MLD) reports. It compares any MLD multicast group JOINs against the index it built on startup and finds matches for file (tree) and blocks. In this way, the server only sends data when at least one client is subscribed. If more clients want to download the data, the server need take no further action. Thus, the load on the server does not change at all, regardless of whether there is one client or a billion.

Bloom Filters and Timers

lcsync uses an experimental form of MLD triggering. Instead of using linked-lists for tracking multicast groups, as the Linux kernel does, we use something more scalable. There can potentially be 2112 multicast groups in IPv6, so beyond a certain point the O(n) search on a linked-list does not scale.

Early versions of lcsync used SIMD (CPU vector operations) to implement counted bloom filters, as well as we are calling a "bloom timer", which lets us track active multicast groups in O(1) constant time. This works, but has the drawback that even for 0 active groups, CPU usage is constant. The size of the bloom filters can be tuned depending on the expected number of simultaneous groups.

Since lcsync v0.1.0 the bloom timer has been replaced with a simple bloom filter which eliminates the need for heavy vector operations, and still provides constant time O(1) searches and updates.

Most of lcsync's functionality was merged into Librecast 0.7.0 with the new Librecast Sync API.

Building

Prerequisites:

  • liblibrecast - the Librecast IPv6 multicast library (>= 0.8)
  • libcrq - the Librecast RaptorQ library (>=0.1)
  • libsodium - a modern, easy-to-use software library for encryption

Installation:

NB: GNU Make is required. On *BSD install and use gmake. The bash shell is also required for make test.

./configure
make
make test (optional)
make install # requires root privileges

Note for Packagers

lcshare requires permissions to create raw sockets. On Linux, this requires setting CAP_NET_RAW on the lcshare binary. For other systems, setuid root may be appropriate.

Usage

lcshare is the server-side component which indexes files and listens for MLD multicast group joins and sends the file and directory block data.

lcsync is the client-side component which joins multicast groups to receive files and directories.

Serve a a single file: :lcshare [OPTION...] FILENAME

Serve all files below a directory: :lcshare [OPTION...] DIRECTORY

Sync remote file(s) with local: :lcsync [OPTION...] REMOTEFILENAME LOCALFILENAME

Sync two local files (Path required. Can be ./): :lcsync ./LOCALFILE1 ./LOCALFILE2

lcsync assumes source and destination are network addresses unless told otherwise. To refer to a local destination, you must specify the path. For files in the local directory, prefix them with `./` (a remote source can be forced with `--remote`)

Options

lcshare (server) Options:

--loopback :enable multicast loopback (sending host will receive sent data)

lcsync (client) Options:

-a, --archive :set archive options [-g -o -p -r -t]

-n, --dry-run :don’t copy any data

-g, --group :set group on destination

-o, --owner :set owner on destination

-p, --perms :set permissions on destination

--remote :source path is remote

-t, --times :set modification times on destination

General Options:

-b, --batch :Batch mode. No prompting. NB: if you do not specify a keyfile for encryption, encryption will be disabled.

--bwlimit INTEGER :set send rate limit (bps). An SI prefix of T, G, M or K may be added (eg. --bwlimit 10M)

--hex :print file hashes in hex

-i, --interface INTERFACE :set network interface to use (default: all)

--keyfile KEYFILE :Read symmetric key from keyfile, which must be the path to a file containing a 128 byte random key. This can be created with a command like: dd if=/dev/random of=keyfile count=1 bs=128

--loglevel INTEGER :set loglevel

-r, --recursive :recurse into directories

-q, --quiet :shhh - we’re hunting wabbits

-v, --verbose :increase verbosity

-V, --version :display version and exit

Testing

sudo make net-setup (sudo make net-teardown when finished)

sudo ip netns exec vnet0 sudo -u `id -un` /bin/bash

Now we can run make test and sudo make cap in our test namespace.

License

GPLv2 or (at your option) GPLv3


This project was funded through the NGI0 Discovery and NGI Assure Funds, established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreements 825322 and 957073. *Applications are still open, you can apply today*

Logo NLnet: abstract logo of four people seen from above Logo NGI Zero: letterlogo shaped like a tag Logo NGI Assure: letterlogo shaped like a tag