From owner-freebsd-net@FreeBSD.ORG Sun Oct 31 08:27:05 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 313AF16A4CE for ; Sun, 31 Oct 2004 08:27:05 +0000 (GMT) Received: from web13009.mail.yahoo.com (web13009.mail.yahoo.com [216.136.172.90]) by mx1.FreeBSD.org (Postfix) with SMTP id E4D5D43D2D for ; Sun, 31 Oct 2004 08:27:04 +0000 (GMT) (envelope-from rosey_kc@yahoo.com) Message-ID: <20041031082704.30632.qmail@web13009.mail.yahoo.com> Received: from [202.70.91.5] by web13009.mail.yahoo.com via HTTP; Sun, 31 Oct 2004 01:27:04 PDT Date: Sun, 31 Oct 2004 01:27:04 -0700 (PDT) From: kamal kc To: freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Bridge--using Packet Capture Library(libpcap.a) -- efficiency ????? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2004 08:27:05 -0000 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 device descriptor--- ..... pcap_t *pd; pd = (pcap_t *)malloc(sizeof(*pd)); if (pd == NULL) { printf("memory allocation error"); } if((pd=pcap_open_live(device,BUFFSIZE,1,0,errbuf))==NULL) {printf("pcap_open_live: %s",errbuf); exit(1); }; v = 1; if (ioctl(pd->fd, BIOCIMMEDIATE, &v) < 0) { printf("can't set BIOCIMMEDIATE"); exit(1); } .................. Now the problem is efficiency !!! The RTT for a ping packet to traverse across the bridge takes a fastest of about 3ms when run as normal process and about 2ms when run as daemon. But when setting gateway_enable="YES" in rc.conf the RTT is less than 1 ms. (i.e. FreeBSD Box acting as bridge) I have FreeBSD 5.1 BOX. I used Packet Capture Library(libpcap.a) because I could find of none libraries in capturing packets that could return with the ethernet header. Further I could not find good usage maunal on BPF. In the above code setting the TIMEOUT value to 0 also didn't improve the time taken to capture and transmit the packets across the network. Each packet is processed by a separate thread that is envoked by the main thread listening on the packet capture handle. ++++++++++++++++ So finally Could anyone suggest a way on improving the time delay and making the bridge process packets faster with improved response time. Solutions using Packet Capture Library would be great !! Thanks in advance Kamal ++++++++++++++++++++ --------------------------------- Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish.