The issue you're experiencing might be related to the internal buffer of the UDP driver, which stores unread packets until its capacity is reached. It's crucial to understand that while the Packet Output block sends a packet at each time step regardless of input changes, the Packet Input block reads only one packet per time step, even if several packets are waiting in the buffer. This can create a situation where a long queue of unprocessed packets gives the appearance of a delay, as packets arrive faster than they are processed.
Here are some strategies to consider:
- Adjust Sample Time: Set the sample time of the Packet Input block to be shorter than the expected period of new packet arrivals. Utilize the Data Ready port to check when a new packet has arrived.
- Discard Older Messages: If reducing the sample time isn't possible and only the newest message is needed, use the Data Ready port of the Packet Input block to discard older messages. Place the Packet Input block inside a While Iterator subsystem, using the Data Ready port to drive the While condition. This setup ensures messages are read one-by-one, displaying only the latest data at the output. Remember to set all blocks inside the While Iterator subsystem to a sample rate of -1, as they inherit their sample rate from the While subsystem.