libpcap timeout weirdness
libpcap timeout weirdness
- Subject: libpcap timeout weirdness
- From: Robert Monaghan <email@hidden>
- Date: Sun, 24 Mar 2013 13:00:34 +0100
Hi Everyone!
I am using the built in Libpcap library that comes with MacOSX.
I have set up a background GCD dispatch queue, where the libpcap is set up and waits for packets to arrive on my 10Gig card.
The code is very trivial, and "generally" works well, under specific conditions.
Here is the problem.
I am using "pcap_loop" to grab a specific number of packets. Lets call it "1000" for the sake of this email.
If I set up the pcap_loop command to do its work, I end up with a timeout being called. If I trim the number of packets by about 10%, then there is no timeout and everything moves along at lightning speed. (I know this is a timeout, because if I change the timeout value in "pcap_open_live", the timeout changes each time I make a change.)
Now I download another (smaller) set of data, this time 500 or so packets. This download starts to timeout, as well! (Even though the 900 or so, packet downloaded just fine!) If I trim it by about 10% it is extremely fast!
Weird.
Just for fun, I tried an really large data set, at 3000 packets. As expected it stalls. But again, trimming about 4 to 5 % removes the stall, and it moves the data extremely quickly.
If I use pcap_stats immediately after the pcap_loop, I see that in both fast and timed out situations, that I don't drop any packets.
The only issue seems to be that the timeout is triggered.
I am at a loss on this one. I have tried changing the 'snaplen' size, and altered the timeout, but i can't seem to see where the problem is.
I have the "pcap_loop" code in "blocking" mode, so that I can wait for all of the packets to finish, before triggering a semaphore.
This works if I trim the number of packets read, but slows down dramatically, if I do the full amount of packets requested.
Can anyone make a suggestion?
Thanks!
bob.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden