[Winpcap-users] Tips for a real-time (low latency) application?

Gianluca Varenni gianluca.varenni at cacetech.com
Thu Jun 15 23:45:02 GMT 2006


Richard,

all the ideas that you propose can make sense. What's missing from your mail 
is the maximum latency that you want to achieve (which basically means "what 
is the purpose of your app?").

Have a nice day
GV


----- Original Message ----- 
From: "Richard Hansen" <pcap-ri at scientician.org>
To: <winpcap-users at winpcap.org>
Sent: Thursday, June 15, 2006 3:31 PM
Subject: [Winpcap-users] Tips for a real-time (low latency) application?


> Hi all,
>
> I'm new to WinPcap/libpcap and have some questions on how to use WinPcap 
> for a low-latency app.  I'm willing to sacrifice some throughput and CPU 
> usage to improve latency.
>
> I can think of three ways to minimize latency, and I have a bunch of 
> questions related to them:
>
> 1.  Use pcap_setmintocopy() to improve real-time responsiveness.  Is there 
> a practical limit to how low I can set this?  Would it be bad to set it to 
> 0?  Also, is there a libpcap equivalent to this?
>
> 2.  Make sure pcap_next() returns the instant a packet is available.  I'm 
> somewhat confused about how to_ms affects how pcap_next() returns.  Does 
> it return immediately if a packet is available?  Or is it possible for 
> pcap_next() to wait up to to_ms even if a packet is immediately available? 
> Is this affected by pcap_setmintocopy()?
>    What I would like is a function that returns a packet immediately if 
> one is available, otherwise it will wait up to a specified amount of time 
> for a packet to arrive (and will return the instant a packet arrives). 
> And -- if at all possible -- I would like it to work on multiple platforms 
> (especially Linux and BSD).  Is this possible?  I am currently setting 
> pcap to non-blocking mode and doing a tight poll, but that pegs the CPU.
>
> 3.  Mess with the kernel queue behavior.  It would be nifty if the kernel 
> buffer was a head-drop FIFO queue that automatically dropped packets older 
> than a specified cutoff age.  This way I wouldn't waste time copying stale 
> packets into userspace.  Is this possible without messing with the WinPcap 
> source code?  How does WinPcap's kernel buffer behave?  How does libpcap 
> behave?
>
> Any other suggestions for improving latency would be much appreciated.
>
> Thank you!
>
> Richard
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users 



More information about the Winpcap-users mailing list