Question

I want to know the exact amount of data which is getting transferred through a particular network interface for logging purpose, is there any standard library or api call from which I can do this in a cross platfrom way?

Was it helpful?

Solution

SNMP4J will let you read the interface mib of any SNMP-compliant device. Linux and OSX (probably) have an SNMP daemon already running; Windows has an SNMP service that you can install though Programs and Features in Control Panel.

OTHER TIPS

This seems to do what you'd like. At least, I think it will point you in the right direction: http://jnetpcap.com/

edit: While not strictly cross-platform, libpcap has libraries for all major platforms so I wouldn't consider that a show-stopper, but I'm not the one that needs it.

jNetPcap uses Sigar in some of its unit tests. Sigar advertizes itself as a "portable interface for gathering system information" including network interface detection, configuration info and metrics. Take a look at its NetInterfaceStat class.

Note that Sigar also relies on platform specific JNIs, i.e. Rob H's remark still applies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top