title: libpcap: Delay between receiving frames and call of callback-function
body: <p>i am experiencing the following situation:
  I open with <code>pcap_open_live()</code> one of my network-interfaces. Then i am compiling a filter for pcap for only capturing a specified ethernet-type (<code>ether proto 0x1234</code>). Now i am starting the <code>pcap_loop()</code>. The only thing, that the callback-function executes, is to send a frame via <code>pcap_inject()</code>. (The frame is hard-coded as a global char array).</p>
  
  <p>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.</p>
  
  <p>Following things i already tried:</p>
  
  <ul>
  <li>tried all different variants of <em>read-timout (in ms)</em> in <code>pcap_open_live()</code>: even a read-timout of -1, which should be to my knowledge a polling, generates a delay of around 3 milliseconds</li>
  <li>setting no filter</li>
  <li>setting a higher priority to process</li>
  <li>set <code>InterrupThrottleRate=0</code> and other parameters of the <code>e1000</code>/<code>e1000e</code>-kernel module to force the hardware sending an interrupt for every single frame</li>
  </ul>
  
  <p>But i never decreased the delay under the average of 3 milliseconds.</p>
  
  <p>For my planned application it is necessary to react to incoming packets in a time unter <strong><em>100 microseconds</em></strong>.
  Is this even generally doable with libpcap?! Or are there any other suggestions for realizing such a application?</p>
  
  <p>Thanks for all your replies,
  i hope anyone can help me!</p>
  
  <p><em>Notes</em>: I am deploying under Linux/Ubuntu in C/C++.</p>