[Winpcap-users] Multithreaded programming with WinPCap

Prachyabrued Mores mxp4758 at louisiana.edu
Sun Apr 30 05:06:41 GMT 2006


Hello!

> 
> Note that setting the timeout to -1 essentially switches your 
> architecture to polling, which is efficient but wastes a lot of CPU. 
> You may try to set a very small timeout and see if things are still 
> good, this would make you program much more efficient.
> 
I actually tried setting timeout to 1 (before i found out about -1 value), 
and the throughput obtained was 10Mbps vs 55 Mbps (in case of -1). So i 
think i should stick with -1. 

> > Btw, i still need an answer to this questions,
> > 
> > 1. Can i access the same descriptor in different thread without 
> > synchronization?
> 
> Accessing any kind of handle or descriptor from different threads 
> without solid synchronization is evil.
I tried it out already. My program was still functioning correctly but the 
throughput was dropped to about 20-30 Mbps. Do you have any explanation for 
this? Anyway, i will just stick with my two threads approach. Just curious.

> 
> > 2. Since i am implementing (application level) router queue using 
WinPCap, i 
> > wonder if there is any underlying system queue used by WinPCap? Is it 
> > possible for packet to be dropped by WinPCap before reaching my app?
> 
> WinPcap has a kernel buffer, whose size can be changed with the 
> pcap_setbuff() function.
> if with "Is it possible for packet to be dropped" you mean "does 
> winpcap have a filtering system", the answer is yes, give a look at 
http://www.winpcap.org/docs/docs31/html/group__wpcap__tut5.html
> 

I actually meant that my application is implementing application level 
queue/buffer. And would love to know that if it's possible for a packet to 
get dropped at a kernel, because of a buffer overflow, before reaching my 
application queue. Consulting a document for a setbuff function you 
mentioned, i think the answer is yes.

> > 3. If there is someone who has enough patience to read my first 
question. A 
> > suggestion or comment to improve my program will be very welcome.!
> 
> Decrease mintocopy. This benefits pure performance at the cost of 
> higher CPU load, like decreasing the timeout.
> 
> Loris
>
This function looks interesting, maybe i can squeeze some more performance 
from this function. Thank you very much for all of your answers! I really 
help.

Mark





More information about the Winpcap-users mailing list