From owner-freebsd-net@FreeBSD.ORG Thu Nov 25 13:22:53 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 329001065670; Thu, 25 Nov 2010 13:22:53 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id C2B868FC12; Thu, 25 Nov 2010 13:22:52 +0000 (UTC) Received: from c122-106-145-124.carlnfd1.nsw.optusnet.com.au (c122-106-145-124.carlnfd1.nsw.optusnet.com.au [122.106.145.124]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id oAPDMnOH022253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 26 Nov 2010 00:22:50 +1100 Date: Fri, 26 Nov 2010 00:22:49 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ivan Voras In-Reply-To: Message-ID: <20101125234706.O3121@besplex.bde.org> References: <4CEBBB8F.70400@sentex.net> <20101123151153.GB27694@diehard.n-r-g.com> <20101125150444.D1713@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org Subject: Re: em driver, 82574L chip, and possibly ASPM X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 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, 25 Nov 2010 13:22:53 -0000 On Thu, 25 Nov 2010, Ivan Voras wrote: > On 11/25/10 05:54, Bruce Evans wrote: > >> Yes, this is normal. It is how ping -f doesn't work -- it doesn't do >> anything >> resembling flooding, except possibly accidentally when 1 Mbps ethernet was >> fast. The ramping up is also accidental. >> ... > > Thank you, that was a very informative explanation! > > So in case I really do want to flood ping or in some other way test PPS > throughput, are there any convenient tools for that? netrate (netsend/netblast) is almost adequate. I normally use a 1990ish version of ttcp with iny modifications. It is also almost adequate. A problem with all of these is that that cannot do the right thing when the send queue fills up. send() should then return ENOBUFS. Userland then has the following bad options to handle this: - loop calling send(). Takes 100% of 1 CPU and may consume time needed for productive i/o - try using blocking mode and select(), and usually discover that select() doesn't work for for handling ENOBUFS. Maybe it is the blocking mode that doesn't work. I think the FreeBSD kernel can't easily tell if it should block because the driver would return ENOBUFS. Userland has even less chance of telling if it should not try to send() because the i/o would either block or fail with ENOBUFS - try to predict when send() will not block due to ENOBUFS, and wait until then non-busily using sleep(). Old ttcp does essentially this, and does it very badly -- it uses a very long hard-coded sleep time that may have worked when 1 Mbps ethernet was fast, but is now not so good. Newer ttcps try harder using shorter sleeps, but still tend to fail due to the sleep granularity being large. Send buffer queue lengths for 1 Gbps ethernet are typically 1024 packets, so the whole buffer can be drained in less than 1 msec and the sleep granularity needs to be considerably less than 1 msec to keep up, but this is unreasonably short. I avoid this problem using very large queue length (~10000, so that the sleeps for 10 msec in old ttcp can keep up (also depends on my NIC not draining as fast as theoretically possible, else I would need a queue length of 40000)). netsend also uses sleeps to control its rate, and cannot work very well due to sleep granularity. The limits for input are easier to test, once you can generate floods from somewhere, since the ENOBUFS problem corresponds to saturation/dropping packets/flow control, so when you hit it you know that you are at the limit. sam@ implemented or ported kttcp (kernel ttcp) which reduces at least the network stack overheads for sending packets, so the limits are closer to the driver and/or network. I have't got around to trying it. I don't know how it handlers ENOBUFS. Bruce