Why do I stop receiving UDP data sent over Ethernet?

5 views (last 30 days)
I have two laptops, each recording data from separate instruments using TCP/IP. In order to time-synchronize the data collected from both laptops, I must send a signal (trigger) from one laptop to the other. To do this, one computer sends a UDP packet containing a 1 or 2, which is read in from the ethernet port (2222) on the other computer through a MatLab UDP object. Once received, I know when both data recodings begin/end.
Sometimes all will work fine, sometimes the UDP packets stop receiving after the first trigger, sometimes nothing is received at all. As far as I can tell, the first laptop is sending the triggers correctly, and on the other laptop, the ethernet port is always open and the UDP object listening to it.
There appears to be no consistent pattern leading to this issue - opening one laptop before the other, sending triggers repeatedly, etc.
Every time that I set up the UDP object, I make sure that all previously open/connected ports are closed and workspace variables/objects are deleted and cleared.
fclose(Data); % Data = TCP/IP object for data recording
fclose(Trigger); % Trigger = UDP object for receiving trigger value (1 or 2)
delete(Data);
delete(Trigger);
clear Data Trigger
I also use instrreset to refresh the ports.
instrreset
I am aware that UDP is not a reliable protocol to transmit data, but the random failure to receive data using the MatLab UDP object is baffling...
Any help would be greatly appreciated!

Answers (1)

Ram Vijayaragavan
Ram Vijayaragavan on 6 Feb 2020
Hi Matt,
Please check the following answer on how to send data between two computers using udp:
I Hope this helps.

Categories

Find more on Interface-Based Instrument Communication in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!