From owner-freebsd-net@FreeBSD.ORG Thu Dec 26 17:49:16 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8D5D79E1 for ; Thu, 26 Dec 2013 17:49:16 +0000 (UTC) Received: from mail-pd0-x22e.google.com (mail-pd0-x22e.google.com [IPv6:2607:f8b0:400e:c02::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6688D13CD for ; Thu, 26 Dec 2013 17:49:16 +0000 (UTC) Received: by mail-pd0-f174.google.com with SMTP id x10so8260165pdj.33 for ; Thu, 26 Dec 2013 09:49:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=skRpVNCq0/rOwV1JwVGtosLN+51feQb/0mrIU7+UjO0=; b=eANZ/uCXaYSPDm5SWp28gAXuMDM/pu8Sia3ShyjOZKQkE6RvdiZtLmOft2tt0/59D0 Nn8F6sBVWLDdbQg8bjZh+f1Ah1JrjUddqyjbl7ge1KIXzbzx8o40l2zwZrbvVw8cUN2U 3zxu+sloae6TDnVu8l6O6sLLKu8cvjLoQkWSpBEccJD6MtASpZTt4C1ronET5VBpzO6/ 7hj0RbCms+ls43WfB8E0/owqz5tKjqu3ZQaOpNg7FZMGfzsqUGj3wOzqXxc2htFHkX8N UgBCNWKcHHNhnq+MDrrnLflkYPFtm5oqdenrA+nFdWyhkURB7PlszJVnuDxzy4IclSp1 aElw== MIME-Version: 1.0 X-Received: by 10.68.170.66 with SMTP id ak2mr45460209pbc.5.1388080156051; Thu, 26 Dec 2013 09:49:16 -0800 (PST) Received: by 10.68.147.131 with HTTP; Thu, 26 Dec 2013 09:49:16 -0800 (PST) Date: Thu, 26 Dec 2013 09:49:16 -0800 Message-ID: Subject: Question about the "connected" UDP sockets From: Oleg Moskalenko To: FreeBSD Net Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2013 17:49:16 -0000 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