Sunday, October 18, 2009

21.3 Code Introduction

Team-Fly
 

 

TCP/IP Illustrated, Volume 2: The Implementation
By
Gary R. Wright, W. Richard Stevens
Table of Contents
Chapter 21. 
ARP: Address Resolution Protocol


21.3 Code Introduction


There are nine ARP functions in a single C file and definitions in two headers, as shown in Figure 21.2.



Figure 21.2. Files discussed in this chapter.


Figure 21.3 shows the relationship of the ARP functions to other kernel functions. In this figure we also show the relationship between the ARP functions and some of the routing functions from Chapter 19. We describe all these relationships as we proceed through the chapter.



Figure 21.3. Relationship of ARP functions to rest of kernel.


Global Variables


Ten global variables are introduced in this chapter, which are shown in Figure 21.4.



Figure 21.4. Global variables introduced in this chapter.



Statistics


The only statistics maintained by ARP are the two globals arp_inuse and arp_allocated, from Figure 21.4. The former counts the number of ARP entries currently in use and the latter counts the total number of ARP entries allocated since the system was initialized. Neither counter is output by the netstat program, but they can be examined with a debugger.


The entire ARP cache can be listed using the arp -a command, which uses the sysctl system call with the arguments shown in Figure 19.36. Figure 21.5 shows the output from this command, for the entries shown in Figure 18.2.



Figure 21.5. arp -a output corresponding to Figure 18.2.


Since the multicast group 224.0.0.1 has the L flag set in Figure 18.2, and since the arp program looks for entries with the RTF_LLINFO flag set, the multicast groups are output by the program. Later in this chapter we'll see why this entry is marked as "incomplete" and why the entry above it is "permanent."



SNMP Variables


As described in Section 25.8 of Volume 1, the original SNMP MIB defined an address translation group that was the system's ARP cache. MIB-II deprecated this group and instead each network protocol group (i.e., IP) contains its own address translation tables. Notice that the change in Net/2 to Net/3 from a stand-alone ARP table to an integration of the ARP information within the IP routing table parallels this SNMP change.


Figure 21.6 shows the IP address translation table from MIB-II, named ipNetToMediaTable. The values returned by SNMP for this table are taken from the routing table entry and its corresponding ifnet structure.



Figure 21.6. IP address translation table: ipNetToMediaTable.


If the routing table entry has an expiration time of 0 it is considered permanent and hence "static." Otherwise the entry is considered "dynamic."





    Team-Fly
     

     
    Top
     


    No comments:

    Post a Comment