Transport Modes Overview
Publisher and Subscriber support two transport mechanisms:- Local transport (iceoryx2): Zero-copy shared memory for same-process communication (< 1 μs latency)
- Network transport (Zenoh): Network-based messaging for cross-process and remote communication (1-10 ms latency)
Subscriber Transport Selection
Auto-Detection (Recommended)
- Check if local publisher exists (iceoryx2)
- If yes, use local transport (fast, zero-copy)
- If no, use network transport (Zenoh)
Auto-detection is the recommended approach for most use cases. It automatically chooses the fastest available transport.
Force Local Transport
- You’re certain a local publisher exists
- You want to ensure zero-copy performance
- You want to avoid network overhead
Force Network Transport
- You’re connecting to a remote publisher
- You want to test network communication
- You want to ensure network discovery works
Network transport is useful for:
- Cross-process communication
- Remote machines
- When you want to ensure network discovery works
Enabling Local Transport After Creation
If you create a network-only subscriber but later want to enable local transport:Publisher Network Control
Publishers always use local transport. Network transport is optional and can be controlled at runtime:Network publishing runs on a background thread. When enabled, messages are queued and sent asynchronously. The network thread uses latest-message semantics, so only the most recent message is sent if the network is slow.
Transport Modes Comparison
| Mode | When to Use | Latency | Serialization | Control |
|---|---|---|---|---|
| Auto-detect | Default choice | Local: < 1 μs Network: 1-10 ms | Local: None Network: Yes | Automatic |
| Force local | Same-machine only | < 1 μs | None | Manual |
| Force network | Remote or cross-process | 1-10 ms | Yes | Manual |
Comparison with TopicManager
TopicManager automatically handles transport selection:| Feature | Direct Publisher/Subscriber | TopicManager |
|---|---|---|
| Transport Selection | Manual (None, Some(true), Some(false)) | Automatic (auto-detects and switches) |
| Network Enable | Manual (enable_network() / disable_network()) | Automatic (enabled on discovery) |
| Local Enable | Manual (enable_local_subscriber()) | Automatic (enabled when local publisher appears) |
| Control | Fine-grained per pub/sub | Centralized automatic management |
TopicManager automatically:
- Selects the optimal transport (local when available, network otherwise)
- Enables network transport when remote subscribers are discovered
- Switches to local transport when local publishers become available
- Manages transport transitions seamlessly
When to Use Manual Control
Manual transport control is beneficial when:- Runtime network control: You need to enable/disable network publishing based on application state
- Testing: You want to force specific transport modes for testing
- Resource management: You want to disable network to save resources when no remote subscribers exist
- Custom discovery: You’re implementing your own discovery mechanism
- Performance tuning: You need fine-grained control over transport selection for performance optimization