How to change the UDP receive buffer size in udpport and what is its max value?

29 ビュー (過去 30 日間)
海 林
海 林 2023 年 5 月 26 日
コメント済み: 海 林 2023 年 6 月 1 日
I am using the matlab to receive the data from a FPGA using UDP. But I came with some packages loss problem.
The data stream is under a burst mode. A burst speed could be over 600Mbits/s and the size is about 48MBytes (1024bytes/package and 49152 packages). I found the problem comes frome the receive buffer size of udp sockets. And I can't find the option to change it.
I tried the python which can modify the SO_RCVBUF to meet my requirements.
Also, I found the 'dsp.UDPReceiver' object can modify the receive buffer size by 'ReceiveBufferSize', and the max size is 67108864. It did buffer all the burst data.
The old function udp() can also modify the buffer size by 'InputBufferSize'. But it still loss packages when i set a value over 48M.
Now, scripts are implemented using udpport. I want to know if I can modified the receive buffer size of udpport() and its max value. So if the buffersize of udpport() can be solved, we don't need to turn it into 'dsp.UDPReceiver'.

回答 (1 件)

Meet 2023 年 5 月 31 日
To modify the receive buffer size of ‘udpport()’ in MATLAB, you can use the ‘set’ method.
Example :
bufferSize = 16384; % modify the buffer size (in bytes)
set(u, 'InputBufferSize', bufferSize);
where ‘u’ is the UDP object returned by the udpport() function, and ‘bufferSize’ is the desired receive buffer size in bytes. The above example will set the receive buffer size of the UDP object to 16384 bytes.
Regarding the max value of the receive buffer size, it depends on the operating system and network hardware limitations.
For more details on the ‘set’ function , please refer Configure or display instrument object properties - MATLAB set (
Hope this helps!
  1 件のコメント
海 林
海 林 2023 年 6 月 1 日
Thank you for your answer but there is no 'InputBufferSize' property in the udpport() object, so there will be error when using the 'set' function. It does be a property of the udp() but not udpport(). BTW, My matlab version is 2021b.



Help Center および File ExchangeData Acquisition Toolbox Supported Hardware についてさらに検索





Community Treasure Hunt

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

Start Hunting!

Translated by