Re: DatagramSocket receive performance
- From: Timothy Bendfelt <bendfelt@xxxxxxxxxxx>
- Date: Wed, 28 Mar 2007 18:50:48 -0500
I'll add my 2 cents about the packet loss. Without setting the receive
buffer size on the socket you probably get a default buffer of 8K. This
is pretty shallow for high data rates without flow control. If the VM
turns its back for just a second (GC) and if a burst comes from the
server the buffered packets will be overwritten (dropped) by the newly
arriving packets.
As far as the setLength() call on the reused client DatagramPacket I think
that winsock is doing some strange accounting on the socket buffer when
you pull out less data than was delivered. Even with this call though you may
see the problem again at a higher data rate and you may see it in the java
client before the native one.
Your native client code is ether quicker on the draw and never needs 8K
of data buffered locally, or it is using a deeper buffer that can withstand a
bigger delivery burst in between scheduling.
You can detect this by putting a sequence number in the payload and
watching at the client to see when they skip or go out of order.
I've had similar problems working with UDP apps that want a reliable
delivery semantic.
Hope this helps.
On Sat, 24 Mar 2007, Ron wrote:
On Mar 23, 11:30 pm, Esmond Pitt <esmond.p...@xxxxxxxxxxxxxxxxxx>
wrote:
Ron wrote:
If anyone knows, I sure would appreciate a hint. :D
When you receive into a DatagramPacket its length is reset to the length
of the incoming data if it's shorter than the original length. So if you
keep receiving variable-length datagrams into the same DGP the DGP will
keep shrinking, and you will be losing data at the end of the larger
datagrams received.
See src/{solaris,windows}/native/java/net/PlainDatagramSocketImpl.c, end
of the receive0() function.
Gah. Not sure how I missed that. Thank you.
Unfortunately I'm still confused. I totally understand how this could
result in losing data. But I was actually seeing packets go missing
entirely.
Without setLength(), the count variable in my java program would trail
the count variable in my c program. As soon as added setLength(), the
counts in the two programs matched. This was true, even if I added
setLength(0) at the start of the loop! The count would be fine, I
just could never see the contents of the packet. I think there must
be more to the story.
.
- References:
- DatagramSocket receive performance
- From: Ron
- Re: DatagramSocket receive performance
- From: Ron
- Re: DatagramSocket receive performance
- From: Esmond Pitt
- Re: DatagramSocket receive performance
- From: Ron
- DatagramSocket receive performance
- Prev by Date: Re: SAX PARSING DESIGN PATTERN
- Next by Date: Re: Why does it worth sun to give java sdk away for free?
- Previous by thread: Re: DatagramSocket receive performance
- Next by thread: Way to get session variables into a non-servlet?
- Index(es):
Relevant Pages
|