UDP fread not returning entire datagram

2 views (last 30 days)
Jay
Jay on 15 Apr 2013
I have an application where I am using UDP to get data from another application. I have my UDP object in DatagramTerminateMode, and I am calling fread in my callback.
The application was working just fine until today, and I am not exactly sure what I changed. Some calls to fread are only returning 256 bytes instead of roughly 8000 bytes. If I add a command to my callback and leave off the semicolon it seems to make everything work again.
This would suggest that fread is being called before data is ready, but I am in DatagramTerminateMode so there should always be a datagram available when the callback is executed.
You may also be thinking... "are you sure that datagram isn't actually 256 bytes?" Well I am rather certain that is it not... When I debug the other application it appear to never be sending a datagram less than 8000 bytes.
  11 Comments
Jay
Jay on 19 Apr 2013
Edited: Jay on 19 Apr 2013
I have modified the data portion of the UDP packets to simply be:
  • int32 Index
  • lots of zeros
  • 0xAA
I am using this index to line up the erronous packets in matlab with the packets in wireshark.
I run my matlab application with a breakpoint checking whether the entire datagram was read. I break in the case that there is a partially read datagram. I then read out the packet index from matlab and find that packet in wireshark.
Wireshark shows the packet correctly: index, lots of zeros, 0xAA. 505 bytes of data total.
Matlab reports that there are 505 data bytes, but only read 391 bytes. The bytes that it read are correct, it just ends before it gets to the 0xAA.
As a precaution I have set udpobject.Terminator = '';
Walter Roberson
Walter Roberson on 19 Apr 2013
I think you should take this to tech support.

Sign in to comment.

Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!