Friday, October 16, 2009

4.2 Code Introduction

Team-Fly
 

 

TCP/IP Illustrated, Volume 2: The Implementation
By
Gary R. Wright, W. Richard Stevens
Table of Contents
Chapter 4. 
Interfaces: Ethernet


4.2 Code Introduction


The code for the Ethernet device driver and the generic interface ioctls resides in two headers and three C files, which are listed in Figure 4.3.



Figure 4.3. Files discussed in this chapter.


Global Variables


The global variables shown in Figure 4.4 include the protocol input queues, the LANCE interface structure, and the Ethernet broadcast address.



Figure 4.4. Global variables introduced in this chapter.


le_softc is an array, since there can be several Ethernet interfaces.



Statistics


The statistics collected in the ifnet structure for each interface are described in Figure 4.5.



Figure 4.5. Statistics maintained in the ifnet structure.


Figure 4.6 shows some sample output from the netstat command, which includes statistics from the ifnet structure.



Figure 4.6. Sample interface statistics.


The first column contains if_name and if_unit displayed as a string. If the interface is shut down (IFF_UP is not set), an asterisk appears next to the name. In Figure 4.6, sl0, sl2, and sl3 are shut down.


The second column shows if_mtu. The output under the "Network" and "Address" headings depends on the type of address. For link-level addresses, the contents of sdl_data from the sockaddr_dl structure are displayed. For IP addresses, the subnet and unicast addresses are displayed. The remaining columns are if_ipackets, if_ierrors, if_opackets, if_oerrors, and if_collisions.


  • Approximately 3% of the packets collide on output (942,798/29,234,729 = 3%).

  • The SLIP output queues are never full on this machine since there are no output errors for the SLIP interfaces.

  • The 12 Ethernet output errors are problems detected by the LANCE hardware during transmission. Some of these errors may also be counted as collisions.

  • The 814 Ethernet input errors are also problems detected by the hardware, such as packets that are too short or that have invalid checksums.



SNMP Variables


Figure 4.7 shows a single interface entry object (ifEntry) from the SNMP interface table (ifTable), which is constructed from the ifnet structures for each interface.



Figure 4.7. Variables in interface table: ifTable.


The ISODE SNMP agent derives ifSpeed from if_type and maintains an internal variable for ifAdminStatus. The agent reports ifLastChange based on if_lastchange in the ifnet structure but relative to the agent's boot time, not the boot time of the system. The agent returns a null variable for ifSpecific.





    Team-Fly
     

     
    Top
     


    No comments:

    Post a Comment