Date: Sun, 31 Oct 2004 09:44:17 +0000 (GMT) From: Robert Watson <rwatson@freebsd.org> To: kamal kc <rosey_kc@yahoo.com> Cc: freebsd-net@freebsd.org Subject: Re: Bridge--using Packet Capture Library(libpcap.a) -- efficiency ????? Message-ID: <Pine.NEB.3.96L.1041031093534.48022B-100000@fledge.watson.org> In-Reply-To: <20041031082704.30632.qmail@web13009.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 31 Oct 2004, kamal kc wrote: > I have made a bridge using the Packet Capture Library I set the two nics > to promiscous mode and transfer packet between the two packet capture > handles A piece of the code I use for initializing the packet capture Copying every packet into and out of user space along with the at least two system calls to do each packet will necessarily be expensive. However, 3ms sounds far to high to me, do you have other processes running (such as tcpdump) that might result in additional context switches? I have used BPF to do bridging previously with a lot of success; I have some sample code bridging over a tap interface and a TCP socket -- the source (functional but not pretty) is at: http://www.watson.org/~robert/freebsd/netbridge/ The only complicated bit is walking through the BPF buffer, where sample code is invaluable. Everything else is very straight forward. If you're doing a bridge, you probably want to set the BPF flag so you don't loop any packets. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Principal Research Scientist, McAfee Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1041031093534.48022B-100000>