mcrx-core
mcrx-core is a runtime-agnostic and portable IPv4 multicast receiver library for ASM
((*, G)) and SSM ((S, G)).
It is built for applications and integrations that want a small multicast receive core with explicit lifecycle and socket ownership control.
Highlights
- IPv4 ASM and SSM receive support
- Non-blocking receive API
- Explicit subscription lifecycle:
add,join,leave,remove - Multiple concurrent subscriptions with fair receive across them
- Caller-provided socket support
- Event-loop friendly socket borrowing and extraction APIs
- Optional Tokio adapter via the
tokiofeature - Optional receive metadata on platforms that expose it
- Optional metrics via the
metricsfeature
Install
With the optional Tokio adapter:
With optional metrics:
Quick Start
use ;
use Ipv4Addr;
let mut ctx = new;
let config = asm;
let id = ctx.add_subscription ?;
ctx.join_subscription ?;
if let Some = ctx.try_recv_any ?
Existing Sockets
Use add_subscription_with_socket() when you need to create or bind the socket
yourself:
use ;
use ;
use ;
let mut ctx = new;
let config = asm;
let socket = new ?;
socket.set_reuse_address ?;
socket.bind ?;
let id = ctx.add_subscription_with_socket ?;
ctx.join_subscription ?;
Event Loop Integration
Borrow the live socket from a subscription:
let subscription = ctx.get_subscription.unwrap;
let socket = subscription.socket;
let raw = subscription.as_raw_fd;
Or extract the subscription and move it into another loop or runtime:
let subscription = ctx.take_subscription.unwrap;
let parts = subscription.into_parts;
let socket = parts.socket;
Tokio Integration
With the tokio feature enabled, you can wrap an extracted subscription and
await packets asynchronously:
use TokioSubscription;
let subscription = ctx.take_subscription.unwrap;
let subscription = new ?;
let packet = subscription.recv.await?;
Run the Tokio example with:
Optional Receive Metadata
If you need more delivery context than source, group, port, and payload, use the metadata-aware receive APIs:
let subscription = ctx.get_subscription.unwrap;
if let Some = subscription.try_recv_with_metadata ?
Demo Binaries
Basic receiver:
Sender:
Tokio receiver:
Metadata inspection receiver:
Documentation
Platform Support
| OS | ASM | SSM | Notes |
|---|---|---|---|
| macOS | ✅ | ✅ | Verified |
| Linux | ✅ | ✅ | Verified |
| Windows | ✅ | ✅ | Build-checked (x86_64-pc-windows-msvc) |
Compatibility
ASM cross-platform compatibility:
| Sender / Receiver | macOS | Windows | Linux | Android | iOS |
|---|---|---|---|---|---|
| macOS | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Windows | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Linux | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Android | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| iOS | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
SSM cross-platform compatibility:
| Sender / Receiver | macOS | Windows | Linux | Android | iOS |
|---|---|---|---|---|---|
| macOS | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Windows | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Linux | ✅ | ✅ | ✅ | ⏳ | ⏳ |
| Android | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| iOS | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
Notes
- macOS may temporarily emit IGMPv2 reports in some SSM setups
- that can break SSM behavior on the network until the host state recovers
License
BSD 2-Clause