Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Dec 2013 09:49:16 -0800
From:      Oleg Moskalenko <mom040267@gmail.com>
To:        FreeBSD Net <freebsd-net@freebsd.org>
Subject:   Question about the "connected" UDP sockets
Message-ID:  <CALDtMrL32%2BYdhCH2s2SPG31MOS4j9XXFXNsrei80e=k98ApUAA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi

I cannot find the information about the implementation details of the
"connected" UDP sockets in FreeBSD. I know that in older Linux kernels all
UDP sockets are stored in a hash table - and the remote IP:port are not
used for the hash calculation, so the performance is awful when you have
thousands "connected" UDP sockets on the same local IP:port address. So a
UDP packet incoming to the local address has to go through the long list of
sockets to find the proper destination.

How it is done in the FreeBSD ? Are the UDP "connected" sockets using a
hash table with key based upon 5-tuple (protocol, remote-ip, remote-port,
local-ip, local-port} ?

I'd like to use UDP for my server application in the same way as TCP is
used: I'll accept a new incoming packet, determine whether the remote
address is "new", and if it is new I'd create a new UDP socket bound to the
same local address and connected to the remote address. I'll end up with
thousands UDP sockets with the same local address and different remote
addresses; and the sockets are distributed among several threads (one per
CPU core). How efficiently this case is handled by FreeBSD kernel ? In the
older Linuxes the performance is quickly degrading when the number of
"connected" UDP sockets is growing.

Will I'll be better with just a single-threaded application with a single
unconnected UDP socket ?

Thanks !
Oleg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALDtMrL32%2BYdhCH2s2SPG31MOS4j9XXFXNsrei80e=k98ApUAA>