From owner-freebsd-hackers Tue Nov 27 10:20:27 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id B402437B41A for ; Tue, 27 Nov 2001 10:20:17 -0800 (PST) Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id KAA10029; Tue, 27 Nov 2001 10:11:53 -0800 (PST) Date: Tue, 27 Nov 2001 10:11:52 -0800 (PST) From: Julian Elischer To: Rajesh P Jain Cc: freebsd-hackers@freebsd.org Subject: Re: BPF - Packet Reception In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG netgraph? On Tue, 27 Nov 2001, Rajesh P Jain wrote: > Thanks for all the replies. > > In linux, the packet reception can be done efficiently through the usage of ethernet sockets. > > In FreeBSD, one of the option is by using the BPF. But, as already commented, BPF is not a high performance device. > > So, Can anyone give an alternative way in FreeBSD (other than modifying the driver code), so that high packet-rate reception can be done by without dropping any of the packets ? > > Thanks in advance > Raj > > -- > > On Mon, 26 Nov 2001 17:05:33 Robert Watson wrote: > > > >On Mon, 26 Nov 2001, Rajesh P Jain wrote: > > > >> We are trying to use BPF (Packet Filter) pseduo device to send > >> and receive the packets. > >> Even if there is a slight delay (Some processing has to be done > >> on the read packet) between the issuing of 'read' call, so many packets > >> are getting dropped. > >> Is there a way to attach a callback function to the opened device, > >> so that on a packet arrival, this function is being called. > >> We polling the device is always risky thing as we may loose some > >> packet. > >> Any help on this would be very much appreciated. Thanks and > >> regards, -Raj > > > >There are a number of things that can be done to improve BPF's behavior > >under high volume, including setting a larger in-kernel buffer for BPF > >(using BIOCSBLEN), as well as implementing the equivilent of interupt > >coallescing when delivering packets to userland, through the use of a > >timeout (BIOCSRTIMEOUT, BIOCIMMEDIATE), which can increase throughput. > >While BPF is not able to handle extremely high packet rates, due to it > >performing memory copies and simple virtual machine execution, I've quite > >successfully used it to do userland packet forwarding (read, process, > >send) in the 100mbps range on moderately equipped machines. Depending on > >the nature of the packets you're capturing, optimizing your BPF code, or > >feeding it code that matches more specifically, can also impact > >performance. > > > >The performance of BPF is often directly associated with the amount of > >userland context switching going on: for example, running my BPF-based > >packet forwarding program at the same time as tcpdump would easily halve > >the throughput by making the number of context switches proportional to > >the number of packets delivered. A single process performing BPF > >operations will perform *much* better on an unloaded machine. > > > >Robert N M Watson FreeBSD Core Team, TrustedBSD Project > >robert@fledge.watson.org NAI Labs, Safeport Network Services > > > > > > > > > > > Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message