Hello Jose,
Thank you so much for a great report!
It took me some time to check and test everything; please read my comments below.
You expect pcap dumps captured with ioninja-hwc
and with tcpdump
to be exactly the same. Actually, that's not guaranteed. Ethernet Tap does not "pause" forwarding of Ethernet frames from one port to the other if the Cypress USB buffer is full -- that's in line with how other taps for IO Ninja work (they don't even "forward" data and are simply connected to the existing lines instead). The buffer on the Ethernet Tap itself is very small (as it has no RAM/flash), so if the software is not fast enough to read the captured data -- data will be lost).
The packet loss ratio you experienced with ioninja-hwc
is, of course, not acceptable. The original version of ioninja-hwc
was doing the initiating of USB read transfers, parsing the input from the Tap and writing it to the output file (a pipe to Wireshark, in your case) all in one thread. So if somewhere along the way any delay happens, then new USB reads are not scheduled, the Cypress USB buffer on the Ethernet Tap gets full, and the packets are lost.
I rewrote ioninja-hwc
so that scheduling of USB reads is now done in a dedicated thread, so any blocking waits during writing to the output file/pipe should not prevent new USB reads from being scheduled. Also, it's now directly controllable how many simultaneous USB read transfers are passed to the bus driver (as well as buffer sizes for those).
Please try this build:
https://tibbo.com/downloads/archive/ioninja/.internal/ioninja-hwc-test.tar.xz
Controlling the buffer sizes and read parellelism is done via --read-parallelism
and --read-block-size
command line parameters. It also generates a log of overflows in %HOME%/ioninja-hwc-log.txt
Still, this can't completely prevent packet loss -- Linux/Windows/macOS are not realtime OSes, and at 10+ MBytes per second, any delay could result in an overflow of the (rather tiny) buffer on the Ethernet Tap. Considering this, it's recommended to connect Ethernet Tap to a fast host to minimize packet loss.
The ultimate solution should include some RAM/SD/eMMC on the Ethernet Tap to store captured packets.
Besides packet loss, there's a bigger problem.
Under some conditions during heavy load, the FPGA firmware could send garbaged data over USB (not only the packet contents, but the USB protocol headers could suffer as well). Luckily -- or, maybe, unfortunately (because it essentially hid the problem) -- our USB protocol is designed in a way so that it recovers and re-synchronizes almost instantly, so this problem remained unnoticed. But yes, I was able to reproduce the issue. Data corruption over a bulk USB endpoint is not acceptable and should never happen. Our FPGA developer is investigating the issue at the moment. Hopefully, we will have a firmware patch for this soon.
Once again, thank you for reporting the issue in great detail; I'll keep you posted.