[Winpcap-users] How to receive extended statistics from pcap_stats_ex

Guy Harris guy at alum.mit.edu
Tue Aug 7 17:01:05 GMT 2007


Mark Bednarczyk wrote:

> But there is also a very lengthy pcap_stat_ex definition with 24 fields in
> it:
> 
> #ifdef MSDOS
> /*
>  * As returned by the pcap_stats_ex()
>  */
> struct pcap_stat_ex {
>        u_long  rx_packets;        /* total packets received       */
>        u_long  tx_packets;        /* total packets transmitted    */
>        u_long  rx_bytes;          /* total bytes received         */
>        u_long  tx_bytes;          /* total bytes transmitted      */
>        u_long  rx_errors;         /* bad packets received         */
> ... [truncated]
> }
> #endif
> 
> I really need to understand this thoroughly before I can put this call into
> my java API. Can someone explain to me when the extended information becomes
> available

It becomes available if you're running on MS-DOS.

Windows - even Windows 9x - is *not* MS-DOS in this context.

pcap_stats_ex() was added to libpcap by Gisle Vanem when he added MS-DOS 
support.  It's MS-DOS-only; not only is it not supported in libpcap on 
Windows (which is called "WinPcap"), it's not supported in libpcap on 
any of the UN*X platforms libpcap supports, either.

Top-of-tree libpcap CVS doesn't have pcap_stat_ex() on UN*X or Windows, 
only in MS-DOS.  The WinPcap 4.1 beta documentation mentions a 
pcap_stat_ex() with a *different* function signature from the one in 
pcap-for-DOS; the code for that isn't in the libpcap source, so it's 
probably in one of the WinPcap source files outside of libpcap.

In any case, for the WinPcap version of pcap_stat_ex(), the structure is 
documented in

	http://www.winpcap.org/docs/docs_41b/html/structpcap__stat.html

and has only one extra field - bs_capt, which is the "number of packets 
that are accepted by the filter, that find place in the kernel buffer 
and therefore that actually reach the application."

Given that the jNetPcap site speaks of it as multi-platform, note that 
you would have to return a "not supported" error for pcap_stat_ex() on UN*X.


More information about the Winpcap-users mailing list