Java Dynamic Management Kit 5.1 Tutorial

19.3.2 Generating SNMPv3 Engine IDs

SNMPv3 engine ID objects are generated in accordance with SNMP RFC 2571. An engine discovers its ID in one of the following ways, each of which is tried in the order shown:

  1. It is found in the engine's associated jdmk.security file

  2. It is found using SnmpEngineParameters

  3. It is computed by the SNMP adaptor, based on the host and port information, or it is computed by the SNMP session, based on time

In Java DMK 5.1, you can create new SNMP engine IDs either manually using a Java command line tool called EngineIdGenerator, or automatically in the code of your applications using the SnmpEngineId class. You can see the EngineIdGenerator tool in the examplesDir/current/Snmp/EngineId directory. You must provide either of EngineIdGenerator or SnmpEngineId with any of the following information:

The EngineIdGenerator uses the SnmpEngineId class when generating engine IDs (see the Javadoc entry for SnmpEngineId for details). The SnmpEngineId class simplifies the configuration of SNMP entities by enabling you to identify engines using information that is easily comprehensible to humans, such as host names and port numbers, which it then converts into system-oriented hexadecimal engine IDs for you. The SnmpEngineId class also generates SNMP object identifiers (OIDs) from the engine IDs it creates. This is particularly useful when computing USM MIB user table indexes, as seen in 19.3.6 Creating Users for SNMPv3 USM MIBs.

To Run the SNMP EngineIdGenerator Example
  1. Compile the EngineIdGenerator class in examplesDir/current/Snmp/EngineId.


    $ javac -classpath classpath EngineIdGenerator.java
    
  2. Start the EngineIdGenerator tool.


    $ java -classpath classpath EngineIdGenerator
    Start making your engine Id construct:(h for help)
    #:
    

    Typing h will provide examples of information you can provide.

  3. Provide the relevant information to create the engine ID.

    Declare your information, using the appropriate separators, as follows:

    address:port:IANA number

    All three inputs are used

    address:port

    The address and port you specify are used; the IANA number defaults to 42 (SUN Microsystems)

    address

    The address you specify is used; the port defaults to 161 and the IANA number defaults to 42 (SUN Microsystems)

    :port

    The port you specify is used; the host defaults to localhost and the IANA number defaults to 42 (SUN Microsystems)

    ::IANA number

    The IANA number you specify is used; the host defaults to localhost and the IANA number defaults to 42 (SUN Microsystems)

    :port:IANA number

    The port and IANA number you specify are used; the host defaults to localhost

    address::IANA number

    The address and IANA number you specify are used; the port defaults to 161

    ::

    The port defaults to 161, the address defaults to localhost and the IANA number defaults to 42 (SUN Microsystems)

    For example, to specify all three of the address, port and IANA number, when prompted you might type:


    Start making your engine Id construct:(h for help)
    #:localhost:8087:42
    Generated engine Id ******** [0x8000002a05819dcb6200001f97] ********
    #:
    
  4. Press Control-C when you have finished generating engine IDs