1PCAP_STATS(3PCAP)                                            PCAP_STATS(3PCAP)
2
3
4

NAME

6       pcap_stats - get capture statistics
7

SYNOPSIS

9       #include <pcap/pcap.h>
10
11       int pcap_stats(pcap_t *p, struct pcap_stat *ps);
12

DESCRIPTION

14       pcap_stats() fills in the struct pcap_stat pointed to by its second ar‐
15       gument.  The values represent packet statistics from the start  of  the
16       run to the time of the call.
17
18       pcap_stats()  is supported only on live captures, not on ``savefiles'';
19       no statistics are stored in ``savefiles'', so no statistics are  avail‐
20       able when reading from a ``savefile''.
21
22       A struct pcap_stat has the following members:
23
24              ps_recv
25                     number of packets received;
26
27              ps_drop
28                     number  of  packets  dropped because there was no room in
29                     the operating system's buffer when they arrived,  because
30                     packets weren't being read fast enough;
31
32              ps_ifdrop
33                     number of packets dropped by the network interface or its
34                     driver.
35
36       The statistics do not behave the same way on  all  platforms.   ps_recv
37       might  count  packets whether they passed any filter set with pcap_set‐
38       filter(3PCAP) or not, or it might count only packets that pass the fil‐
39       ter.   It also might, or might not, count packets dropped because there
40       was no room  in  the  operating  system's  buffer  when  they  arrived.
41       ps_drop  is  not  available  on  all platforms; it is zero on platforms
42       where it's not available.  If packet  filtering  is  done  in  libpcap,
43       rather  than in the operating system, it would count packets that don't
44       pass the filter.  Both ps_recv and ps_drop might, or might  not,  count
45       packets not yet read from the operating system and thus not yet seen by
46       the application.  ps_ifdrop might, or might  not,  be  implemented;  if
47       it's  zero,  that might mean that no packets were dropped by the inter‐
48       face, or it might mean that the statistic is unavailable, so it  should
49       not  be  treated  as  an indication that the interface did not drop any
50       packets.
51

RETURN VALUE

53       pcap_stats() returns 0 on success, PCAP_ERROR_NOT_ACTIVATED  if  called
54       on  a  capture  handle  that  has  been  created  but not activated, or
55       PCAP_ERROR if there is another error or if  p  doesn't  support  packet
56       statistics.  If PCAP_ERROR is returned, pcap_geterr(3PCAP) or pcap_per‐
57       ror(3PCAP) may be called with p as an argument to fetch or display  the
58       error text.
59

SEE ALSO

61       pcap(3PCAP)
62
63
64
65                                 5 March 2022                PCAP_STATS(3PCAP)
Impressum