Configure NI-XNET to Replay CAN Frames with Precise Transmit Timing in LabVIEW

Updated Oct 16, 2025

Environment

Software

  • LabVIEW

Driver

  • NI-XNET

This article explains how to configure an NI-XNET Output Stream Session in LabVIEW to replay CAN frames at specific timing intervals. This approach allows you to achieve precise transmit timing for CAN messages, which is critical for simulation, testing, and replay scenarios.

1. Create a Frame Out Stream Session

  • Use XNET Create Session and select Frame Out Stream mode for both sessions.
  • Configure the session for the correct CAN interface and database if needed.

2. Set the Replay Type

  • Set the ReplayExclusive or ReplayInclusive property via the XNET Session Property Node.
  • This ensures frames are transmitted according to their timestamps.

3. Synchronize Interface Time

  • Call XNET Synchronize with Adjust Local Time in the same XNET Session Property Node before writing frames.
  • This aligns the NI-XNET interface clock with the system clock for accurate timing.

4. Connect Terminals for Triggering

  • Use XNET Connect Terminals to link Start Trigger and Sync Trigger terminals.
  • This setup allows hardware-level synchronization for frame transmission.

5. Prepare and Write Frames

  • Build an array of frames with timestamps, CAN IDs, and payloads.
  • Use XNET Write (Frame Out Stream) to transmit frames based on their timing.

6. Use XNET Wait (Trasmit Complete).vi 

  • This will ensure the data is transmitted correctly.

The attached LabVIEW snippet demonstrates:

  • Configuring the output stream session with replay enabled.
  • Terminal connections for triggering.
  • Writing frames with timestamps for precise replay.