Forum > Networking and Web Programming

Indy UDP packets losses in duplex

(1/6) > >>

vladbfg:
Hello all,
Before write module for my project I write simple test using TIdUDPServer.

First, code of sender, that send 2000 packs 50 bytes every 300ms by timer


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFmain.UPDSenderTimerTimer(Sender: TObject);  var i : integer;    s:string;    buf : TidBytes;begin  s:= #$7E + #0#0#0+#$7E;  s:= s+#$7E + #0#0#0+#$7E;  s:=s+s+#0#0#0#0#0;// 10+10+5  s:=s+s;// 50   buf := bytesof(s);  for i:=1 to MaxThreads(2000) do begin    idUDPServer.SendBuffer(EditDebug3.Text, 1003, buf);    txp := txp+1;    txb := txb+length(s);  end;end; 
I tested and checked it by Wireshark and all looks like good, I see thousands packets and counts in capture are equal my sended count txp

Second,
I write echo server, it receives pack and send back.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFMain.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;  const AData: TIdBytes; ABinding: TIdSocketHandle);  var sansi : ansistring = '';begin  RxB:= RxB + length(AData);  RxP:= RxP + 1;   lastip := ABinding.PeerIP;  lastport := ABinding.PeerPort;   SetLength(sansi, Length(AData));  Move(Pointer(AData)^, Pointer(sansi)^, Length(AData));   Packs.Add(sansi);  //IdUDPServer1.SendBuffer(ABinding.PeerIP, ABinding.PeerPort, AData); end;
After that, I notice that not all packs are achieved the echo-server. For example I sended 100,000 packs, received 80,000 packs,  but wireshark shows in receive side 100,000packs.

Then I commented  //IdUDPServer1.SendBuffer(ABinding.PeerIP, ABinding.PeerPort, AData);
echo sending and all 100thds packs by rxp  are acheived the aplication|socket.

So, my question is how to make it work in duplex mode?
May be it is nedeed set big buffers or timeouts, separately  TX and RX works fine.


         

cdbc:
Hi
Define a protocol for your duplex, e.g.: handshakes, ack, nack etc...
Regards Benny

vladbfg:

--- Quote from: cdbc on July 19, 2024, 03:02:25 pm ---Hi
Define a protocol for your duplex, e.g.: handshakes, ack, nack etc...
Regards Benny

--- End quote ---
What does protocol have to do with it?
There is no protocol (my own protocol, I send raw data over UDP).   
Protocol doesn't matter.
P.S. You probably didn't understand the question- I need to transfer data in both direction simultaneously, simultaneously Rx + Tx.

TRon:

--- Quote from: vladbfg on July 22, 2024, 06:24:40 am ---What does protocol have to do with it?

--- End quote ---
Everything  :)


--- Quote ---There is no protocol (my own protocol, I send raw data over UDP).   
Protocol doesn't matter.

--- End quote ---
Please read up on UDP f.e. wikipedia


--- Quote ---...
UDP is a connectionless protocol meaning that messages are sent without negotiating a connection and that UDP doesn't keep track of what it has sent.[1][2]
..

--- End quote ---
Note "connectionless"


--- Quote ---P.S. You probably didn't understand the question- I need to transfer data in both direction simultaneously, simultaneously Rx + Tx.

--- End quote ---
I think cdbc understood the question as intended but that is just my hunch.

Are you aware that Indy socket implementation uses blocking sockets ?

vladbfg:

--- Quote from: TRon on July 22, 2024, 07:33:00 am ---
--- Quote ---...
UDP is a connectionless protocol meaning that messages are sent without negotiating a connection and that UDP doesn't keep track of what it has sent.[1][2]
..

--- End quote ---
Note "connectionless"

--- End quote ---
And what?
Did you read my post carefully? ALL packets reach their destination in both directions separately without losses.
Moreover, all packets reach the network card, but do not reach the program (or socket), while I am sending packets (while receiving).


--- Quote ---Are you aware that Indy socket implementation uses blocking sockets ?
--- End quote ---
Thank you for this. Ok, the socket cannot receive a packet while it is transmitting.
But why is the data lost? Why is the data not accepted into the buffer by the operating system (or socket realization) so that I can pick it up later?


Navigation

[0] Message Index

[#] Next page

Go to full version