i am experiencing the following situation:
I open with pcap_open_live()
one of my network-interfaces. Then i am compiling a filter for pcap for only capturing a specified ethernet-type (ether proto 0x1234
). Now i am starting the pcap_loop()
. The only thing, that the callback-function executes, is to send a frame via pcap_inject()
. (The frame is hard-coded as a global char array).
When i compare now the timestamps of the received and the sent frame (e.g. on wireshark on a third non-involved computer) the delay is around 3 milliseconds (minumum 1 millisecond, but also up to 10 milliseconds). So pcap needs in average around 3 milliseconds to proceed with the received frame and calling the callback-function for sending the new frame. I want/have to decrease that delay.
Following things i already tried:
- tried all different variants of read-timout (in ms) in
pcap_open_live()
: even a read-timout of -1, which should be to my knowledge a polling, generates a delay of around 3 milliseconds - setting no filter
- setting a higher priority to process
- set
InterrupThrottleRate=0
and other parameters of thee1000
/e1000e
-kernel module to force the hardware sending an interrupt for every single frame
But i never decreased the delay under the average of 3 milliseconds.
For my planned application it is necessary to react to incoming packets in a time unter 100 microseconds. Is this even generally doable with libpcap?! Or are there any other suggestions for realizing such a application?
Thanks for all your replies, i hope anyone can help me!
Notes: I am deploying under Linux/Ubuntu in C/C++.