On Apr 24, 2013, at 11:20 AM, Gerald Combs <gerald@xxxxxxxxxxxxx> wrote:
> Polling the system's TCP and UDP connection tables is trivial but its
> usefulness is limited since it assumes that your interesting traffic has
> a corresponding table entry at the instant you poll. This may not be the
> case for short-lived connections such as DNS or DHCP and it certainly
> won't be the case for ICMP or non-IP protocols.
>
> System event tracing (e.g. Event Tracing for Windows, dtrace, or
> whatever happens to be popular on Linux this month) or Guy's suggestion
> of exposing process information through libpcap would be better, but
> neither are trivial.
Exposing it through libpcap requires a way to get it on the underlying OS, which, again, should involve watching for PCB (Process Control Block) creation and destruction rather than polling the tables if at all possible.
It would probably be best if the platform-dependent stuff were done in libpcap, if possible, so that it only has to be done in the library, not every application (libpcap's main role in life is to hide platform dependencies from applications, after all), but that wouldn't, by itself, let you get notified of the creation and destruction of PCBs.