Skip to main content

Module same_host

Module same_host 

Source
Expand description

Same-host tracker for Wave 4 of the zero-copy roadmap (Spec docs/specs/zerodds-zero-copy-1.0.md §6 Wave 3).

§Purpose

Discovery detects via [GuidPrefix::is_same_host] (Wave 4a) whether a peer runs on the same machine. On a match, the DCPS runtime registers a (WriterGuid, ReaderGuid) pair in this tracker. The tracker keeps a deterministic SHM-segment identification so that both sides can derive the same transport path without an extra discovery round-trip.

§Path convention

An SHM segment for a writer-reader pair is identified by a deterministic 16-byte hash of the two GUIDs (see shm_segment_id_for_pair). Both sides arrive at the same id because the hash is symmetric / ordered.

The base_dir default is ${TMPDIR}/zerodds-shm (Linux) or ${TEMP}\zerodds-shm (Windows). The host_id_hex sub-folder prevents cross-host collisions on NFS mounts; should gethostname fail (fallback in participant::host_id_bytes), the path remains unique per process.

§Tracker state

Each pair has a SameHostState:

  • Pending — match detected, SHM setup not yet performed (e.g. because the Wave-4b.2 hook only maps the segment on the first send).
  • Bound { transport, role } — SHM transport is initialized; role says which side is Owner (writer producer) or Consumer (reader receiver) (see Role).
  • Failed { reason } — setup failed; the sender should fall back to the classic UDP path.

The concrete transport instantiation does not live here (that is the job of the Wave-4b.2 hook in the runtime module), so this module stays no_std + alloc portable and does not depend directly on transport-shm.

§Spec anchors

  • docs/specs/zerodds-zero-copy-1.0.md §6 Wave 3 (Iceoryx backend hot-path wiring; ZeroDDS reuses it for the SHM-bytes path).
  • RTPS 2.5 §9.4 — LOCATOR_KIND_SHM.

Structs§

SameHostTracker
Tracker for all (WriterGuid, ReaderGuid) same-host pairs of the local participant. Thread-safe via an inner mutex.

Enums§

Role
Role of the local endpoint in the SHM pair.
SameHostState
State of a same-host pair in the tracker.

Constants§

DEFAULT_BASE_DIR_NAME
Default base directory for SHM segments. Used only in std builds; in the no_std profile the tracker is state-only and no path lookup is needed.

Functions§

shm_segment_filename
Hex representation of a shm_segment_id_for_pair result. Returns 32 lowercase hex characters.
shm_segment_id_for_pair
Deterministic 16-byte segment identification for a writer-reader pair.