Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to interpret pcap_stats() returned values in case of npcap #644

Open
pstavirs opened this issue Oct 30, 2022 · 2 comments
Open

How to interpret pcap_stats() returned values in case of npcap #644

pstavirs opened this issue Oct 30, 2022 · 2 comments

Comments

@pstavirs
Copy link

pstavirs commented Oct 30, 2022

The libpcap pcap_stats man page says the values returned are platform dependent.

I was hoping the npcap pcap_stats man page will specify what the values mean in case of npcap - but this looks to be the same as the libpcap page.

Is there any information available on how to interpret these values? Also the extra values returned by pcap_stats_ex().

@pstavirs pstavirs changed the title How to interpret pcap_stats returned values in case of npcap How to interpret pcap_stats() returned values in case of npcap Oct 30, 2022
@pstavirs
Copy link
Author

From my testing, it seems pcap_stats_ex() returns -

  • ps_recv counts all packets received irrespective of whether it passes the capture filter or not
  • ps_capt counts packets passing the capture filter

Will update this comment as and when I get more info

@dmiller-nmap
Copy link
Contributor

Thanks for this suggestion. We will look into ways to improve our documentation. In the meantime, here is the definitive answer:

  • pcap_stats() returns a struct pcap_stat with the following members set:
    • ps_recv is a count of all packets on the interface that the Npcap driver has seen while this handle was open.
    • ps_drop is a count of all packets that passed the capture filter but could not be delivered because the kernel buffer was full. Additionally, this count may show packets that could not be delivered because a memory allocation failed, which may happen before the capture filter is applied. This is a rare situation, and the system would be generally unstable if resources dropped that low.
  • pcap_stats_ex() returns a struct pcap_stat with the same info as pcap_stats(), plus the following members:
    • ps_ifdrop is set if the driver returns it. Npcap and WinPcap before it set this to 0. The difference here is that pcap_stats() sets this to 0 in wpcap.dll, but pcap_stats_ex() passes through the value from the driver.
    • ps_capt is a count of packets passing the capture filter and not dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants