|
|
| HOME | PRODUCTS | DOWNLOAD | SALES | SUPPORT | ABOUT US | |
|
Koshna SNMP Agent ToolkitConfiguring the SNMP protocol Stack for a SNMP AgentThe architecture diagram below shows how the various modules interact.
To configure the SNMP protocol stack for a SNMP agent.
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 SnmpAgentMTDispatcher(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()); // Create the MIB objects HOST_RESOURCES_MIB mib = new HOST_RESOURCES_MIB(); for (int i=0;i<2;i++){ mib.getHrStorage().getHrStorageTable().addRow(new HrStorageEntry(i)); } mib.getHrDevice().getHrPartitionTable().addRow(new HrPartitionEntry(2,1)); HOST_RESOURCES_MIBInfo mibInfo = new HOST_RESOURCES_MIBInfo(mib); System.out.println("registering crs"); // Create the Command responders & associate them with the dispatcher SnmpV1CommandResponder v1_cr = new SnmpV1CommandResponder(mibInfo); SnmpV2cCommandResponder v2c_cr = new SnmpV2cCommandResponder(mibInfo); SnmpV3CommandResponder v3_cr = new SnmpV3CommandResponder(mibInfo,vacm); dispatcher.registerSnmpCommandResponder(v3_cr); dispatcher.registerSnmpCommandResponder(v2c_cr); dispatcher.registerSnmpCommandResponder(v1_cr); internalMibs.registerMibs(v1_cr); internalMibs.registerMibs(v2c_cr); internalMibs.registerMibs(v3_cr); mib.init(); // Start the dispatcher dispatcher.start(); ... The SNMP Agent 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. |