Open DraAngel opened 4 months ago
npcap version:1.79 npcap-sdk version:1.13
How many dropped packets does pcap_stats()
report in ps_drop
?
Should I write fetch ps_drop in the timeout branch
Should I write fetch ps_drop in the timeout branch
Since your capture loop seems not to ever exit, the right place to try it might be to, every N packets, for some value of N, call pcap_stats()
and, if ps_drop
is non-zero, print its current value as a count of dropped packets.
Well. I tried to get ps_drop every 15678 packets, and the results seemed a little hard to understand. The code looks like this:
srcIndex = uh->index;
if (srcIndex % 15678 == 0)
{
int size;
pcap_stat* stat = pcap_stats_ex(adhandle, &size);
printf("drop num: %d\n", stat->ps_drop);
}
The results show that most of the packets are lost.
I set the buffer size and the packet buffer timeout, and now I can fetch all the packets! Thank you for your help, Sir.
Another question, if I want to use Npcap to reliably transfer 1 gigabit data to another device in the LAN in the shortest possible time, is there any good advice?
Now, I set the buffer size to 2*1024*1024*1024
(which seems to be the maximum for an int), the packet buffer timeout to 1000
, and the ps_drop
to end up being 0. As I scale up the number of packets to 2M, ps_drop
starts to become nonzero during reads. However, the number of packets monitored by Wireshark was as expected. Am I setting my parameters wrong or missing some configuration items?
I packed 200,000 packets using pcap_sendqueue_queue with a sequence number field added to the packet. Then I use pcap_sendqueue_transmit to send it to another computer in the local area network. The log message printed shows that there were no abnormalities in the delivery process, and the monitoring results in Wiresshark show that the packets were sent normally. send log:
Wireshark:
![screen](https://github.com/nmap/npcap/assets/42402599/513c347b-2be5-4496-93b9-ec2cf79eda4a)
Then I use pcap_next_ex to fetch the packet from the local adapter, filter it according to the ip information it was sent, and print the sequence number information in the packet.However, after sorting through the printed information, I found that the packet sequence number was sometimes lost in the middle or at the end. receive log:![log2](https://github.com/nmap/npcap/assets/42402599/8bd10730-55f0-42a2-8b5a-afc731cad4bc)
The following is part of the sending and receiving code, is there something wrong with my code? send:
if ((res = pcap_sendqueue_transmit(outdesc, squeue, sync)) < squeue->len){ printf("An error occurred sending the packets: %s."" Only %d bytes were sent\n", pcap_geterr(outdesc), res); } printf("\nTotal packets generated = %d", npacks);
listenToPcap: