UDP fread not returning entire datagram
古いコメントを表示
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 件のコメント
Walter Roberson
2013 年 4 月 15 日
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
2013 年 4 月 17 日
Walter Roberson
2013 年 4 月 17 日
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
2013 年 4 月 17 日
Try 'uint8' instead of '*uint8'.
Jay
2013 年 4 月 17 日
Walter Roberson
2013 年 4 月 17 日
What count is being returned now? And what is DatagramLength currently?
Walter Roberson
2013 年 4 月 17 日
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
2013 年 4 月 19 日
I think you should take this to tech support.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Instrument Control Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!