get the IFLA_STATS attribute (rx/tx byte counters) for a specific interface

Jan-Philip gehrcke jgehrcke at googlemail.com
Fri Feb 25 11:17:50 EST 2011


Hello,

currently, I'm trying to create a bandwidth measurement program for my
Linux router in C. Obviously, for calculating a bandwidth, you need a
time and byte count difference. Due to performance reasons, I would like
to get the byte counters directly from the kernel, without reading from
/proc oder /sys. Therefore, I'm working myself through the 'ip' program,
gathering this data via rtnetlink using libnetlink. While searching the
web to understand more of this topic, I came across libnl which seems to
be a cleaner and more modern implementation. However, I'm a bit
overwhelmed by the documentation.

Assume I know the interface index of the interface I want to evaluate.
Then, what is the cleanest way to use libnl to receive the corresponding
IFLA_STATS attribute [1] containing the byte counters? I would
appreciate any guidance/suggestion that helps me orienting in libnl :-)

Thank you,

Jan-Philip Gehrcke

[1] http://linux.die.net/man/7/rtnetlink

--
http://gehrcke.de



More information about the libnl mailing list