How to set a specified engine ID for SNMP4J to send V3 trap

When I want to create a SNMPv3 user on the NMS, there need to input an engine ID which is an identifier string from SNMP Agent server for each user, so I input an casual id. For example:

82857e61015ebda8218c4bca148b00f

And I can successfully send the trap from Agent server to NMS using below command:

snmptrap -e 0x8000000001020304 -v 3 -u myuser -a MD5 -A myjjpassword -x DES -X myjjpassword1 -l noAuthNoPriv 172.24.8.133:162 “” 1.3.6.1.4.1.48183 1.3.6.1.4.1.48183.1 s “smartmon”

Now, everything looks ok.

But when I want to use java SNMP4j to send trap with the created user mytrapuser1 on Agent server, I don’t know how to specify the request’s engine id as 0x80001370017f000101, that caused the trap is sent failed on agent or the requested engine ID cannot be matched on the NMS.

My Questions:

  1. Is the Engine ID sent from the command line specially processed?
  2. If I am sending TRAP v3 via SNMP4J, how do I pass the appropriate engine ID?
  3. If the engine ID configured in the snmptrapd.conf file is “0x8000000001020304”, what should be written in the Java code?

Is there anyone could help me, thanks very much.

OctetString uses a different string representation than NET-SNMP does. Thus, you need to specify your engine ID as:

OctetString.fromString("8000000001020304", 16);

Wow, your advice is very effective. Thank you very much