Overhead, UDP: Many packets on 1 socket vs. one packet and many sockets.
- From: Jason C <jason.cipriani@xxxxxxxxx>
- Date: Sat, 11 Oct 2008 14:15:32 -0700 (PDT)
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
.
- Follow-Ups:
- Re: Overhead, UDP: Many packets on 1 socket vs. one packet and many ?sockets.
- From: Rick Jones
- Re: Overhead, UDP: Many packets on 1 socket vs. one packet and many sockets.
- From: Rainer Weikusat
- Re: Overhead, UDP: Many packets on 1 socket vs. one packet and many ?sockets.
- Prev by Date: Re: sending structure client server
- Next by Date: Re: sending structure client server
- Previous by thread: complete set of 3b1 manuals
- Next by thread: Re: Overhead, UDP: Many packets on 1 socket vs. one packet and many sockets.
- Index(es):
Relevant Pages
|