My Opinion on Comparative Analysis of SNMP4J and ObjectSNMP

 

  SNMP4J is an open source project that implements the SNMP (Simple Network Management Protocol) protocol in Java. It supports management and response in the form of command lines. Object SNMP is an object-oriented SNMP development component. Similar to the OR Mapping technology popular in relational databases, it implements the operation mapping from Object to SNMP MIB (OM Mapping for short). Developing with SNMP4J with ObjectSNMP is similar to developing with native JDBC with the Hibernate framework.

Introduction to SNMP4J

  SNMP4J is an open source project that implements the SNMP (Simple Network Management Protocol) protocol in Java. It supports management and response in the form of command lines. SNMP4J is a pure object-oriented design similar to SNMP++ (implementing SNMPv1/v2c/v3 in C++).

  1. Supports MD5 and SHA authentication, DES, 3DES, AES128, AES192 and AES256 encrypted SNMPv3.
  2. Supports MPv1, MPv2C and MPv3, with executable blockable message processing modules.
  3. All PDU formats.
  4. Blockable transport topology. Support UPD, TCP, TLS.
  5. Blockable timeout module.
  6. Synchronous and asynchronous requests.
  7. Command generator and command responder support.
  8. Open source based on Apache license is free.
  9. JAVA 1.4.1 or later (2.0 or later requires jdk1.6 and above support).
  10. Logging based on LOG4J.
  11. Row-based efficient asynchronous table fetching using GETBULK.
  12. Multithreading is supported.

 

Introduction to ObjectSNMP

  Object SNMP (Object Simple Network Management Protocol) is an object-oriented SNMP development component. It is similar to the popular OR Mapping technology of relational databases. It realizes the operation mapping from Object to SNMP MIB (OM Mapping for short), and the system provides a Java/SNMP gateway. , RMI/SNMP gateway, Web Service/SNMP gateway service. Developers do not need to understand the SNMP protocol and MIB details, but only need to define common data objects, and then submit the data objects to the gateway in the modes of adding, deleting, modifying, and querying. The Object SNMP gateway will automatically send the data objects to the SNMP device according to the developer's expectations, and return the data objects required by the user. Object SNMP provides advanced functions such as distributed proxy SNMP gateway, network topology discovery, physical topology discovery, network automatic search discovery, device connection relationship discovery, device type discovery, network roaming search, and defined MIB data that can manage various devices. Function.

  ObjectSNMP provides four gateway API models to meet the needs of most developers. The APIs of all gateways are consistent, and services such as adding, deleting, modifying, and querying based on data objects are provided; and various gateway modes can be switched at will, keeping the API unchanged for users.

1.OM Mapping mapping framework

  Refer to the popular O-RMapping technology in the database field, realize the Object-MIB mapping framework in the SNMP field, automatically translate MIB and OID syntax, SNMP commands and network operations, and completely say goodbye to the programming mode of Socket, PDU, UDP, SNMPGet, etc., developers Only need to define a normal data object corresponding to MIB data. Then submit data objects through various gateways to complete complex access to SNMP.

2. Java/SNMP gateway

  The user's program and ObjectSNMP are in the same Java process, the user defines common Java data objects, and then accesses the ObjectSNMP gateway through the Java API.

3. Java RMI/SNMP gateway

  The user's program and ObjectSNMP are in different Java processes, or on different machines. Users define common Java data objects and then access the ObjectSNMP gateway through the RMI Java API.

4. Web Service/SNMP gateway

  Users can access the ObjectSNMP gateway in the Web environment for other programs that support Web Service technology, such as PHP, C++, .NET, Java, Flex, and JavaScript. The Web Servcie/SNMP Gateway supports any servlet-compatible Web container.

5.Proxy/SNMP transparent gateway

  It provides transparent SNMP gateway services for scenarios such as private network penetration, distributed deployment of SNMP gateways, SNMP gateway load balancing, and master/slave two-level SNMP management. Proxy gateway can adopt any mode of Java, RMI, Web Service, and is completely transparent to users, just like there is only one gateway.

6. Consistent API service

  The APIs of all gateways are consistent, providing services such as adding, deleting, modifying, and querying based on data objects; and can switch various gateway modes at will, keeping the API unchanged for users.

7. SNMP Trap receiving service

  Built-in SNMP Trap receiving server, can receive public and private SNMP Trap messages. And automatically parse the original Trap PDU packet into a Java Trap message object. In order to simplify the programming and development of Trap notification mode, ObjectSNMP maps the passively received Trap message mechanism into a common programming mode that actively obtains Java Trap message objects.

8. Network management integration

  ObjectSNMP relies on the underlying OM framework and gateway technology to provide the most convenient support for SNMP network management functions such as fault management, performance monitoring management, fault monitoring, configuration management, service management, and network security management.

9. Support private MIB files

  The product can load private MIB files of various manufacturers. After loading the private MIB files, the syntax of the MIB files is automatically parsed.

10. Network automatic discovery function

  Adopt new technology: support a single Cisco, Huawei network, and also support a mixed network of equipment from various manufacturers. Support fuzzy connection location, in the case of incomplete data or missing equipment, find the connection relationship as much as possible. It can work in any network environment and does not require users to make any assumptions about the network.

11. SNMP data collection service

  ObjectSNMP provides the following common data collection services, which users can use directly: system MIB description, IP network MIB description, switch MIB description, hardware facility MIB description, software MIB description, and Java MIB description.

12. Automatic Java code generation technology

  Provides the automatic generation technology of Java data object code, which further simplifies the development of SNMP.

13. SNMP MIB data browser

  It can be used alone or integrated in the program to use the SNMP data browser, which is convenient for development and debugging.

14. Excellent performance

  • The total acquisition time of 10,000 SNMP objects (70,000 SNMP OID data) per thread is <= 5 seconds
  • The total time for acquiring 10,000 SNMP objects concurrently with multiple threads is <= 2 seconds
  • For 30 consecutive days, multi-threaded concurrent acquisition of SNMP data, the memory fluctuation is plus or minus 0.3M
  • 10 million SNMP object acquisition operations, in a multi-threaded concurrent environment, the accuracy rate is 100%

SNMP4J and ObjectSNMP instance comparison

(1) Obtain simple basic data of snmp

1. Snmp4j steps:

1) Create Target (Target represents a remote device or remote entity), including device address, SNMP port, snmp community word, SNMP version, timeout, retries and other information.

2) Create a PDU (representing the data that the management terminal communicates with Target), add the OID value to be obtained in the PDU, and set the access mode.

3) Create SNMP (representing the manager, the role is the specific implementer of communication)

4) Send PDU to Agent and receive Response response

 

5) Parse the Resoponse response.

// set target
   CommunityTarget target = new CommunityTarget();
   target.setCommunity(new OctetString("public"));
   Address targetAddress = GenericAddress.parse("udp:127.0.0.1/161");
   target.setAddress(targetAddress);//Set the target device address and port
   target.setRetries(2); // The number of retries when the communication is unsuccessful
   target.setTimeout(1500);// timeout
   target.setVersion(SnmpConstants.version1);//Set the version

   // create PDU
   PDU pdu = new PDU();
   pdu.add(new VariableBinding(new OID(new int[] { 1, 3, 6, 1, 2, 1, 1, 5, 0 })));
   pdu.setType(PDU.GET);// MIB access method
   
   TransportMapping transport = new DefaultUdpTransportMapping();
   Snmp snmp = new Snmp(transport);
   ResponseEvent respEvnt = snmp.send(pdu, target);// MIB access method

   // Parse Response
   if (respEvnt != null && respEvnt.getResponse() != null) {
		Vector<VariableBinding> recVBs = respEvnt.getResponse().getVariableBindings();
          for (int i = 0; i < recVBs.size(); i++) {
                 VariableBinding recVB = recVBs.elementAt(i);
                 System.out.println(recVB.getOid() + " : " + recVB.getVariable());
          }
   }

2. Use ObjectSNMP to get data:

1) Create SNMPTarget, including device address, SNMP port, snmp community word, SNMP version, timeout, retries and other information.

2) Obtain SNMPAPI, and obtain SNMP data according to OID.

  //Encapsulate Target
   SNMPTarget target = new SNMPTarget();
   target.nodeIP="127.0.0.1";
   target.port=161;
   target.readCommunity="public";
   target.snmpVersion = target.VERSION2C;
   
   //getting information
   String result = SNMPFactory.getSNMPAPI().getOIDValue("1, 3, 6, 1, 2, 1, 1, 5, 0",target);

 Conclusion: For the acquisition of simple SNMP data, that is, to obtain the corresponding information according to a single OID, ObjectSNMP is more simple and convenient.

(2) Operation snmp table and group data

 

  All SNMP MIBs can be divided into two categories, one is called the system group as shown in the figure below, which has query and modification operations.

 

 

 

The JAVA objects mapped to them are:

public class MibSystem implements com.zhtelecom.common.snmp.OMMappingInfo
{
    private String sysDescr;
    private String sysObjectID;
    private long sysUpTime;
    private String sysContact;
    private String sysName;
    private String sysLocation;
    private int sysServices;
		get/set ……..
    public String getMappingOID() //Tell the OID to map the system group
    {
        return "1.3.6.1.2.1.1"; //OID of system group
    }
}

Public class MibOspfStubAreaEntry implements com.zhtelecom.common.snmp.OMMappingInfo
{
    private String ospfStubAreaId;
    private int ospfStubTOS;
    private int ospfStubMetric;
    private int ospfStubStatus;
    private int ospfStubMetricType;

    public String getMappingOID()
    {
        return "1.3.6.1.2.1.14.3.1"; // ospfStubAreaEntry的OID
    }
}

 

//Get all the data in the MibOspfStubAreaEntry table
List list= snmpapi. getAllTableData(MibOspfStubAreaEntry.class, target);
//Add a row of data to the MibOspfStubAreaEntry table
MibOspfStubAreaEntry ospf = new MibOspfStubAreaEntry();
ospf.setOspfStubTOS(3);
ospf.setOspfStubStatus(SNMPAPI.RowStatusEntryAdd); //Set the value of snmp rowstatus to add.
ospf.setOspfStubMetricType(2);
snmpapi.addTableRow(ospf, target);
// delete a row of data from the table
MibOspfStubAreaEntry ospf = new MibOspfStubAreaEntry();//Set the value of snmp rowstatus to delete semantics
ospf.setOspfStubStatus(SNMPAPI.RowStatusEntryDel);
snmpapi.delTableRow(ospf, target);

//Modify a row of data in the MibOspfStubAreaEntry mib table
MibOspfStubAreaEntry ospf = new MibOspfStubAreaEntry();
ospf.setOspfStubAreaId("192.168.9.0");
ospf.setOspfStubTOS(3);
ospf.setOspfStubStatus(SNMPAPI.RowStatusEntryActive); //Set the value of snmp rowstatus to active semantics.
ospf.setOspfStubMetric(3);
ospf.setOspfStubMetricType(3);
snmpapi.update(ospf, target);

It can be seen that operating data through ObjectSNMP is extremely convenient and simple. Compared with SNMP4J, it has been greatly improved in terms of ease of use and functionality, and operating SNMP through objects is more in line with the user's usage habits, and shielding The PDU, ScopedPDU class, TransportMapping, etc. in SNMP4J have been dropped, and the learning cost has been greatly reduced.

(3) Comparison of ObjectSNMP and SNMP Development

project

Develop with ObjectSNMP

SNMP4J

Software Architecture

The bottom layer implements the encapsulation of the SNMP protocol, and the upper layer provides object-based gateway services and various advanced services.

Realize the original encapsulation of SNMP protocol

Development Skill Requirements

Only need to understand SNMP concepts to develop, and provide automatic object code generation tools

Development-level mastery of Socket, SNMP data types, etc. is required.

Development efficiency

Object-level upper-level abstract operations. The amount of code is only 10% of the traditional mode

A large number of SNMP protocol layer operation codes

Development time

The time spent on SNMP module development and device joint debugging is only 20% of the traditional mode

A special person is required to be responsible for the development and post-maintenance of the SNMP module

software performance

Benchmarked, newly defined data objects are passed directly on the gateway channel

Requires extensive tuning, testing, and validation to ensure

software mode

There is a unified object mode and gateway mode, which is consistent with the object style of the overall software

None, requires developers to rebuild

Gateway function

Supports multiple gateways such as Java, RMI, Web Service, Proxy, etc.

without

Premium service

New technology for automatic network topology discovery and network resource discovery

without

Predefined MIB Objects

Provide a variety of built-in MIB collection services, such as network interface, traffic, data packets, IP, CPU, disk, memory, etc.

without

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326570550&siteId=291194637