From owner-freebsd-net@FreeBSD.ORG Fri May 27 12:02:38 2011 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 B18DB106568D for ; Fri, 27 May 2011 12:02:38 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 723598FC29 for ; Fri, 27 May 2011 12:02:38 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 0A90F46B2D; Fri, 27 May 2011 08:02:38 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A009D8A050; Fri, 27 May 2011 08:02:37 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Date: Fri, 27 May 2011 07:45:19 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201105270745.19869.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Fri, 27 May 2011 08:02:37 -0400 (EDT) Cc: linux JHON Subject: Re: [HELP] sendto:No buffer space available 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: Fri, 27 May 2011 12:02:38 -0000 On Friday, May 27, 2011 4:26:35 am linux JHON wrote: > My machine has two net interface cards, fxp0 and acl0, but acl0 is down, > only fxp0 is working. > > When I send raw packets through fxp0, it gives the error: sendto: No buffer > space available. > > I have googled, but I found no answer. The netstat -m result is: > > 67/1223/1290 mbufs in use (current/cache/total) > 64/340/404/25600 mbuf clusters in use (current/cache/total/max) > 64/320 mbuf+clusters out of packet secondary zone in use (current/cache) > 0/167/167/12800 4k (page size) jumbo clusters in use > (current/cache/total/max) > 0/0/0/6400 9k jumbo clusters in use (current/cache/total/max) > 0/0/0/3200 16k jumbo clusters in use (current/cache/total/max) > 144K/1653K/1798K bytes allocated to network (current/cache/total) > 0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters) > 0/0/0 requests for jumbo clusters denied (4k/9k/16k) > 0/5/6656 sfbufs in use (current/peak/max) > 0 requests for sfbufs denied > 0 requests for sfbufs delayed > 0 requests for I/O initiated by sendfile > 0 calls to protocol drain routines > > And the ifconfig gives that: > > alc0: flags=8802 metric 0 mtu 1500 > > options=c3198 > ether xxxxxxxxxxxx > media: Ethernet autoselect > fxp0: flags=8843 metric 0 mtu 1500 > > options=4219b > ether xxxxxxxxxxx > inet xxxxxx netmask 0xffffff00 broadcast xxxxxxxx > media: Ethernet autoselect (100baseTX ) > status: active > plip0: flags=8851 metric 0 mtu > 1500 > lo0: flags=8049 metric 0 mtu 16384 > options=3 > inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4 > inet6 ::1 prefixlen 128 > inet 127.0.0.1 netmask 0xff000000 > nd6 options=3 > > The core code of sending packets is as follows: > > while (num_of_tries-- > 0) > { > if (sendto > (s, datagram, iph->ip_len, 0, (struct sockaddr *) &servaddr, > sizeof (servaddr)) < 0) > { > fprintf (stderr, "Error in sendto:%s\n", strerror(errno)); > exit (1); > } > else > { > /*usleep(30);*/ > if (ft == 0) > { > fprintf (stderr, > > "[****************]\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); > ft = 1; > } > > if ((numtries % modval) == 0) > fprintf (stderr, "."); > > } > } > > When I uncomment the sentence: usleep(30), the error disapears. But I want > to send packets in high speed, what should I do? > > Btw, the packets are raw packets. So I thought maybe the kernel send some > packets to the net interface card alc0 which doesn't work. No, it is sending them all to fxp0, you are just giving it packets faster than it can transmit them. fxp is just a 10/100 device and a system with a modern CPU running your program should be able to swamp a 100mbits line rather easily. -- John Baldwin