Borrar filtros
Borrar filtros

UDP data rate slow with 1GBE ethernet connection

7 visualizaciones (últimos 30 días)
Shimon Elkin
Shimon Elkin el 19 de Jul. de 2022
Respondida: Vinayak el 17 de En. de 2024
hi folks,
i have a two work station that are connects via 1GBE ethernet.
when transfering data at this setup i've encountered that the data rate is ~20MBs which is mach lower then the expected data rate of a 1GBe comminication. i've used udp object and udpport object that ended up with the same results in MATLAB. Code below>>
ferther investing this ive found out that an off the shelf Cpp code gets 800MBs data rate.
  • is there a way to enhance or controll the data rate from within MATLAB?
  • if not how can i work with higher data rates inder my setup, use external C\Java code?
--------------------------------------- Code ---------------------------------------
% TASK send data from port A to Port B
% UDP test for the same computer nIP = 1
% UDP test for the two computers nIP = 2
clc, clear all, close all
n_packets = 200;
packet_size = 4096;
BufferSize = packet_size * 2;
nIP = 1;
%
ipA = '192.168.1.100'; portA = 9092;
if nIP == 1
ipB = '192.168.1.100'; portB = 9093;
else
ipB = '192.168.1.101'; portB = 9093;
end
u=udp(ipB,'RemotePort',portB,'Localport',portA);
set(u, 'InputBufferSize', BufferSize);
set(u, 'OutputBufferSize', BufferSize);
set(u,'DatagramTerminateMode','off')
set(u,'Timeout',0.01);
a = zeros(packet_size,1,'int16');
b = zeros(packet_size,1,'int16');
a = ones(packet_size,1,'int16');
i = 1;
miss_count = 0;
fopen(u);
tic
% Loop over write
while 1 %i<n_packets
a(1) = mod(i,32767);
fwrite(u,a,'int16');
i = i + 1;
end
t_proc = toc;
echoudp('off');
fclose(u);
delete(u);
data_rate = ((n_packets * packet_size * 16)/1e6)/t_proc;
fprintf('\n n_miss_packet = %g',miss_count);
fprintf('\n tudp_trx_sec = %g',t_proc);
fprintf('\n udp_rate_Mbit/s = %g',data_rate);
% TASK get data from port A to Port B
% TASK send data from port A to Port B
% UDP test for the same computer nIP = 1
% UDP test for the two computers nIP = 2
clc, clear, close all
n_packets = 200;
packet_size = 4096; % 16 bits
BufferSize = packet_size * 2;
nIP = 1;
%Shimmi
ii_max = 15;
t_proc_sum = zeros(size(1:ii_max));
miss_count_sum = zeros(size(1:ii_max));
date_rate_sum = zeros(size(1:ii_max));
ipA = '10.1.21.81'; portA = 9092;
if nIP == 1
ipB = '192.168.1.100'; portB = 9093;
else
ipB = '192.168.1.100'; portB = 9093;
end
for ii=1:ii_max
u=udp(ipA,'RemotePort',portA,'Localport',portB);
set(u, 'InputBufferSize', BufferSize);
set(u, 'OutputBufferSize', BufferSize);
a = zeros(packet_size,1,'int16');
b = zeros(packet_size,1,'int16');
a = ones(packet_size,1,'int16');
set(u,'DatagramTerminateMode','off')
set(u,'Timeout',0.01);
i = 1;
iprev = 1;
miss_count = 0;
% Open UDP
fopen(u);
tic
% Loop over read
while i<n_packets
b=fread(u,packet_size,'int16');
icurr = b(1);
if (iprev ~= icurr)
miss_count = miss_count + 1;
end
iprev = icurr + 1;
i = i + 1;
end
t_proc = toc;
echoudp('off');
fclose(u);
delete(u);
data_rate = ((n_packets * packet_size * 16)/t_proc)/1e6;
%
% fprintf('\n n_miss_packet = %g',miss_count);
% fprintf('\n tudp_rx_sec = %g',t_proc);
% fprintf('\n udp_rate_Mbit/s = %g',data_rate);
%analytics
miss_count_sum(ii) = miss_count;
t_proc_sum (ii) =t_proc;
date_rate_sum (ii) = data_rate;
ii = ii+1;
end
fprintf('\n n_miss_packet = %f',mean(miss_count_sum));
fprintf('\n tudp_rx_sec = %f',mean(t_proc_sum));
fprintf('\n udp_rate_Mbit/s = %f',mean(date_rate_sum));
fprintf('\n ');
  2 comentarios
Shimon Elkin
Shimon Elkin el 20 de Jul. de 2022
Hi @Jeffrey Clark, yes i've used udp object and udpport object that ended up with the same results in MATLAB.

Iniciar sesión para comentar.

Respuestas (1)

Vinayak
Vinayak el 17 de En. de 2024
Hi Shimon,
The issues with UDP performance that you've outlined could stem from various factors. To address this, I recommend the following actions:
  • Confirm that the network infrastructure can accommodate the required transfer speeds.
  • Optimize the Buffer Size and Packet Sizes; experimenting with different combinations of values can help find the optimal balance, minimizing overhead and fragmentation.
  • Explore the potential of parallel processing capabilities, if applicable to your specific problem.
  • Consider utilizing external language interfaces such as C or Python.
For further information on udpport”, and the Parallel Computing Toolbox, please refer to the following links:
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by