Re: A throttle needed for UDP sendto()???
- From: "David Schwartz" <davids@xxxxxxxxxxxxx>
- Date: 8 Mar 2007 14:25:26 -0800
On Mar 8, 1:40 pm, guu...@xxxxxxxxxxx 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.
UDP is a best effort protocol. Datagrams can always be 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.
Apparently, the datagrams are trashed in the physical connection.
Actually, they're most likely being discarded by the sender. But UDP
datagrams can be lost anywhere. The sender can opt not to send them,
the network can lose, reorder, or duplicate them, and the receiver can
throw them away. That's how UDP works.
I tried a direct connection with crosswire cable, and through a switch
and the datagrams are lost in either case.
Again, that is the nature of UDP.
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?
UDP requires the application to do transmit pacing if the traffic is
very bursty or a very large amount of data needs to be sent. I
strongly recommend you use TCP if you need its features, rather than
trying to re-implement TCP yourself.
DS
.
- Follow-Ups:
- Re: A throttle needed for UDP sendto()???
- From: guuwwe
- Re: A throttle needed for UDP sendto()???
- References:
- A throttle needed for UDP sendto()???
- From: guuwwe
- A throttle needed for UDP sendto()???
- Prev by Date: A throttle needed for UDP sendto()???
- Next by Date: Re: A throttle needed for UDP sendto()???
- Previous by thread: A throttle needed for UDP sendto()???
- Next by thread: Re: A throttle needed for UDP sendto()???
- Index(es):
Relevant Pages
|