[Winpcap-users] Losing link hangs the application

Eli Iser eli.iser at gmail.com
Tue Feb 20 20:04:15 GMT 2007


Hello,

I'm developing a router application on Windows XP using Packet32 from
WinPCap version 3.1. I know I should use WinPCap, but I prefer the simpler
interface of Packet32, as I do every aspect of the application myself.

The application basicly has two threads: one reads packets from NIC A,
checks in the routing table and then sends via NIC B. The other thread reads
packets from NIC B and routes them via NIC A. Answering ARP requests and
receiving ARP replies is a case where I have cross-thread access, so the
sending of the packets is protected with a mutex for every NIC.

The problem I have is thus: when I pull the ethernet cable from NIC A I
obviously lose the packets from it, but sometimes (quite reproducable,
though not predictable) my entire application threads hang until I plug the
cable back, restoring link to the adapter. I examined the state of both
threads and it seems that both threads are accessing the same adapter, which
I've unplugged. In one occasion one thread is writing to the adapter and the
other is reading from it. In another case one thread is writing while the
other is getting statistics from it.

At first I was sure that this was because I modified the Packet32 code to
use Overlapped IO, but I than reverted back to the original code and the
problem still happens.

Maybe I'm doing something wrong? How well does the Packet32 code handle
multithreaded access?
I'll be glad for any help and suggestions.

As a side note, I'd rather try and figure out the problem before moving my
code to use WinPCap 4 (if indeed it is a know bug of 3.1), since I've been
developing the app for quite some time, and wouldn't like to retest all of
it again.

Thank you,
Eli Iser
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070220/c27b55d4/attachment.htm


More information about the Winpcap-users mailing list