PCAP_STATS(3PCAP)
π
PCAP_STATS β okay so this is from the PCAP_STATS(3PCAP) manual, bestie
β¨ NAME β¨
pcap_stats β get capture statistics π
πΈ SYNOPSIS πΈ
#include <pcap/pcap.h>
int pcap_stats(pcap_t *p, struct pcap_stat *ps);
π¦ DESCRIPTION π¦
So pcap_stats() fills in the struct pcap_stat that your second argument points at. The values are packet statistics covering from the start of the run all the way to the time of the call. Slay, a full timeline. β¨
Heads up:pcap_stats()is supported only on live captures, not onsavefiles''. No statistics get stored insavefiles'' at all, so when you're reading from a ``savefile'' there's literally nothing available. Not even crumbs. π
A struct pcap_stat has these members, periodt:
ps_recvβ number of packets received π«Άps_dropβ number of packets dropped because there was no room in the operating system's buffer when they arrived, because packets weren't being read fast enough. she was too booked and busy πps_ifdropβ number of packets dropped by the network interface or its driver
The statistics do not behave the same way on all platforms, and this is the part where it gets messy, ngl:
ps_recvmight count packets whether they passed any filter set withpcap_setfilter(3PCAP)or not β or it might count only packets that pass the filter. Both are on the table. π- It also might, or might not, count packets dropped because there was no room in the operating system's buffer when they arrived.
ps_dropis not available on all platforms; it's zero on platforms where it's not available.- If packet filtering is done in libpcap, rather than in the operating system, it would count packets that don't pass the filter.
- Both
ps_recvandps_dropmight, or might not, count packets not yet read from the operating system and thus not yet seen by the application. ps_ifdropmight, or might not, be implemented. If it's zero, that might mean that no packets were dropped by the interface β or it might mean that the statistic is unavailable. So please please please do not treat it as an indication that the interface did not drop any packets. it's giving "zero could mean anything" π
π₯ RETURN VALUE π₯
pcap_stats() returns 0 on success π, PCAP_ERROR_NOT_ACTIVATED if you called it on a capture handle that has been created but not activated, or PCAP_ERROR if there's another error or if p doesn't support packet statistics.
If PCAP_ERROR gets returned, you may call pcap_geterr(3PCAP) or pcap_perror(3PCAP) with p as an argument to fetch or display the error text. icon behaviour, honestly π
π SEE ALSO π
pcap(3PCAP)
okay that's the whole page, bestie β much love from the PCAP_STATS(3PCAP) girlies, dated 5 March 2022 ππβ¨
π¦ where this page comes from
- alpine 3.22: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.23: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.24: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- centos-stream 10: libpcap-devel 14:1.10.4-8.el10 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- debian bookworm: libpcap0.8-dev 1.10.3-1
- debian trixie: libpcap0.8-dev 1.10.5-2
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- nixos 26.05: libpcap 1.10.7
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3.1
- ubuntu questing: libpcap0.8-dev 1.10.5-2ubuntu2
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1 Β· BSD-3-clause-var3
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1.1 Β· BSD-3-clause-var3
- ubuntu stonking: libpcap0.8-dev 1.10.7-1ubuntu1 Β· BSD-3-clause-var3
- Copyright (c) 1994, 1996, 1997 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms