What do your network statistics say? ("netstat -e" and "netstat -s") Any errors or checksum issues?
No, there is no errors. But when packet drops starting, it shows that "Discards" value starts to grow very significantly. When there is no packet drop it shows "Discards" = 0. And "Errors" value still remains zero.
I'm not sure what "Discards" value means exactly. As I read
here it shows "The number of packets rejected by the NIC, perhaps because they were damaged".
But that packet drops issue appears when CPU load is above some threshold. When there is no CPU load, there is no packet drops. So this is definitely not damaged or malformed packets.
By the way, most of my speed tests with UDP I performed with
Alex Forencich verilog ethernet stack implementation, which seems pretty stable and tested for up to 10G and 25G speed.
Are you using jumbo frames, rather than the "safe minimum" of 548 bytes of user data? This will reduce the OS overhead a lot.
Hm... I didn't know about that "safe minimum" 548 bytes... Why 548 bytes?
I don't use jumbo frames, because it needs to enable it in network card properties. By default it is disabled on my driver. And as I remember when I enable it it affects network performance for a usual packets. So I'm using 1024+8 bytes packet, 1024 bytes for a data payload and 8 bytes for id and streaming control.
Are you maintaining the required interpacket gaps? 12 idle bytes between packets?
yes, 12 bytes gap. When I tried to reduce it, the network card just stops to accept the packets and as I remember I even don't see any packet in the Wireshark.
What are you doing when you get a packet? Could it be distracting the OS long enough to cause the NIC ring buffer to overrun?
Basically I send it to HDSDR program which performs FFT and further DSP processing. But for a cleaner test of network performance, I tried to receive data, check packet id and just drop it with no further processing. In both cases I have packet drops. So, it seems that data processing in HDSDR doesn't affect it much, the only note here is that data processing add some CPU load.
I tried two methods to receive the data:
1) using fixed buffer for socket recvfrom call, next I extract payload to another fixed buffer and send it to HDSDR. All this is done from the same thread with highest priority dedicated to the socket receive task.
2) using fixed buffer for socket recvfrom call, next I copy the packet content to another fixed buffer and enqueue it for processing in another thread which extracts data and sends it to HDSDR.
The first method has a smaller CPU load and less packet drops. Probably due to additional cost for a thread synchronization and queue processing.
Interesting thing is that change receive thread priority to normal sometimes can reduce packet drops. But when I added timeBeginPeriod(1) call it turns into opposite - highest priority helps to reduce packet drops.
Also I found that for some unknown reason, the packet drops are significantly reduced when I run receive process under debugger (MSVS), I have no idea why... When I thinking why it may happens I got the idea to try to change OS time slice with timeBeginPeriod. And it really helps to reduce packet drops very significantly. But as a side effect I got higher CPU load.
It seems that there is possible another some internal OS thread which is involved in a network card processing. So, playing with time slice interval and thread priority affects that hidden thread.