processed - people often get confused by the "received by filter" count,
as they might not realize that, in some systems, it counts packets that
were handed to the filter mechanism regardless of whether they pass or,
if they pass, they have yet been read by the application and, on some
other systems, it counts packets that passed the filter but still counts
them in the kernel before they're read by the application.
They're probably mostly interested in the count of packets processed by
tcpdump; the "received by filter" count is probably of interest only if
you want to know how effective your filter is (and even then it's of
interest only if it counts packets handed to the filter rather than
packets that passed the filter).
Give more details on why the "received by filter" count doesn't
necessarily mean what you think it means.
.I tcpdump
finishes capturing packets, it will report counts of:
.IP
.I tcpdump
finishes capturing packets, it will report counts of:
.IP
+packets ``captured'' (this is the number of packets that
+.I tcpdump
+has received and processed);
+.IP
packets ``received by filter'' (the meaning of this depends on the OS on
which you're running
.IR tcpdump ,
and possibly on the way the OS was configured - if a filter was
specified on the command line, on some OSes it counts packets regardless
packets ``received by filter'' (the meaning of this depends on the OS on
which you're running
.IR tcpdump ,
and possibly on the way the OS was configured - if a filter was
specified on the command line, on some OSes it counts packets regardless
-of whether they were matched by the filter expression, and on other OSes
-it counts only packets that were matched by the filter expression and
-were processed by
+of whether they were matched by the filter expression and, even if they
+were matched by the filter expression, regardless of whether
+.I tcpdump
+has read and processed them yet, on other OSes it counts only packets that were
+matched by the filter expression regardless of whether
+.I tcpdump
+has read and processed them yet, and on other OSes it counts only
+packets that were matched by the filter expression and were processed by
.IR tcpdump );
.IP
packets ``dropped by kernel'' (this is the number of packets that were
.IR tcpdump );
.IP
packets ``dropped by kernel'' (this is the number of packets that were
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.214 2003-08-08 09:47:45 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.215 2003-09-16 21:02:52 guy Exp $ (LBL)";
#endif
static void info(int);
#endif
static void info(int);
+static u_int packets_captured;
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
if (!verbose)
fprintf(stderr, "%s: ", program_name);
if (!verbose)
fprintf(stderr, "%s: ", program_name);
+ (void)fprintf(stderr, "%u packets captured", packets_captured);
+ if (!verbose)
+ fputs(", ", stderr);
+ else
+ putc('\n', stderr);
(void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
if (!verbose)
fputs(", ", stderr);
(void)fprintf(stderr, "%d packets received by filter", stat.ps_recv);
if (!verbose)
fputs(", ", stderr);
static uint cnt = 2;
char *name;
static uint cnt = 2;
char *name;
++infodelay;
dump_info = (struct dump_info *)user;
++infodelay;
dump_info = (struct dump_info *)user;
static void
dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
static void
dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
++infodelay;
pcap_dump(user, h, sp);
++infodelay;
pcap_dump(user, h, sp);
struct print_info *print_info;
u_int hdrlen;
struct print_info *print_info;
u_int hdrlen;
++infodelay;
ts_print(&h->ts);
++infodelay;
ts_print(&h->ts);