public static SnmpEngineId createEngineId(){
  byte[] address=null;
  byte[] engineid=new byte[13];
  int iana=42;
  long mask=0xFF;
  long time=System.currentTimeMillis();
  engineid[0]=(byte)((iana & 0xFF000000) >> 24);
  engineid[0]|=0x80;
  engineid[1]=(byte)((iana & 0x00FF0000) >> 16);
  engineid[2]=(byte)((iana & 0x0000FF00) >> 8);
  engineid[3]=(byte)(iana & 0x000000FF);
  engineid[4]=0x05;
  engineid[5]=(byte)((time & (mask << 56)) >>> 56);
  engineid[6]=(byte)((time & (mask << 48)) >>> 48);
  engineid[7]=(byte)((time & (mask << 40)) >>> 40);
  engineid[8]=(byte)((time & (mask << 32)) >>> 32);
  engineid[9]=(byte)((time & (mask << 24)) >>> 24);
  engineid[10]=(byte)((time & (mask << 16)) >>> 16);
  engineid[11]=(byte)((time & (mask << 8)) >>> 8);
  engineid[12]=(byte)(time & mask);
  return new SnmpEngineId(engineid);
}

public static SnmpEngineId createEngineId ( ) { byte [ ] address = null ; byte [ ] engineid = new byte [ 13 ] ; int iana = 42 ; long mask = 0xFF ; long time = System . currentTimeMillis ( ) ; engineid [ 0 ] = ( byte ) ( ( iana & 0xFF000000 ) > > 24 ) ; engineid [ 0 ] |= 0x80 ; engineid [ 1 ] = ( byte ) ( ( iana & 0x00FF0000 ) > > 16 ) ; engineid [ 2 ] = ( byte ) ( ( iana & 0x0000FF00 ) > > 8 ) ; engineid [ 3 ] = ( byte ) ( iana & 0x000000FF ) ; engineid [ 4 ] = 0x05 ; engineid [ 5 ] = ( byte ) ( ( time & ( mask << 56 ) ) > > > 56 ) ; engineid [ 6 ] = ( byte ) ( ( time & ( mask << 48 ) ) > > > 48 ) ; engineid [ 7 ] = ( byte ) ( ( time & ( mask << 40 ) ) > > > 40 ) ; engineid [ 8 ] = ( byte ) ( ( time & ( mask << 32 ) ) > > > 32 ) ; engineid [ 9 ] = ( byte ) ( ( time & ( mask << 24 ) ) > > > 24 ) ; engineid [ 10 ] = ( byte ) ( ( time & ( mask << 16 ) ) > > > 16 ) ; engineid [ 11 ] = ( byte ) ( ( time & ( mask << 8 ) ) > > > 8 ) ; engineid [ 12 ] = ( byte ) ( time & mask ) ; return new SnmpEngineId ( engineid ) ; }
generates an engine id that is unique to the host the agent is running on . the engine id unicity is system time based . the creation algorithm uses the sun microsystems iana number ( 42 ) .
