/* 
* Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
*/ 

TEST NAME 

      sanity - test network card

SYNOPSIS 

      sh sanity.sh DRIVER INSTANCE REMOTE BROADCAST-ADDR

DESCRIPTION 

      This repeatedly tests the basic functions of the network card such as
      loading/unloading, re-initializing, and network-broadcasting from the
      driver.

OPERANDS 

       DRIVER           Name of the NIC driver as it appears in the
                        /kernel/drv directory.

       INSTANCE         Individual instance of the driver for a particular
                        network card. Pick one from the 'ifconfig -a' output.

       REMOTE           Either the host name or IP address of the machine. 
                        If the host name is specified, it must appear in
                        /etc/hosts along with the remote machine's IP
                        address.

       BROADCAST-ADDR   Broadcast address for the particular network card,
                        typically 'x.x.x.255'.

USAGE VARIABLES 

      RUNTIME   This environment variable specifies, in seconds, the duration 
                of the test.

SETUP 

      You need at least two machines connected by a network, either
      back-to-back, or through a hub or switch.

OUTPUT 

      The test produces reasonably self-explanatory output that indicates the
      progress of the test. See the appropriate man pages for a full
      explanation of the output.

DURATION 

      24 hours

POSSIBLE CONCURRENT TESTS 

      It is not useful to run this test with others (except mpflip), as it
      continuously brings the interface up and down.

NOTES 

      * Due to the fact that the driver is continually being loaded and
        unloaded, tests that use the network card will probably timeout,
        although they shouldn't hang the system.

      * Some intelligent hubs and switches might disable the port to which the
        test machine is connected as the interface goes up and down because of
        a feature called "broadcast storm control". If necessary, consult the
        documentation on how to disable this feature.

      * By repeatedly loading/unloading the driver (hammering), this test might
        reveal any initializing problems present in the driver.

      * This test is useful for basic functionality testing and can also detect
        some memory leaks that might be present.

      * A subtest called hammer.sh is run as part of the sanity test. This test
        deals with the loading/unloading of the module and is called
        automatically by sanity.sh.

EXAMPLES 

      If the driver name is 'mtok', the individual NIC instance number is 0,
      and the remote machine name is dellboy, the following output is
      generated:

      # RUNTIME=60
      # export RUNTIME
      # ./sanity.sh mtok 0 dellboy 1.1.30.255
      |--------------------Bringing the card Down and Up once.----------------|
      Starting to Hammer mtok0 1 times
      Using localhost: 1.1.30.20
      Bringing mtok0 Up
      Setting netmask of mtok0 to 255.255.255.0
      dellboy is alive
      Bringing mtok0 Down
      Trying to unload module: mtok
       mtok0 module unloaded
      1
      Setting netmask of mtok0 to 255.255.255.0
      mtok Up
      [Cleaning up]
      Setting netmask of mtok0 to 255.255.255.0
      mtok0 Up
      Please wait ...


      |-----------------------------Pinging dellboy-------------------------|
      dellboy is alive
      Finished
      Please wait ...

      |---------------------------Hammer Test---------------------------------|

      Starting to Hammer mtok0 -1 times
      Using localhost: 1.1.30.20
      Bringing mtok0 Up
      Setting netmask of mtok0 to 255.255.255.0
      dellboy is alive
      Bringing mtok0 Down
      Trying to unload module: mtok
       mtok0 module unloaded
      Bringing mtok0 Up
      Setting netmask of mtok0 to 255.255.255.0
      dellboy is alive
      Bringing mtok0 Down
      Trying to unload module: mtok
       mtok0 module unloaded
       .
       .
      Bringing mtok0 Up
      Setting netmask of mtok0 to 255.255.255.0
      dellboy is alive
      Bringing mtok0 Down
      Trying to unload module: mtok
       mtok0 module unloaded
      Setting netmask of mtok0 to 255.255.255.0
      mtok Up
      !PASS: Finished Hammering
      [Cleaning up]
      Setting netmask of mtok0 to 255.255.255.0
      mtok0 Up


      |-------------------------Broadcast Test--------------------------------|
      PING 1.1.30.255: 56 data bytes
      64 bytes from rockie30 (1.1.30.20): icmp_seq=0. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=0. time=1. ms
      64 bytes from rockie30 (1.1.30.20): icmp_seq=1. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=1. time=0. ms
      64 bytes from rockie30 (1.1.30.20): icmp_seq=2. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=2. time=0. ms
      64 bytes from rockie30 (1.1.30.20): icmp_seq=3. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=3. time=1. ms
      64 bytes from rockie30 (1.1.30.20): icmp_seq=4. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=4. time=0. ms
      64 bytes from rockie30 (1.1.30.20): icmp_seq=5. time=0. ms
      64 bytes from dellboy (1.1.30.1): icmp_seq=5. time=1. ms

      ----1.1.30.255 PING Statistics----
      6 packets transmitted, 12 packets received, 2.00 times amplification
      round-trip (ms)  min/avg/max = 0/0/1
      Finished Pinging



      |-------------------------Multicast Test--------------------------------|
      224.0.0.1 is alive



      |---------------------------Snoop Test----------------------------------|
      Using device /dev/mtok (promiscuous mode)
                   -> SMC          TR LLC, but no SNAP encoding, size = 45 bytes
                   -> SMC          TR LLC, but no SNAP encoding, size = 45 bytes
                   -> SMC          TR LLC, but no SNAP encoding, size = 45 bytes
      Finished Snooping
      |-----------------------------Netstat----------------------------------------|
      Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue 
      lo0   8232 loopback      localhost      121332 0     121332 0     0      0     
      iprb0 1500 137.156.240.0 rockie240      0      0     571    571   0      0     
      mtok0 2008 1.1.30.0      rockie30       252002 0     201650 0     0      0     

      mtok0:
      ipackets 252002 opackets 201650 multircv 25 multixmt 0 brdcstrcv 151371 
      brdcstxmt 151363 ierrors 0 oerrors 0 link_status 1 link_status_type 6 
      obytes 13211692 ibytes 15730455 norcvbuf 0 noxmtbuf 0 intr 566915 line_errors 0 
      internal_errors 0 burst_errors 0 ari_fci_errors 0 abort_delimiters 0 
      lost_frame_errors 0 congestion_errors 0 frame_copied_errors 0 
      frequency_errors 0 token_errors 0 dma_bus_errors 0 dma_parity_errors 0 
      inits 50272 speed 16 nocanput 0 noallocb 0 
      # 

REFERENCES 

      ifconfig(1M), modload(1M), modunload(1M), netstat(1M), ping(1M), snoop(1M)
