Re: Please help me with my lost UDP packets

From: _at_ *SPAM* yahoo_com (_at_)
Date: 04/03/04


Date: Sat, 03 Apr 2004 13:14:13 -0800

For this application, some packet loss is OK. But the 80-90% failure
that I'm seeing is no good. The device originating the traffic is
sending UDP packets. Data integrity is not an issue.

I've worked with UDP before; I've just never seen it so flaky before but
I'm new to wireless networking and Pocket PC. I want to learn if the
Pocket PC is simply incapable of handling UDP in a decent manner or
(more likely) my code is the problem.

Thanks!

John

Trevor wrote:

> "@ *SPAM* yahoo_com" <""jlindwall*NO*\"@ *SPAM* yahoo_com"> wrote in message
> news:88CdnQbscvDvq_DdRVn-hQ@adelphia.com...
>
>>I'm new to the Compact Framework and C# but have been programming for
>>years, but not on small devices.
>>
>>I have written a program running on Dell Axim that receives UDP packets.
>> that was converted from java using the tool provided by Microsoft. It
>>creates a TextBox to display messages (like "packet received" etc) and a
>>button. When the button is pressed the program listens for UDP packets
>>on port 51800.
>>
>>On my desktop PC I then run a program that creates packets and sends
>>them to the proper IP address/port. Early in my learning process I
>>learned that I needed to disconnect the Axim from the cradle and use the
>>wireless network for receiving network traffic. I *DO* receive some of
>>the UDP packets, so my problem is not that I can't receive any data ---
>>my problem is that delivery seems unreliable even by UDP standards.
>>
>>Out of 100 packets (each 10 bytes) sent (with a delay of 500 or 1000 ms
>>between packets) my program receives 10-12 of them. I also tried 256
>>byte packets and 1024 with similar disappointing results.
>>
>>Is this normal on these little devices? Am I expecting too much? I
>>know that UDP is not guaranteed but this seems so bad that I can only
>>assume my program is flawed.
>>
>>I can provide more code if needed. A UdpClient is used to receive the
>>data. Here's the receive method if that helps.
>>
>>THANKS!
>>
>>public static void Receive(System.Net.Sockets.UdpClient tempClient,
>> out PacketSupport packet)
>>{
>> System.Net.IPEndPoint remoteIpEndPoint =
>>new System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
>>
>> PacketSupport tempPacket;
>> try
>> {
>> byte[] data_in = tempClient.Receive(ref remoteIpEndPoint);
>> tempPacket = new PacketSupport(data_in, data_in.Length);
>> tempPacket.IPEndPoint = remoteIpEndPoint;
>> }
>> catch ( System.Exception e )
>> {
>> throw new System.Exception(e.Message);
>> }
>> packet = tempPacket;
>>}
>
>
> In general, if you are looking towards using UDP and packet loss is
> unacceptable you have two solutions.
>
> 1) Build a "smarter" protocol on top of UDP which implements sequence
> numbers, resends, acks, etc..
> 2) Switch to TCP which already has sequence numbers, resends, acks, etc...
>
> Most people would choose #2 and be on their merry way. Plain old UDP is not
> reliable. It really depends on the networks, routers, etc... I wouldn't
> waste much time on this issue. It is the nature of the beast. The only
> feasible situation for using plain old UDP is in a video game or something
> like that where speed is more important than data integrity or where data
> integrity is not important at all.
>
>