Trap Parameters

 

Management applications can receive trap messages sent by the agent. Following are the trap parameters that are to be set while developing applications.

 

Enterprise OID

 

This is the OID of the management enterprise that defines the trap message. The value is represented as an OBJECT IDENTIFIER and has a variable length. The following table displays the method that can be used for setting the enterprise OID.

 

API Name Class/Component Name API Methodsapi.jpg

Low Level

SnmpPDU

setEnterpriseOID(SnmpOID)

 

Agent Address

 

This specifies the source IP address from which the trap was sent. The following table displays the method that can be used for setting the agent address.

 

API Name Class/Component Name API Methodsapi.jpg

Low Level

SnmpPDU

setAgentAddr(String)

 

Generic and Specific Type

 

The SNMP standard defines seven traps that can be generated by SNMPv1 agents. Six of these traps are "generic" traps and the seventh trap is enterprise specific. The enterprise-specific trap is used by the private organizations to define their device-specific traps. The six generic trap types defined for SNMPv1 agents are as follows.

The generic traps are fixed and cannot be defined. On the other hand, it is possible to define multiple enterprise-specific traps.

 

The trap message identity is determined based on the values contained in the Enterprises, Standard Trap Type, and Specific Trap Type fields of the Trap PDU. If the Trap Type value is zero through five, the trap is one of the generic traps and the value of the Specific Trap Type field will be zero. If the Trap type value is six, the trap is enterprise specific and is defined in a private MIB. It can take any integer value between 0 and 2147483647.

 

The following table lists the methods that can be used for setting the trap type. The following table lists the methods that can be used for setting the generic and specific traps.

 

API Name Class/Component Name API Methodsapi.jpg Remarks

Low Level

SnmpPDU

setTrapType(int)

setSpecificType(String)

The setTrapType(int) method sets the generic type of the trap and the setSpecificType(String) sets the specific type of the trap.

 

Time Stamp

 

This is the value stored in the MIB-II sysUpTime variable converted into hours, minutes, and seconds. It is a 32-bit unsigned value indicating the number of centiseconds that have elapsed since the start of the SNMP agent and the sending of the trap. The following table displays the method that can be used for setting the time stamp.

 

API Name Class/Component Name API Methodsapi.jpg

Low Level

SnmpPDU

setUpTime(long)

 

The traps are normally received in the UDP port no 162. However, this port number can be different and the applications should be able to handle this. In most operating systems, especially in Unix, port numbers 0 to 1023 are reserved. Only root users have permissions to use these ports. Therefore, if the SNMP port 162 is not available, it is preferable to choose the port numbers greater than 1023.

 

The following table lists the methods that can be used for setting the trap port.

 

API Name Class/Component Name API Methodsapi.jpg

High Level

SnmpTrapReceiver

setPort(int)

setPortWithExceptionMsg(int)

Low Level

UDPProtocolOptions

setLocalPort(int)

RMI

SnmpTrapReceiver

setPort(int)

CORBA

SnmpTrapReceiver

setPort(int)

 

An SNMPv2 trap may need to be translated to an SNMPv1 trap. The following table shows the notification parameters that make up an SNMPv1 trap and SNMPv2 traps.

 

SNMPv1 Trap SNMPv2 Trap

enterprise value

sysUpTime (first variable -binding)

agent address

snmpTrapOID value (next variable bindings)

generic-trap value

snmpTrapEnterprise value (optional)

specific-trap value

additional variable bindings

timestamp

 

variable-bindings

 



Copyright © 2012, ZOHO Corp. All Rights Reserved.