UDP packet loss receive
이전 댓글 표시
I am using Matlab to receive and process UDP packages sent from a microcontroller via Ethernet. This works without problems - but if I send a high amount of data, at a certain point UDP packages get lost in an random-looking way.
I assumed, that the InputBufferSize was too small, but increasing it had no effect. Also flushing the input buffer before the occurrence did not fix the problem. (The buffer is never full, checked with BytesAvailable).
Closing and re-opening the UDP connection fixes the problem, but causes a high delay and loss of data during the connection is closed.
I saved the packages to a text-file and compared them to the Wireshark packets. In Wireshark no packet loss happens.
%How I open the connection:
u=udp('192.168.0.100', 55055,'LocalPort', 55056,'DatagramTerminateMode','on', 'InputBufferSize',500000);
fopen(u);
flushinput(u);
u.Timeout = 1;
%How I read packages:
while(1)
[udp_package,count,msg] = fread(u);
fprintf(fileID,'%s\n',udp_package);
end
댓글 수: 4
Walter Roberson
2015년 11월 23일
Is there a router or switch between the devices, or is the microcontroller connected directly by ethernet cable to a port on the computer?
Josef Stein
2015년 11월 23일
Luigi
2018년 2월 20일
I have the same problem. Only the sequence fopen(UDPobject) - fread(UDPobject) - fclose(UDPobject) for every read operation gives me a contiguous sequence of data without packet loss, but is slow. Have tried 'flushinput', changing 'inputBufferSize' and also reducing the data-rate from the source. All without success.
Gideon Bergbaum
2021년 3월 15일
I also have the same problem. I have the same code working on a Windows 7 machine but when the setup was upgraded to Windows 10 this stopped working. I have tried disabling firewalls, changing network adapter priorities and increasing the specificity of my UDP port. None of this has worked:
udpport("datagram","LocalHost",'X.X.X.X',"LocalPort", X, "EnablePortSharing", true);
답변 (1개)
Matthias Kern
2018년 8월 24일
0 개 추천
I can confirm the issue. I want to read 5000 packages but after ~3500 I loose packages. The input buffer size is set to 5000*packageSize
카테고리
도움말 센터 및 File Exchange에서 Call C/C++ from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!