Overhead, UDP: Many packets on 1 socket vs. one packet and many sockets.



I have an application that communicates with a series of devices on a
gigabit LAN network (64 or more devices) using UDP. It is constantly
streaming data to these devices. The data is organized into "frames"
and each device frame is a single UDP packet. The current
implementation creates a separate SOCK_DGRAM socket for each device,
then calls connect() and sends packets with send() (rather than using
sendto() with no connect()).

I am now at a point where I have to modify this application to send
additional data to the devices, with some slightly different
information in the data packets. The application must now send more
than one UDP packet per frame to each device.

I basically have two options:

1. Create a new socket for each of these new pieces of data. This
means more than one UDP socket is "connected" to the same network
device. If I have to send 3 UDP packets per frame to a device, I have
3 sockets "connected" to that device, and I serially send a packet
over each of those sockets.

2. Share one socket per device. Only one UDP socket is "connected"
to a given device. If I have to send 3 UDP packets per frame to a
device, I have a single socket "connected" to it and I send 3 packets
using that one socket.

Without going into too much detail, because of the way the application
is designed it is *far* easier to implement number 1 than number 2
(option 1 requires little additional code, option 2 requires nearly a
complete rewrite of the hardware interface portion of the
application).

In the current situation, there are 60 devices each which require 16
UDP packets per frame of data. Therefore option 1 requires 60*16 = 960
sockets and option 2 requires only 60. This machine and LAN is
dedicated to this application and no other applications are competing
for network resources.

My question is, is it worth the trouble to rewrite a lot of the
application to go with option 2? Low network latencies are critical,
and bandwidth usage is fairly high (370 kilobit bursts every 1/60th of
a second -- so about 22 mbps on average, and we'd like to keep each
burst under 0.5 ms). Is there a significant amount of overhead
associated with sending less packets over more sockets to the same
destination, rather than more packets over less sockets? Or will
option 1 have similar performance?

Thanks,
Jason
.



Relevant Pages

  • Re: Update: UDP 770 Potential Worm
    ... > the network immediately after the 'attack', ... were no packets indicating some form of replication. ... I noticed that the UDP ... > of the UDP datagrams is the IP address of the proxy? ...
    (Incidents)
  • Re: Send-Q on UDP socket growing steadily - why?
    ... Send-Q on a moderately active UDP socket keeps growing steadily until it reaches ~128K at which point socket writes start failing. ... The application in question is standard ntpd from Fedora 7, kernel is the latest available for the distro, that is ... "I don't know how to send these packets" mode forever. ...
    (Linux-Kernel)
  • Re: Overhead, UDP: Many packets on 1 socket vs. one packet and many ?sockets.
    ... a gigabit LAN network using UDP. ... into "frames" and each device frame is a single UDP packet. ... information in the data packets. ... over each of those sockets. ...
    (comp.unix.programmer)
  • Re: Determining if it is "safe" to send UDP packets
    ... IMHO for "reliable" UDP you need to use some Quality of service ... Maybe your network is QoS enabled and your traffic gets classified as "below ... > the sender's OS that is throwing the UDP packets away. ... > next 100%-x% are not send, they are almost all completely lost. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: em driver sending bad packet lengths
    ... This is from UDP NFS ... Here is a tcpdump trace showing some bad packets: ... 258 broadcast/multicast datagrams undelivered ... device = 'PRO/1000 EB Network Connection' ...
    (freebsd-net)