title: How to send v3 trap with enginedId using snmp4j
body: <p>I'm trying to create a standalone java application to send SNMP v3 Traps along with engineId.</p>
  
  <p>I'm using snmp4j 2.5.3 and Java 1.8</p>
  
  <p>Below is the code snippet which I am using.</p>
  
  <p>When I provide engineId while addUser, it throws "Message processing model 3 returned error: Unknown security name".</p>
  
  <p>When I remove, it works fine. But, my SNMP manager not recognizing the Trap.</p>
  
  <pre><code>// Sample code snippet
  
  Address targetAddress = GenericAddress.parse("udp:" + ipAddress + "/" + port);
                  TransportMapping&lt;?&gt; transport = new DefaultUdpTransportMapping();
                  Snmp snmp = new Snmp(transport);
  
                  USM usm = new USM(SecurityProtocols.getInstance().addDefaultProtocols(),
                          new OctetString(MPv3.createLocalEngineID(new OctetString(engineId))), 0);
                  SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES192());
                  SecurityProtocols.getInstance().addPrivacyProtocol(new PrivAES256());
                  SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());
                  SecurityModels.getInstance().addSecurityModel(usm);
  
                  switch (securityLevel) {
                      case SecurityLevel.NOAUTH_NOPRIV:
                          snmp.getUSM().addUser(new OctetString(username), new OctetString(engineId), new UsmUser(new OctetString(username), null,
                                  null, null, null));
                          break;
                      case SecurityLevel.AUTH_NOPRIV:
                          snmp.getUSM().addUser(new OctetString(username), new OctetString(engineId), new UsmUser(new OctetString(username), auth,
                                  new OctetString(authpassPhrase), null, null));
                          break;
                      case SecurityLevel.AUTH_PRIV:
                          snmp.getUSM().addUser(new OctetString(username), new OctetString(engineId), new UsmUser(new OctetString(username), auth,
                                  new OctetString(authpassPhrase), privacy, new OctetString(privacypassPhrase)));
                          break;
                      default:
                          System.err.println("Undefined Security level for SNMP v3");
                          System.exit(1);
                  }
  
                  UserTarget target = new UserTarget();
                  target.setAddress(targetAddress);
                  target.setRetries(1);
                  target.setTimeout(5000);
                  target.setVersion(SnmpConstants.version3);
                  target.setSecurityLevel(securityLevel);
                  target.setSecurityName(new OctetString(username));
  
                  ScopedPDU pdu = new ScopedPDU();
                  pdu.setType(ScopedPDU.NOTIFICATION);
                  pdu.setRequestID(new Integer32(1234));
                  pdu.add(new VariableBinding(SnmpConstants.sysUpTime));
                  pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, SnmpConstants.linkDown));
                  pdu.add(new VariableBinding(new OID(Oid), new Integer32(123)));
  
                  snmp.send(pdu, target);
                  System.out.println("Sending Trap to (IP:Port)=&gt; " + ipAddress + ":" + port);
                  snmp.close();
  </code></pre>
  
  <p>I expect the SNMP Manager should recognize the Trap and it should be received at SNMP Manager.</p>
  
  <p>What am I missing here?</p>
  
  <p>Thanks in advance.</p>