(E-Mail Removed) wrote:
> I use UDP to transfer 64K datagrams between two local PC's over
> 100Mbps Ethernet connection. Works fine under normal
> conditions. However, when my sender code generates calls to sendto()
> at max speed, the datagrams are lost. sendto() does not return any
> error code, send buffer is set to 50MB but it does not make any
> difference because sendto() with large datagrams of 64K blocks the
> caller until all bits are sent. The receiving PC does not see any of
> the lost datagrams. It only sees the datagrams that get through.
You need to know that unless you are running on a very rare network
type (ie one with a 64+KB MTU), those 64K messages you hand to UDP
will be handed to IP and _fragmented_ into MTUish-sized IP datagram
fragments. If _any_ of the IP datagram fragments of an IP datagram
carrying the UDP datagram carrying your message are lost, the entire
IP datagram carrying the UDP datagram carrying your message is useless
- it cannot be reassembled and will be dropped.
> Apparently, the datagrams are trashed in the physical connection. I
> tried a direct connection with crosswire cable, and through a switch
> and the datagrams are lost in either case.
You might want to check the link-level stats with ethtool on both
sides, as well as the UDP and IP stats on the receiver with
netstat. Take some "snapshots" from before and after your transfer,
and run them through beforeafter:
ftp://ftp.cup.hp.com/dist/networking/tools/
And you will see the deltas between the snapshots without having to do
the math yourself.
> When I put a very small delay/sleep between each call to sendto(),
> then all datagrams get through. Does it mean that sendto() requires
> a throttle?
Not sendto() so much as UDP. (The sendto() call might be used with
other transport protocols with semantics different from UDP's)
While Linux provides intra-stack flow-control when sending UDP
datagrams (notice that a netperf UDP_STREAM test doesn't report
greater than link-rate on the sending side), that I suspect provides
some with a false sense of security, and allows them to forget that
there is no end-to-end flow control (nor recovery from datagram loss)
in UDP. UDP is but a thin veneer on top of IP.
Not only does your application require a throttle, it requires a
mechanism to recover from lost datagrams, because even if you throttle
to a given rate nominally achievable by the link(s) you can still have
packet loss.
rick jones
--
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway...

feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...