dcubroker
Watches the Pilatus DCU ramdisk and forwards CBF frames over TCP to one or more Pylatus instances. Sits in the middle of the Pilatus data pipeline:
Dectris camserver -> ramdisk (.cbf files) -> dcubroker -> [Pylatus](https://git.3lp.cx/dyadkin/pylatus) (PPU)
How it works
inotifywatches the directory forCLOSE_WRITEandMOVED_TOevents -- the file is always complete when it's picked up.- Each
.cbfis streamed straight from disk to the socket withtokio::io::copy-- no intermediate buffer, no double-allocation. - With multiple
-ppeers, sends run in parallel; the file is deleted from the ramdisk once the fan-out finishes (successes and timeouts alike).
Wire format
Each frame is sent as:
| Field | Type | Value |
|---|---|---|
| magic | u32 LE | 0xdeadbeef |
| size | u32 LE | body length in bytes |
| body | size bytes |
raw .cbf file contents |
One TCP connection per frame per peer. Pylatus is the reference receiver.
Build
cargo build --release
The binary lands at target/release/dcubroker.
Usage
dcubroker -p pylatus.host /mnt/ramdisk
Fan out to several PPUs and tighten the per-peer timeout:
dcubroker -p pylatus1 -p pylatus2:9000 -t 5 /mnt/ramdisk
Flags
| Flag | Description |
|---|---|
<DIRECTORY> |
Ramdisk path to watch (positional, required) |
-p, --ppu <PPU-HOST> |
Pylatus host; default port 7678. Repeat for fan-out. |
-t, --timeout <SEC> |
Per-PPU send timeout (default 2) |
--dont-clean |
Skip wiping the ramdisk on startup |
-d, --daemon |
Fork into background |
-o, --out <LOGFILE> |
stdout log file (requires -d) |
-e, --err <LOGFILE> |
stderr log file (requires -d) |
-i, --pid <PIDFILE> |
pidfile path (requires -d) |
-u, --user <USER> |
Drop to user (requires -d) |
-g, --group <GROUP> |
Drop to group (requires -d) |
-w, --workdir <DIR> |
Working directory (requires -d) |
-m, --dated |
Timestamp log lines (for openrc) |
-v, -vv, -vvv |
Verbosity: error / info / debug (default: off) |
A note on --dont-clean
By default, dcubroker wipes the watched directory at startup. Dectris
camserver tends to leave stale files (mainly *.log) behind between runs, and a clean
ramdisk is what experiments expect. Pass --dont-clean if you have a
reason to preserve whatever's there.
Why not UDP / multicast
Frames are 2-6 MB -- well above MTU, so a UDP path would need app-layer sequencing, ACKs, retransmits and reassembly. That's TCP, badly reimplemented. Multicast would save sender uplink at the cost of a reliable-multicast layer and a Pylatus rewrite; on 10 Gb LAN with 2-3 receivers the savings don't justify the complexity. TCP fan-out it is.
License
GPL-3.0+