I'm trying to test the maximum throughput of wireless device(s) using a TUN interface and I'd like to avoid overflowing the send buffer, which will cause packets to be dropped before they actually reach the device. So ideally I'd like to query the send buffer using TIOCOUTQ to make sure that there's always data in the queue without overflowing it. I created a simple test shown below.
int i, sr, buff_stat;
for(i=0; i<1000; i++){
sr = sendto(sock, message, sizeof(message), 0, &addr, sizeof(addr));
ioctl(sock, TIOCOUTQ, &buff_stat);
printf("buffer status: %i\n", buff_stat);
}
If sock was created such that it will be routed through the standard Ethernet device the output is non-zero, but if it was created such that it will be routed through the TUN interface the output is all zeros. In this case there was no process consuming the data so I would think the buffer would just fill up. I get the same behavior in my actual application, where I do have a process consuming the data.
So I'm wondering if I'm right in concluding that TIOCOUTQ simply does not work with TUN interfaces and if there might be some other way to determine the send buffer status.