[HELP] sendto:No buffer space available

John Baldwin jhb at freebsd.org
Fri May 27 12:02:38 UTC 2011


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<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
> 
> 
options=c3198<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MCAST,WOL_MAGIC,VLAN_HWTSO,LINKSTATE>
>     ether xxxxxxxxxxxx
>     media: Ethernet autoselect
> fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
> 
> 
options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
>     ether xxxxxxxxxxx
>     inet xxxxxx netmask 0xffffff00 broadcast xxxxxxxx
>     media: Ethernet autoselect (100baseTX <full-duplex>)
>     status: active
> plip0: flags=8851<UP,POINTOPOINT,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu
> 1500
> lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
>     options=3<RXCSUM,TXCSUM>
>     inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
>     inet6 ::1 prefixlen 128
>     inet 127.0.0.1 netmask 0xff000000
>     nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
> 
> 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


More information about the freebsd-net mailing list