Question about the "connected" UDP sockets

Oleg Moskalenko mom040267 at gmail.com
Thu Dec 26 17:49:16 UTC 2013


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


More information about the freebsd-net mailing list