Question

I have to write a network monitoring app for android and one of the requisites is to monitor all the incoming and outgoing IP traffic, I found out the /proc/stat/netstat file which I'm pretty sure contains what I want, problem is: I cannot find anywhere how to read it. Anyone knows the internal format of /proc/stat/netstat? I have to monitor the IP traffic that is being generated by the system and I found an entry named "IpExt" with some numbers after it in that file but I cannot figure out the meaning... anyone knows?

Thanks

Was it helpful?

Solution

The net/ipv4/proc.c file in the linux kernel does that.

/* Following items are displayed in /proc/net/netstat */
static const struct snmp_mib snmp4_ipextstats_list[] = {
        SNMP_MIB_ITEM("InNoRoutes", IPSTATS_MIB_INNOROUTES),
        SNMP_MIB_ITEM("InTruncatedPkts", IPSTATS_MIB_INTRUNCATEDPKTS),
        SNMP_MIB_ITEM("InMcastPkts", IPSTATS_MIB_INMCASTPKTS),
        SNMP_MIB_ITEM("OutMcastPkts", IPSTATS_MIB_OUTMCASTPKTS),
        SNMP_MIB_ITEM("InBcastPkts", IPSTATS_MIB_INBCASTPKTS),
        SNMP_MIB_ITEM("OutBcastPkts", IPSTATS_MIB_OUTBCASTPKTS),
        SNMP_MIB_ITEM("InOctets", IPSTATS_MIB_INOCTETS),
        SNMP_MIB_ITEM("OutOctets", IPSTATS_MIB_OUTOCTETS),
        SNMP_MIB_ITEM("InMcastOctets", IPSTATS_MIB_INMCASTOCTETS),
        SNMP_MIB_ITEM("OutMcastOctets", IPSTATS_MIB_OUTMCASTOCTETS),
        SNMP_MIB_ITEM("InBcastOctets", IPSTATS_MIB_INBCASTOCTETS),
        SNMP_MIB_ITEM("OutBcastOctets", IPSTATS_MIB_OUTBCASTOCTETS),
        /* Non RFC4293 fields */
        SNMP_MIB_ITEM("InCsumErrors", IPSTATS_MIB_CSUMERRORS),
        SNMP_MIB_ITEM("InNoECTPkts", IPSTATS_MIB_NOECTPKTS),
        SNMP_MIB_ITEM("InECT1Pkts", IPSTATS_MIB_ECT1PKTS),
        SNMP_MIB_ITEM("InECT0Pkts", IPSTATS_MIB_ECT0PKTS),
        SNMP_MIB_ITEM("InCEPkts", IPSTATS_MIB_CEPKTS),
        SNMP_MIB_SENTINEL
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top