HOME | PRODUCTS | DOWNLOAD | SALES | SUPPORT | ABOUT US

 
Koshna SNMP Agent Toolkit
Overview
Technical Description
Usage
API Documentation
Download
Purchase

Koshna SNMP Agent Toolkit

Configuring the SNMP protocol Stack for a SNMP Agent

The architecture diagram below shows how the various modules interact.

SNMP Agent

To configure the SNMP protocol stack for a SNMP agent.

  • Create the Transport Layers.
  • Create a SNMP Agent Dispatcher and associate the transport layers with it.
  • Create the SNMP Protocol Engines for the different SNMP versions(V1, V2c & V3) and associate them with the Dispatcher.
  • Initialize the internal MIBs.
  • Create the Security Module & associate it with the Protocol Engine(only V3 engine supports this).
  • Create the Command Responders for the different SNMP Versions(V1, V2c & V3) and associate them with the Dispatcher.
  • Create the Access Control Modules and associate them with the Command Responders as needed ( Currently there are implementations for Community based access control and View based access control with the later giving more fine grained control).
  • Create the MIB objects & their Info objects( that provide the SNMP protocol inoformation)  and associate them with the Command Responders as desired.
  • Start the Dispatcher

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.