title: In Android, how to measure the data traffic per interface per application
body: <p>I want to implement an extention to <code>android.net.TrafficStats</code> to measure the data traffic per APN or per APN per application. the methods prototype looks like:</p>
  
  <pre><code>getInterfaceTxPackets(String interface)
  getInterfaceRxPackets(String interface)
  getInterfaceTxBytes(String interface)
  getInterfaceRxBytes(String interface)
  getUidInterfaceTxPackets(int uid,String interface)
  getUidInterfaceRxPackets(int uid,String interface)
  getUidInterfaceTxBytes(int uid,String interface)
  getUidInterfaceRxBytes(int uid,String interface)
  </code></pre>
  
  <p>I read the <code>android.net.TrafficStats.java</code>, it call the native methods in <code>android_net_TrafficStats.cpp</code>, and the native methods read the traffic statistics from some files: </p>
  
  <ul>
  <li><p>the total traffic statistic files are in folder <code>/sys/class/net/</code>, in this folder there are some sub folders like: eth0, ip6tnl0, rmnet0, rmnet1, rmnet2, rmnet3., the detailed statistic files are saved in these folders.</p></li>
  <li><p>the per application traffic statistic files are in <code>/proc/uid_stat/[uid]/</code> </p></li>
  </ul>
  
  <p>My questions:</p>
  
  <ol>
  <li><p>Do the folder <code>rmnet0, rmnet1, rmnet2, rmnet3..</code>.  match each APN? If do, what's the match rule? if don't, how can I get each APN traffic statistic?</p></li>
  <li><p>In folder <code>/proc/uid_stat/[uid]/,</code> there are only two files: <code>tcp_rcv</code> and <code>tcp_snd</code>, how can I get each applicaton on each APN traffic stats?</p></li>
  </ol>