UDP fread not returning entire datagram
Show older comments
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
Walter Roberson
on 15 Apr 2013
Are you using Gigabit Ethernet with Jumbo Packets enabled? If so is it possible that something in the network stopped supporting those?
Only Gigabit (and higher) Ethernet with Jumbo Packets support 8000+ byte payloads; for anything else, the packets would have to be fragmented. Relying on reliable delivery of multiple fragments of an unreliable datagram protocol has always seemed like an oxymoron to me.
Jay
on 17 Apr 2013
Walter Roberson
on 17 Apr 2013
Experiment with passing a size to fread:
fread(udpobject, event.Data.DatagramLength, '*uint8')
In theory the size should be ignored when the datagram terminate mode is on, but let's try it just in case.
Walter Roberson
on 17 Apr 2013
Try 'uint8' instead of '*uint8'.
Jay
on 17 Apr 2013
Walter Roberson
on 17 Apr 2013
What count is being returned now? And what is DatagramLength currently?
Walter Roberson
on 17 Apr 2013
Have you tossed on a network sniffer such as wireshark, just to verify that the packets are getting there correctly?
Have you tried sending a variety of packet contents, and checking whether there is any particular character that is causing the problems? Key characters I would check would be char(0), and CR and LF and char(26)
Walter Roberson
on 19 Apr 2013
I think you should take this to tech support.
Answers (0)
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!