|
|
| HOME | PRODUCTS | DOWNLOAD | SALES | SUPPORT | ABOUT US | |
|
Koshna SNMP Manager ToolkitConfiguring the SNMP protocol Stack for a SNMP ManagerA simplified block diagram of the architecture of the stack for an SNMP Manager implementation is shown below.
To configure the SNMP protocol stack for a SNMP manager.
For example, here is some sample code: ... // Create a Transport Layer IPTransportLayer tpLayer = new IPTransportLayer(161,2048); // Create a SNMP Agent Dispatcher and associate the transport layer with it. dispatcher = new SnmpManagerMTDispatcher(2,2,tpLayer); // Create Protocol Engines &associate them with the dispatcher SnmpV3ProtocolEngine pe = new SnmpV3ProtocolEngine(new byte[] {(byte)0x80, 0x00, 0x00, 0x02, 0x01, 0x09, (byte)0x84, 0x03, 0x01}); // Initialize the internal MIBS InternalMibs internalMibs = new InternalMibs(".\\config\\snmp.conf"); // Create a Access Module VACMImpl vacm = new VACMImpl(internalMibs.getVacmMibHelper()); // Create a Security Module USMImpl usm = new USMImpl(internalMibs.getUsmMibHelper()); System.out.println("Registering the v3 protocol engine..."); // Associate the security module with the V3 protocol engine pe.addSecModule(usm); dispatcher.registerSnmpProtocolEngine(pe); dispatcher.registerSnmpProtocolEngine(new SnmpV1ProtocolEngine()); dispatcher.registerSnmpProtocolEngine(new SnmpV2cProtocolEngine()); // Start the dispatcher dispatcher.start(); // Create the SNMP Session SnmpIPPeer peer = new SnmpIPPeer("127.0.0.1",161); SnmpV3Parameters params = new SnmpV3Parameters(); params.setSecurityModelNumber(usm.getSecModelNumber()); params.setRemoteEngineID(new byte[] {0x10,0x01}); params.setUserName("user1".getBytes()); params.setSecurityLevel(new SecurityLevel(SecurityLevel.AUTH_PRIV )); SnmpV3Session session = new SnmpV3Session(dispatcher, peer, params); session.discoverRemoteEngineID(); session.discoverRemoteEngineTime(); // Create the MIB Proxy objects HOST_RESOURCES_MIBProxy mibProxy = new HOST_RESOURCES_MIBProxy(); mibProxy.init(); // Associate the proxies with the session. mibProxy.setSnmpSession(session); // get values from remote agent. mibProxy.snmpGetAll(); System.out.println("MibProxy = " + mibProxy.toXML()); ... The SNMP Manager dispatcher can be multi-threaded in which case you can decide how may threads will be assigned to receive packets & decode them(SNMP Packet Processors) and how many to create SNMP messages (SNMP Message Processors) and send them out.Besides, One thread each will be assigned to the Transport Layer modules. |
| Copyright ?2005 Koshna Software Technologies Pvt Ltd, Bangalore, India. All rights reserved. |