The pseudo code, which is implementing a stress test and trying to
measure the network performance based on different techniques to send data:
fd = open("/dev/bpf", O_RDWR);
if (fd == -1) {
perror("open");
return;
}
strlcpy(&ifr.ifr_name[0], "genet0", IFNAMSIZ);
if (ioctl(fd, BIOCSETIF, &ifr) == -1) {
perror("ioctl(BIOCSETIF)");
return;
}
unsigned int hdr_complete = 1;
if (ioctl(fd, BIOCSHDRCMPLT, &hdr_complete) == -1) {
perror("ioctl(BIOCSHDRCMPLT");
return;
}
for(;;) {
struct iovec *msg = get_packet(); // Creates a UDPv4 frame
if (writev(fd, msg, 2) == -1) {
if (errno == ENOBUFS) {
delay(750000);
continue;
}
perror("writev");
return;
}
}
This seems to be NetBSD specific, not observed on FreeBSD, QNX 7.1
(based on old NetBSD with their fixes).
Secondary problem: I couldn't find an effective way to handle ENOBUFS,
other than with a 750us delay (couldn't find how to handle this properly
to know when I should resend data).
Any hints on what I'm doing wrong is appreciated.
Regards,
Jason.