25.9. ICMP StatisticsThe ICMP protocol keeps the statistics defined in RFC 2011, storing them in icmp_mib data structures. The kernel maintains statistics on a per-CPU basis, and for each CPU it distinguishes between statistics updated in software interrupt context and those updated outside that context. In other words, for each counter there are two instances per CPU: one of those two instances is used by code running in software interrupt context and the other is used by code not running in software interrupt context. All of those icmp_mib instances are allocated by init_ipv4_mibs in net/ipv4/af_inet.c. icmp_statistics is a two-element array, whose first element represents the per-CPU array of icmp_mib instances used by code that runs in software interrupt context, and whose second element represents the other per-CPU array.
The icmp_mib structure consists of an array of unsigned long members, one for each counter defined in RFC 2011 for the ICMP protocol:
The counters are identified via the enumeration list ICMP_MIB_XXX, defined in include/linux/snmp.h:
Note that the size of the icmp_mib array is one unit bigger than the size of the ICMP_MIB_XXX enumeration list. The extra element is used to account for ICMP message types not recognized by the kernel. At any time, when the kernel needs to update a given counter, it selects the right element of icmp_statistics based on the interrupt context, and then the right icmp_mib instance based on the current CPU. The kernel provides a set of macros in include/net/icmp.h that need only the counter identifier in input (i.e., ICMP_MIB_XXX) and transparently take care of the two selections just described:
The three macros are defined as wrappers around generic macros provided by the SNMP subsystem:
Here is the meaning of the ICMP_MIB_XXX values. For a more detailed description, you can refer to RFC 2011. Fields related to received ICMP messages
ICMP_MIB_INXXX counterpart for each ICMP_MIB_OUTXXX counter:
ICMP_MIB_INXXX counters are updated in icmp_rcv. ICMP_MIB_OUTXXX counters are updated within icmp_reply and icmp_send by invoking icmp_out_count:
In both cases, for any ICMP type t, the right counter to increment is identified by means of the input_entry and output_entry fields of the icmp_control data structure associated with t. The values of these counters are exported in the /proc/net/snmp file. You can also read them with netstat -s (and with SNMP agents, of course). |
Saturday, October 24, 2009
Section 25.9. ICMP Statistics
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment