Hi Zufei,
I understand that you want to replay CAN FD messages in sync with real-time, ensuring simulated time aligns with actual time. However, I acknowledge the challenge you're currently facing in achieving this synchronization.
This delay is caused by other application activities that interrupts MATLAB and causes hitches in the performace. As such, it's variable to even quote latency at all because it can be affected by so many variables. So, the Latency and timing operations on desktop cannot be guaranteed.
If deterministic latency and extremely low reliable latency are required, then you should consider using a real-time platform, like Simulink Real-Time.
For further insights and practical guidance, you might find the VNT example on periodic CAN communication beneficial. This resource can be accessed at: https://in.mathworks.com/help/vnt/ug/periodic-can-communication.html