tcpdump mailing list archives

Re: libpcap & poll()


From: Eloy Paris <peloy () chapus net>
Date: Thu, 13 Nov 2008 18:14:51 -0500

Hi Aaron,

On Thu, Nov 13, 2008 at 02:32:21PM -0800, Aaron Turner wrote:

[...]

basically:

int keep_processing = 1;

pcap_setnonblock(pcap1, 1, errbuf);
pcap_setnonblock(pcap2, 1, errbuf);
do {
   pcap_dispatch(pcap1, -1, &callback, &keep_processing);
   pcap_dispatch(pcap2, -1, &callback, &keep_processing);
} while(keep_processing);

This will definitely yield high CPU utilization

I would of assumed that using poll() would be more efficient since the
code effectively blocks until a packet arrives rather then looping
constantly even when idle.

You're assumption is correct. I think you're on the right path with poll(); just do some troubleshooting to see what's 
causing the high CPU.

Cheers,

Eloy Paris.-
netexpect.org
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: