Blasting UDP traffic using iperf and ttcp

I've been trying to get iperf to blast UDP packets for 10 minutes on
a 1-Gbps link. However, iperf stops after a few seconds and complains
that it can't write to the socket because no buffer space is available.

'netstat -m' shows that there are lots of mbufs available. I modified
iperf source code to set the socket's send buffer to 200000 bytes (*)
but it didn't really help much. In another attempt, I modified iperf
source code such that it would not quit after failing to write to
the socket. However, this caused iperf to hang. I use iperf 1.7.0
and FreeBSD 4.5. The machine I am using has a 1-GHz CPU and 1 Gbytes
of memory. I could try to write my own program to blast UDP packets
but would prefer to use available software if possible.

The bottom line is that the current version of iperf (version 1.7.0)
doesn't have a good handle of error cases. If iperf's attempt to write
to an UDP socket fails, iperf would just quit. If you want to blast UDP
packets, you can use ttcp instead. And remember to set the receive buffer
size to a large number (e.g., sysctl -w net.inet.udp.recvspace=200000).

(*) Apparently, iperf doesn't have an option to set the socket buffer for
UDP sockets. And there seems to be a limit that doesn't allow to set a
larger buffer size than around 200000 bytes (this is not related to iperf
but FreeBSD in general).

I posted the message above on frebsd-net mailing list and got the following

Response 1:
I would use 1460 byte packets or so so there is no fragmentation. This means a send-size of 1460, and a receive buffer size of ~64K. iperf uses RTP to measure the latency and loss, stamping a timestamp and continuity counter on each packet, so just making it ignore errors may not be what you want.

Response 2:
The ENOBUFS you're getting is likely generated by IFQ_ENQUEUE() when the outgoing interface queue fills, as lossy datagram protocols will generally attempt to deliver straight to the interface and drop if there's no room. I believe this happens regardless of socket buffer size, hence your '*' below. What you probably want to do is use an interval timer to schedule sending packets at the rate you want to accomplish. Or, if you really just want to send as fast as you can, you can spin and ignore ENOBUFS. :-)

Long Le
Jun 23 10:01:25 EDT 2004