From owner-freebsd-net@FreeBSD.ORG Thu May 12 03:00:36 2005 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 5F8CC16A4CE for ; Thu, 12 May 2005 03:00:36 +0000 (GMT) Received: from pi.codefab.com (pi.codefab.com [199.103.21.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id D15CF43D78 for ; Thu, 12 May 2005 03:00:35 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from localhost (localhost [127.0.0.1]) by pi.codefab.com (Postfix) with ESMTP id 3FA7B5E5E; Wed, 11 May 2005 23:00:35 -0400 (EDT) Received: from pi.codefab.com ([127.0.0.1]) by localhost (pi.codefab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00466-03; Wed, 11 May 2005 23:00:32 -0400 (EDT) Received: from [192.168.1.3] (pool-68-161-53-96.ny325.east.verizon.net [68.161.53.96]) by pi.codefab.com (Postfix) with ESMTP id F2FB45E5C; Wed, 11 May 2005 23:00:31 -0400 (EDT) Message-ID: <4282C6C8.7010209@mac.com> Date: Wed, 11 May 2005 23:00:24 -0400 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Valencia References: <20050512021758.99519.qmail@web53905.mail.yahoo.com> In-Reply-To: <20050512021758.99519.qmail@web53905.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at codefab.com cc: freebsd-net@freebsd.org Subject: Re: sending MAC packets --- again 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: Thu, 12 May 2005 03:00:36 -0000 Daniel Valencia wrote: [ ...pcap delays... ] > Has anyone in this list had any experience with > libpcap over fbsd that can point me into the right > direction? Sure. Are you trying to use non-blocking mode of PCAP by any chance? I found that to be fairly busted on FreeBSD and would drop lots of packets, just as you've described. PCAP timeouts in blocking mode also seem to not work very well, in the sense that the timeout starts after the first packet is received. I've got a code snippet handy: /* This routine obtains a list of all of the network interfaces on the machine * for each interface found, check to see whether the interface is UP and * whether the user wants this interface to be used. If so, open the packet * capture interface and add this (struct interface) to IFL. */ void init_interfaces() { struct ifaddrs *if_ptr; char *name; u_int flags; struct interface *new; [ ... ] LIST_INIT(&IFL); if (getifaddrs(&ifap) == -1) { fatal(strerror(errno)); /*NOTREACHED*/ } /* iterate over the list of interfaces on the machine */ for (if_ptr = ifap; if_ptr; if_ptr = if_ptr->ifa_next) { name = if_ptr->ifa_name; flags = if_ptr->ifa_flags; /* check that the interface is UP before we try to use it */ if (!(flags & IFF_UP)) continue; switch (if_ptr->ifa_addr->sa_family) { case AF_INET: /* check whether the user specified this interface */ if (check_interface(name)) { new = calloc(1, sizeof(struct interface)); if (!new) fatal("can't calloc() interface structure"); new->name = name; new->addr = (struct sockaddr_in *)if_ptr->ifa_addr; [ ... ] new->pcap_fd = pcap_open_live(name, CAPSIZE, 1, 50, errbuf); if (new->pcap_fd == 0) { logwarn("init_interfaces(): error calling pcap_open_live():\n"); fatal(errbuf); /*NOTREACHED*/ } #if 0 /* XXX: non-blocking mode seems to drop lots of packets, don't use */ if (pcap_setnonblock(new->pcap_fd, 1, errbuf) == -1) { loginfo("init_interfaces(): pcap_setnonblock failed!\n"); fatal(errbuf); } #endif [ ... ] -- -Chuck