Estoy haciendo un UDP C/S. Tengo un problema con la cantidad de datos que el servidor puede recibir por segundo.Servidor UDP y Cliente en Delphi
He probado el envío de lotes de 10, 100, 1000 mensajes de datos al servidor, 10, 100 recibidos sin ningún problema. cuando se envía 1000, solo se reciben 300 ~ 400. Todas las pruebas hechas localmente.
He intentado implementar el servidor utilizando tanto el twosecket de ICS como el tudpblocksocket de Synapse. Ambos resultaron con el mismo problema anterior.
¿Podría alguno explicarme por qué sucede esto y cómo podría mejorar el rendimiento del servidor?
Código usando TUDPBlockSocket
...
while not Terminated do
begin
try
sz := FUDPServer.WaitingData;
if sz > 0 then
begin
FUDPServer.RecvBuffer(mem.Memory, sz);
mem.Seek(0, 0);
AMessage := fFormats.ReadFromStream(mem);
DoMessageReceived(FUDPServer.RemoteSin.sin_addr, AMessage);
end;
finally
end;
end;
...
código usando ICS
...
procedure TShapeServer.WSocketDataAvailable(Sender: TObject; ErrCode: Word);
...
begin
SrcLen := SizeOf(Src);
stream := TMemoryStream.Create;
stream.SetSize(INT_BUFFER_SIZE);
Inc(fMessageReceived);
try
Len := FUDPServer.ReceiveFrom(stream.Memory, stream.size, Src, SrcLen);
if (FSenderAddr.S_addr = INADDR_ANY) or
(FSenderAddr.S_addr = Src.Sin_addr.S_addr) then
begin
while stream.Position < Len do
begin
try
AMessage := fFormats.ReadFromStream(stream);
DoMessageReceived(Src.Sin_addr, AMessage);
except
break;
end;
end;
end;
finally
stream.Free;
end;
end;
...
¿Se puede registrar el tráfico udp loopback utilizando wireshark (en Windows funciona con winpcap)? –
También vería el límite de "seguridad" de Microsoft del paquete por segundo. IIRC, tcpip.sys informó acción de límite al registro de eventos –
Intenté wireshark. No estoy seguro de haberlo hecho mal, pero hay un adaptador de bucle para que yo elija. :(Gran herramienta si – Darkerstar