Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Indy UDP Server onReceiveData



Permlink Replies: 3 - Last Post: May 31, 2017 2:25 PM Last Post By: Remy Lebeau (Te...
Zoran Djokic

Posts: 2
Registered: 6/14/15
Indy UDP Server onReceiveData
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 28, 2017 12:30 PM
I suppose this part of forum should be the best place to ask Indy related question. It is probably more UDP related. Suppose I want to send some very long string using Indy UDP (let's say 10 Mbytes), using Send method. On the receiving side, I would like to use onUDPRead event to read incoming data and suppose all the data correctly come to the receiving peer. Should I expect to receive all the data in one onUDPRead event or there will be few events of that kind to fulfill all the data.

Regards
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Indy UDP Server onReceiveData
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2017 12:03 PM   in response to: Zoran Djokic in response to: Zoran Djokic
Zoran Djokic wrote:

I suppose this part of forum should be the best place to ask Indy
related question.

Yes.

It is probably more UDP related. Suppose I want to send some very long
string using Indy UDP (let's say 10 Mbytes), using Send method.

In IPv4, UDP can't handle that much data in a single packet, the max
payload size is 65507 bytes (65535 - 28 bytes for IP and UDP headers).

In IPv6, UDP packets can have payloads over 65535 bytes, but this
feature is optional and requires support from transport providers.
Best to avoid relying on it.

You will have to split up your data into small chunks and send them
individually, and then reassemble them on the receiving end. And,
since UDP is connectionless and does not guarantee delivery or
receiving order, you will have to detect and retransmit missing packets
from time to time, ignore any duplicate packets, reorder received
packets, etc.

On the receiving side, I would like to use onUDPRead event to read
incoming data and suppose all the data correctly come to the receiving
peer. Should I expect to receive all the data in one onUDPRead event
or there will be few events of that kind to fulfill all the data.

The OnUDPRead event will be triggered for each individual packet
received. To send 10MB of data over UDP would require at least 161
packets, so that is at least 161 event firings (assuming the packets
arrive at all).

--
Remy Lebeau (TeamB)
Zoran Djokic

Posts: 2
Registered: 6/14/15
Re: Indy UDP Server onReceiveData
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 31, 2017 11:20 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you for your reply. Meanwhile I made a little investigation that confirms your writings. Also found that UDP header that describes packet length, has two bytes- which means 65 k data.
I am aware of the lack of handling UDP vs TCP, but I have very specific situation and not so sure about the way I should handle my data. In fact I have WiFi/RS232 module which serves data transparently in UDP mode, but in TCP mode with some headers and even then the (RS232) data come in chunks of 1500 bytes (7000 of them for 10Mb data). On the other hand the ONLY peer the module will communicate to is mobile phone (head to head) so I think there should be no UDP packets disordering...). That's why I take into account UDP (and also because of having no need to manipulate broken connections and timeouts like with TCP).
Although that should be some different thread in this forum, I'll be glad to learn other opinions regarding that matter (UDP or TCP in that specific use case).

Thanks.

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Indy UDP Server onReceiveData
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 31, 2017 2:25 PM   in response to: Zoran Djokic in response to: Zoran Djokic
Zoran Djokic wrote:

Thank you for your reply. Meanwhile I made a little investigation
that confirms your writings. Also found that UDP header that
describes packet length, has two bytes- which means 65 k data.

That length is for the entire packet, including the IP and UDP headers.
So the entire packet is limited to 64K, and thus application data is
limited to less than 64K.

On the other hand the ONLY peer the module will communicate to is
mobile phone (head to head) so I think there should be no UDP packets
disordering...).

You can't rely on that being true. ANY use of UDP is going to be
subject to potential data loss and packet reordering, so your protocol
needs to be prepared to handle that.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02