title: Getting Linux interface traffic 64bit statistics in userspace
body: <p>I would like to get the NIC driver <strong>64bit statistics</strong> in <strong>userspace</strong>, in the simplest way possible.
  The man page of  API function getifaddrs(), suggests a simple example program that does it using 32bit "<strong>struct rtnl_link_stats</strong>" (possible to see it here for example: <a href="http://man7.org/linux/man-pages/man3/getifaddrs.3.html" rel="noreferrer">http://man7.org/linux/man-pages/man3/getifaddrs.3.html</a>).</p>
  
  <p>The problem with this struct is obvious: the 32bit variables wrap-around (exceed 2^32) quickly (e.g. "<strong>rx_bytes</strong>").</p>
  
  <p>In the same header file (<a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/if_link.h" rel="noreferrer">linux/if_link.h</a>) that contains <strong>struct rtnl_link_stats</strong>, there is a similar struct with 64bit variables: <strong>struct rtnl_link_stats64</strong>.
  I was sure that I'm very close to have the same statistics on 64bit variables, but unfortunately, I failed doing so.</p>
  
  <p>There are functions like <strong>dev_get_stats()</strong>, but they are all written for kernel-space.</p>
  
  <p>Programs like "<strong>ethtool -S</strong>" show these statistics in 64bit values, but I think they do some manipulation and not fill up <strong>struct rtnl_link_stats64</strong> in a simple way.</p>
  
  <p>Reading directly from <strong>/sys/class/net/ethX/statistics/rx_bytes</strong> (using fopen, fscanf...) is ok, but it doesn't perform as good as reading using API.</p>
  
  <p>Is there a simple way <strong>in userspace</strong> to have <strong>struct rtnl_link_stats64</strong> filled with the relevant statistics, that I miss?</p>