[Winpcap-users] WinPcap and Netork Line Tap

Bryan Kadzban bryan at kadzban.is-a-geek.net
Sun Aug 12 18:29:26 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Buffalo Bob wrote:
> Does anyone have any suggestions on how to guarantee that my 
> application will receive the packets in the correct order ?

Don't use Ethernet?

Ethernet is not guaranteed to preserve the order of frames relative to
each other (at least, I don't think -- I know IP is not guaranteed to do
that, so I'm fairly sure Ethernet isn't either).  The only way you can
get what you want is to have that guarantee from the network protocol.
If you don't have the guarantee from the network protocol, then any
device on the network can re-order the frames on you.

I'd guess that the tap device is probably re-ordering the frames itself,
just because it knows it can -- any higher-level protocol that requires
order to be preserved will have its own method of doing that (e.g. TCP's
sequence numbers).  But even if it's not the tap, it could be the
switch, or the network stack on the other end.

Plus, you have two different threads -- if you get a request on one
thread, but a response on the other, then there's no way to enforce the
ordering between the two threads.  (But maybe that setup can't happen.)

Anyway, you will very likely need something other than Ethernet.  As I
suspect that's not possible for you, I also suspect that your intended
behavior can't be achieved.

But why not add the requests/responses to a list, and signal a third
thread?  That thread could keep its own list of which responses have
shown up without seeing a request, and wait for the corresponding
request on its own.  (With an eventual timeout.)  When it gets a request
and its matching response, it can do the processing.  It'd be a fairly
simple producer/consumer setup, and assuming the processing doesn't take
too long, I think it should work fine.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGv1GES5vET1Wea5wRAwSYAJ9A7UThYAW9F9spQwsIaE6aPpR89wCfWTFz
DohYMWNCEvXmSTGaRIx2/IA=
=OtAZ
-----END PGP SIGNATURE-----


More information about the Winpcap-users mailing list