tcpdump mailing list archives
Re: Packet arrival order
From: "roy hills" <royhills () hotmail com>
Date: Tue, 03 Apr 2007 16:57:27 +0100
> I'll need to check on how select() is behaving, but it is working, and > I'm only calling pcap_dispatch() if select() indicates that the pcap > fd is readable. Yeah, that's what I do too. However, if I remember correctly, I found out that select() was not blocking (as it should) when there was no data available, so I have a bit of extra CPU work. To test whether this is happening to you as well you can just put a printf() right after select()
I've done that. What I find is that select() returns when there is any data received on the network interface; not just data that will match the pcap filter. In other words, just because select() returned indicating that the pcap file descriptor was ready to read does not mean that there is interesting data. I think this is because the DLPI implementation filters in userspace, not in the kernel, unlike BPF and Linux.
> but I then had to alter the code for BSD (BPF) to prevent buffering You mean setting BIOCIMMEDIATE on the BSDs, right?
Yes, that's what I do for BSD/BPF.
> and work around select() issue, Would this be the issue of select() returning "there's data available to be read" only once? In other words, new data arrives and select() returns "there's data available". However, if more data arrives before you've read the data that was previously available, next time you call select() it won't tell you that there's data available.
It's that on some BPF implementations, the pcap file descriptor is not selectable, so select() will always time out. To work around this, I call pcap_dispatch() after select times out for BSD platforms. I use select() as both a timing loop for sending packets and also to see when something is waiting, so this works OK for my application because my timeout is only a few milliseconds. Roy _________________________________________________________________Match.com - Click Here To Find Singles In Your Area Today! http://msnuk.match.com/
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Packet arrival order Ury Segal (Apr 02)
- Re: Packet arrival order roy hills (Apr 03)
- Re: Packet arrival order Eloy Paris (Apr 03)
- Re: Packet arrival order roy hills (Apr 03)
- Re: Packet arrival order Eloy Paris (Apr 03)
- Re: Packet arrival order roy hills (Apr 03)
- Re: Packet arrival order Eloy Paris (Apr 03)
- Re: Packet arrival order Eloy Paris (Apr 03)
- Re: Packet arrival order roy hills (Apr 03)
- Re: Packet arrival order Eloy Paris (Apr 03)