[Winpcap-users] Send packets while capturing
holger
hsteinhaus at gmx.de
Tue Feb 28 02:14:36 PST 2012
I am using Winpcap for an application, that needs to listen to the
network traffic continuously. While listening, some packets need to be
sent on a certain event with minimized delay.
Currently I am using the followin approach:
1. pcap_open_live (blocking=true, timeout=0)
2. pcap_dipatch(cnt=-1)
on event:
3. pcap_breakloop (from separate thread)
4. pcap_sendpacket (from original thread)
5. goto 2
Unfortunately, pcap_breakloop seems not to break the loop promptly. At
least in my test implementation on Windows XP (SP3, 32bit) I see a
random delay (5-15 sec) between pcap_breakloop and the return of
pcap_dispatch (return value is -2 as exepcted).
Any kind of timeout-controlled operation is not really desirable for my
kind of application, as this would introduce some systematic delays. Do
you see any strictly event-based alternative to sketched approach? What
about calling pcap_sendpacket in a separate thread during a running
pcap_dispatch? But I have a bad feeling about this idea...
Regards,
Holger
More information about the Winpcap-users
mailing list