UDP fread not returning entire datagram
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 15 Avr 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
le 17 Avr 2013
Walter Roberson
le 17 Avr 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
le 17 Avr 2013
Try 'uint8' instead of '*uint8'.
Jay
le 17 Avr 2013
Walter Roberson
le 17 Avr 2013
What count is being returned now? And what is DatagramLength currently?
Walter Roberson
le 17 Avr 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
le 19 Avr 2013
I think you should take this to tech support.
Réponses (0)
Catégories
En savoir plus sur Instrument Control Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!